Skip to content

Commit

Permalink
Merge pull request andras-simonyi#100 from andras-simonyi/99-Support_…
Browse files Browse the repository at this point in the history
…literal_names_in_CSL-JSON

99 Support literal names in CSL-JSON
  • Loading branch information
andras-simonyi authored Jan 22, 2022
2 parents 470ecfb + c28cc73 commit f665a12
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 19 deletions.
26 changes: 16 additions & 10 deletions citeproc-proc.el
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,19 @@ Return the itemdata struct that was added."
(setf (citeproc-itemdata-occurred-before itd) nil))
(citeproc-proc-itemdata proc)))

(defun citeproc-proc--parse-csl-json-name (rep)
"Parse the json representation REP of a csl name variable."
(if-let ((literal (alist-get 'literal rep)))
(list (cons 'family (citeproc-s-smart-apostrophes literal)))
(let ((filtered (-remove (lambda (x) (eq (car x) 'isInstitution)) rep)))
(--map (cons
(car it)
(let ((text-field (cdr it)))
(if (stringp text-field)
(citeproc-s-smart-apostrophes text-field)
text-field)))
filtered))))

(defun citeproc-proc--parse-csl-var-val (rep var proc)
"Parse the json representation REP of csl variable VAR.
VAR is a csl variable as symbol;
Expand All @@ -166,16 +179,9 @@ REP is its value in standard csl json representation as parsed by
PROC is the target citeproc-processor of the internal representation.
Return the PROC-internal representation of REP."
(cond ((memq var citeproc--name-vars)
(--map
(let* ((filtered (-remove (lambda (x) (eq (car x) 'isInstitution)) it))
(w-smart-aposts (--map (cons
(car it)
(let ((text-field (cdr it)))
(if (stringp text-field)
(citeproc-s-smart-apostrophes text-field)
text-field)))
filtered)))
(citeproc-proc--internalize-name w-smart-aposts proc))
(--map (citeproc-proc--internalize-name
(citeproc-proc--parse-csl-json-name it)
proc)
rep))
((memq var citeproc--date-vars)
(citeproc-date-parse rep))
Expand Down
9 changes: 0 additions & 9 deletions test/expected_fails.lst
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ citeproc-suite-bugreports-caps-after-one-word-prefix
citeproc-suite-bugreports-chicago-author-date-looping
citeproc-suite-bugreports-creeping-add-names
citeproc-suite-bugreports-demo-page-full-cite-cruft-on-subsequent
citeproc-suite-bugreports-double-encoded-angle-braces
citeproc-suite-bugreports-env-and-urb
citeproc-suite-bugreports-french-apostrophe
citeproc-suite-bugreports-ikey-one
Expand All @@ -21,7 +20,6 @@ citeproc-suite-bugreports-overwrite-citation-items
citeproc-suite-bugreports-parse-name
citeproc-suite-bugreports-single-quote-xml
citeproc-suite-bugreports-small-caps-escape
citeproc-suite-bugreports-year-suffix-in-harvard1
citeproc-suite-collapse-author-collapse-no-date-sorted
citeproc-suite-collapse-chicago-after-collapse
citeproc-suite-collapse-citation-number-ranges-insert
Expand Down Expand Up @@ -104,7 +102,6 @@ citeproc-suite-magic-name-suffix-no-comma
citeproc-suite-magic-name-suffix-with-comma
citeproc-suite-magic-punctuation-in-quote-nested
citeproc-suite-magic-superscript-chars
citeproc-suite-magic-suppress-duplicate-variable-rendering
citeproc-suite-magic-suppress-layout-delimiter-if-prefix-comma
citeproc-suite-magic-term-capitalization-with-prefix
citeproc-suite-name-articular-name-as-sort-order
Expand Down Expand Up @@ -132,9 +129,6 @@ citeproc-suite-name-initials-initialize-true
citeproc-suite-name-initials-initialize-true-empty
citeproc-suite-name-initials-initialize-true-period
citeproc-suite-name-initials-initialize-true-period-space
citeproc-suite-name-institution
citeproc-suite-name-institution-decoration
citeproc-suite-name-literal-with-comma
citeproc-suite-name-long-abbreviation
citeproc-suite-name-lowercase-surname-suffix
citeproc-suite-name-namepart-affixes
Expand Down Expand Up @@ -175,8 +169,6 @@ citeproc-suite-sort-bibliography-citation-number-descending-via-composite-macro
citeproc-suite-sort-bibliography-citation-number-descending-via-macro
citeproc-suite-sort-case-insensitive-bibliography
citeproc-suite-sort-case-insensitive-citation
citeproc-suite-sort-chicago-year-suffix1
citeproc-suite-sort-chicago-year-suffix2
citeproc-suite-sort-citation-number-primary-descending-via-macro-bibliography
citeproc-suite-sort-citation-number-primary-descending-via-macro-citation
citeproc-suite-sort-citation-number-primary-descending-via-variable-bibliography
Expand All @@ -193,7 +185,6 @@ citeproc-suite-sort-quotes
citeproc-suite-sort-range-unaffected
citeproc-suite-sort-separate-authors-and-others
citeproc-suite-sort-with-and-in-one-entry
citeproc-suite-substitute-shared-macro
citeproc-suite-substitute-substitute-only-once-string
citeproc-suite-substitute-substitute-only-once-term
citeproc-suite-substitute-substitute-only-once-term-empty
Expand Down

0 comments on commit f665a12

Please sign in to comment.