-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add distinct references (#127)
* feat: add citation element * feat: add preamble parsing * feat: allow multiple csl locale files * fix: only merge preamble if a preamble exists * add citeproc-js + rendering of the in-text part of citations * prepare citeproc adapter for footnotes and bibliography * use values from preamble + add some styles and locales * add bibliography and footnotes to end of document * replace String::from with .to_string() * support german and english for bibliography heading * add the csl struct that Manuel generated * merge input .csl files to one json object * change type of citation_locales to HashMap<Locale, PathBuf> * add warnings to reading the locale and style files * add CiteErrors * run cargo fmt * move json serialization from get_citation_strings to new of Context + add logs when it fails * serialize each citation ids vector individually * add class for Css entries * try to stop clippy from complaining about the generated file * parse csl-locales from cli using a vector of tuples * serialize locale-pathbuf map using map serializer from serde * use custom visitor for citation_locales deserialization * use custom visitor for multiple locales deserialization * run cargo fmt * Revert "Merge branch 'main' into cite-box" This reverts commit 4c5eeb0, reversing changes made to 9d064a9. * Revert "Revert "Merge branch 'main' into cite-box"" This reverts commit 2746775. * fix: resolve merge conflicts * fix: add bib & footnotes to umi * fix: pass output format to render context * add unit test for citations * don't print bibliography and footnotes if the strings are empty * don't start the citeproc processor if the input doesn't contain citations * parse distinct references * parse distinct references using own parser method * also parse dots in parser for distinct references * add (simplified) rendering of distinct references * print integers without .0 * use author-only of citeproc js for authors in distinct references * fix formatting + tests * add unit tests for rendering distinct references * fix: add dot as field separator * fix: move dist-ref parser to scoped-parser --------- Co-authored-by: Manuel Hatzl <49341624+mhatzl@users.noreply.github.com>
- Loading branch information
1 parent
498ca1f
commit 5d8ffef
Showing
14 changed files
with
727 additions
and
90 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
# Unimarkup specification version | ||
spec: "0.0.1" | ||
|
||
name: distinct_reference | ||
description: Test lexing and parsing of text with distinct reference inline formatting. | ||
|
||
tests: | ||
- name: distinct-reference-without-fields | ||
description: | | ||
Distinct reference where the field "authors" should be added. | ||
input: | | ||
Text with distinct reference &&id-1&& without fields. | ||
- name: distinct-reference-with-one-field | ||
description: | | ||
Distinct reference with one field. | ||
input: | | ||
Text with distinct reference &&id-1.title&& with field title. | ||
- name: distinct-reference-with-multiple-fields | ||
description: | | ||
Distinct reference with multiple fields. | ||
input: | | ||
Text with distinct reference &&id-1.author.0.family&& with fields author, 0 and family. | ||
- name: multiple-distinct-references | ||
description: | | ||
Two distinct references | ||
input: | | ||
Text with a distinct reference &&id-1.title&& and another one &&id-2.issued&&. |
22 changes: 22 additions & 0 deletions
22
...sts/spec/snapshots/parser/distinct_reference/distinct-reference-with-multiple-fields.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
--- | ||
source: inline/tests/parser/mod.rs | ||
info: "Test 'distinct-reference-with-multiple-fields' from 'markup\\distinct_reference.yml'" | ||
--- | ||
Plain @ (1:1)->(1:30) ( | ||
Text with distinct reference | ||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
) | ||
DistinctReference @ (1:30)->(1:54) ( | ||
id-1.author.0.family | ||
) | ||
Plain @ (1:54)->(1:88) ( | ||
with fields author, 0 and family. | ||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
) | ||
|
||
--- | ||
With input: | ||
|
||
Text with distinct reference &&id-1.author.0.family&& with fields author, 0 and family. | ||
|
||
|
22 changes: 22 additions & 0 deletions
22
inline/tests/spec/snapshots/parser/distinct_reference/distinct-reference-with-one-field.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
--- | ||
source: inline/tests/parser/mod.rs | ||
info: "Test 'distinct-reference-with-one-field' from 'markup\\distinct_reference.yml'" | ||
--- | ||
Plain @ (1:1)->(1:30) ( | ||
Text with distinct reference | ||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
) | ||
DistinctReference @ (1:30)->(1:44) ( | ||
id-1.title | ||
) | ||
Plain @ (1:44)->(1:62) ( | ||
with field title. | ||
^^^^^^^^^^^^^^^^^^ | ||
) | ||
|
||
--- | ||
With input: | ||
|
||
Text with distinct reference &&id-1.title&& with field title. | ||
|
||
|
22 changes: 22 additions & 0 deletions
22
inline/tests/spec/snapshots/parser/distinct_reference/distinct-reference-without-fields.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
--- | ||
source: inline/tests/parser/mod.rs | ||
info: "Test 'distinct-reference-without-fields' from 'markup\\distinct_reference.yml'" | ||
--- | ||
Plain @ (1:1)->(1:30) ( | ||
Text with distinct reference | ||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
) | ||
DistinctReference @ (1:30)->(1:38) ( | ||
id-1.authors | ||
) | ||
Plain @ (1:38)->(1:54) ( | ||
without fields. | ||
^^^^^^^^^^^^^^^^ | ||
) | ||
|
||
--- | ||
With input: | ||
|
||
Text with distinct reference &&id-1&& without fields. | ||
|
||
|
29 changes: 29 additions & 0 deletions
29
inline/tests/spec/snapshots/parser/distinct_reference/multiple-distinct-references.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
--- | ||
source: inline/tests/parser/mod.rs | ||
info: "Test 'multiple-distinct-references' from 'markup\\distinct_reference.yml'" | ||
--- | ||
Plain @ (1:1)->(1:32) ( | ||
Text with a distinct reference | ||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
) | ||
DistinctReference @ (1:32)->(1:46) ( | ||
id-1.title | ||
) | ||
Plain @ (1:46)->(1:63) ( | ||
and another one | ||
^^^^^^^^^^^^^^^^^ | ||
) | ||
DistinctReference @ (1:63)->(1:78) ( | ||
id-2.issued | ||
) | ||
Plain @ (1:78)->(1:79) ( | ||
. | ||
^ | ||
) | ||
|
||
--- | ||
With input: | ||
|
||
Text with a distinct reference &&id-1.title&& and another one &&id-2.issued&&. | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.