From 243f8039879ca31f710f6911acd7503652f22448 Mon Sep 17 00:00:00 2001 From: Zeping Lee Date: Fri, 4 Oct 2024 13:40:55 +0800 Subject: [PATCH] Convert locator to HTML-like tagged string (fix #78) --- CHANGELOG.md | 4 + citeproc/citeproc-manager.lua | 5 + tests/fixtures/local/issue_78.txt | 1570 +++++++++++++++++++++++++++++ tests/latex/luatex-1/issue-78.lvt | 58 ++ tests/latex/luatex-1/issue-78.tlg | 131 +++ 5 files changed, 1768 insertions(+) create mode 100644 tests/fixtures/local/issue_78.txt create mode 100644 tests/latex/luatex-1/issue-78.lvt create mode 100644 tests/latex/luatex-1/issue-78.tlg diff --git a/CHANGELOG.md b/CHANGELOG.md index 7a21395..3b24793 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +### Fixed + +- The locator in citation is converted to HTML-like tagged string ([#78](https://github.com/zepinglee/citeproc-lua/issues/78)). + ## [0.6.4] - 2024-09-15 ### Fixed diff --git a/citeproc/citeproc-manager.lua b/citeproc/citeproc-manager.lua index e361d6f..fc9e132 100644 --- a/citeproc/citeproc-manager.lua +++ b/citeproc/citeproc-manager.lua @@ -659,6 +659,11 @@ function CslCitationManager:_make_citation(citation_info) for i, item in ipairs(citation.citationItems) do local citation_item = parse_latex_prop(item) + + if citation_item.locator and type(citation_item.locator) == "string" then + citation_item.locator = latex_parser.latex_to_pseudo_html(citation_item.locator, true, false) + end + if citation_item.prefix then -- util.debug(citation_item.prefix) citation_item.prefix = latex_parser.latex_to_pseudo_html(citation_item.prefix, true, false) diff --git a/tests/fixtures/local/issue_78.txt b/tests/fixtures/local/issue_78.txt new file mode 100644 index 0000000..79963f6 --- /dev/null +++ b/tests/fixtures/local/issue_78.txt @@ -0,0 +1,1570 @@ +>>===== MODE =====>> +citation +<<===== MODE =====<< + + +>>===== DESCRIPTION =====>> +issue-78 +<<===== DESCRIPTION =====<< + + +>>===== RESULT =====>> +>>[0] John T. King, “A Grammar of Dhimal” (doctoral dissertation, Universiteit Leiden, 2008), PDF hlm. 20, https://scholarlypublications.universiteitleiden.nl/handle/1887/13072. +<<===== RESULT =====<< + + +>>===== CITATIONS =====>> +[ + [ + { + "citationID" : "King2008-Gramma@1", + "citationItems" : [ + { + "id" : "King2008-Gramma", + "label" : "page", + "locator" : "PDF hlm. 20" + } + ], + "properties" : { + "noteIndex" : 1 + } + }, + [], + [] + ] +] +<<===== CITATIONS =====<< + + +>>===== CSL =====>> + + + +<<===== CSL =====<< + + +>>===== INPUT =====>> +[ + { + "URL" : "https://scholarlypublications.universiteitleiden.nl/handle/1887/13072", + "accessed" : { + "date-parts" : [ + [ "2024", "08", "13" ] + ] + }, + "author" : [ + { + "family" : "King", + "given" : "John T." + } + ], + "genre" : "doctoral dissertation", + "id" : "King2008-Gramma", + "issued" : { + "date-parts" : [ + [ 2008, 9, 3 ] + ] + }, + "publisher" : "Universiteit Leiden", + "publisher-place" : "Netherlands", + "title" : "A Grammar of Dhimal", + "type" : "thesis" + } +] +<<===== INPUT =====<< + + +>>===== VERSION =====>> +1.0 +<<===== VERSION =====<< diff --git a/tests/latex/luatex-1/issue-78.lvt b/tests/latex/luatex-1/issue-78.lvt new file mode 100644 index 0000000..0d97e5d --- /dev/null +++ b/tests/latex/luatex-1/issue-78.lvt @@ -0,0 +1,58 @@ +% + +\input{regression-test} +\documentclass{article} +\input{csl-test} + +\begin{filecontents}[overwrite, noheader]{\jobname.json} +[ + { + "id": "King2008-Gramma", + "type": "thesis", + "author": [ + { + "family": "King", + "given": "John T." + } + ], + "title": "A Grammar of Dhimal", + "publisher-place": "Netherlands", + "publisher": "Universiteit Leiden", + "URL": "https://scholarlypublications.universiteitleiden.nl/handle/1887/13072", + "genre": "doctoral dissertation", + "issued": { + "date-parts": [ + [ + "2008", + "9", + "3" + ] + ] + }, + "accessed": { + "date-parts": [ + [ + "2024", + "08", + "13" + ] + ] + } + } +] +\end{filecontents} + +\usepackage[style=chicago-fullnote-bibliography]{citation-style-language} +\cslsetup{regression-test = true} +\addbibresource{\jobname.json} + +\newcommand{\hlm}{hlm.} + + +\begin{document} +\START + +Commands don't work in the content of the page option.\cite[page = {PDF \hlm\ 20}]{King2008-Gramma} + +\OMIT +\end{document} diff --git a/tests/latex/luatex-1/issue-78.tlg b/tests/latex/luatex-1/issue-78.tlg new file mode 100644 index 0000000..95f6e28 --- /dev/null +++ b/tests/latex/luatex-1/issue-78.tlg @@ -0,0 +1,131 @@ +This is a generated file for the l3build validation system. +Don't change this file in any respect. +LaTeX Font Info: External font `cmex10' loaded for size +(Font) <7> on input line .... +LaTeX Font Info: External font `cmex10' loaded for size +(Font) <5> on input line .... +LaTeX Font Info: External font `cmex10' loaded for size +(Font) <8> on input line .... +LaTeX Font Info: External font `cmex10' loaded for size +(Font) <6> on input line .... +> \l__csl_citation_info_tl=citationID={King2008-Gramma@1},citationItems={{id={King2008-Gramma},label={page},locator={PDF \hlm \ 20}}},properties={noteIndex={1}}. + } +l. ......cite[page = {PDF \hlm\ 20}]{King2008-Gramma} +> \l__csl_citation_tl=John T. King, “A Grammar of Dhimal” (doctoral dissertation, Universiteit Leiden, 2008), PDF \hlm \ 20, \url {https://scholarlypublications.universiteitleiden.nl/handle/1887/13072}.. + } +l. ......cite[page = {PDF \hlm\ 20}]{King2008-Gramma} +Underfull \hbox (badness 1221) in paragraph at lines 55--55 +[][]\TU/lmr/m/n/8 John T. King, “A Gram-mar of Dhi-mal” (doc-toral dis-ser-ta-tion, Uni-ver-siteit Lei- +\hbox(6.81334+2.0)x345.0, glue set 2.30638, direction TLT +.\localpar +..\localinterlinepenalty=0 +..\localbrokenpenalty=0 +..\localleftbox=null +..\localrightbox=null +.\hbox(6.81334+0.0)x14.40002, glue set 10.23402fil, direction TLT +..\glue 0.0 plus 1.0fil minus 1.0fil +..\hbox(6.81334+0.0)x4.166, direction TLT +...\mathon +...\hbox(0.0+0.0)x0.0, direction TLT +...\hbox(3.99+0.0)x4.166, shifted -2.82333, direction TLT +....\TU/lmr/m/n/6 1 +...\mathoff +.\hbox(6.65+0.0)x0.0, direction TLT +..\rule(6.65+0.0)x0.0 +.\TU/lmr/m/n/8 J +.\TU/lmr/m/n/8 o +.\TU/lmr/m/n/8 h +.\TU/lmr/m/n/8 n +.\glue(\spaceskip) 2.832 plus 1.416 minus 0.944 +.\TU/lmr/m/n/8 T +.\TU/lmr/m/n/8 . +.\glue(\spaceskip) 2.832 plus 1.416 minus 0.944 +.\TU/lmr/m/n/8 K +.\TU/lmr/m/n/8 i +.\TU/lmr/m/n/8 n +.\TU/lmr/m/n/8 g +.\TU/lmr/m/n/8 , +.\glue(\spaceskip) 2.832 plus 1.76999 minus 0.75519 +.\TU/lmr/m/n/8 “ +.\TU/lmr/m/n/8 A +.\glue(\spaceskip) 2.832 plus 1.41458 minus 0.94493 +.\TU/lmr/m/n/8 G +.\TU/lmr/m/n/8 r +.\TU/lmr/m/n/8 a +.\TU/lmr/m/n/8 m +.\discretionary (penalty 50) +..< \TU/lmr/m/n/8 - +.\TU/lmr/m/n/8 m +.\TU/lmr/m/n/8 a +.\TU/lmr/m/n/8 r +.\glue(\spaceskip) 2.832 plus 1.416 minus 0.944 +.\TU/lmr/m/n/8 o +.\TU/lmr/m/n/8 f +.\glue(\spaceskip) 2.832 plus 1.416 minus 0.944 +.\TU/lmr/m/n/8 D +.\TU/lmr/m/n/8 h +.\TU/lmr/m/n/8 i +.\discretionary (penalty 50) +..< \TU/lmr/m/n/8 - +.\TU/lmr/m/n/8 m +.\TU/lmr/m/n/8 a +.\TU/lmr/m/n/8 l +.\TU/lmr/m/n/8 ” +.\glue(\spaceskip) 2.832 plus 1.416 minus 0.944 +.\TU/lmr/m/n/8 ( +.\TU/lmr/m/n/8 d +.\TU/lmr/m/n/8 o +.\kern0.24 (font) +.\TU/lmr/m/n/8 c +.\discretionary (penalty 50) +..< \TU/lmr/m/n/8 - +.\TU/lmr/m/n/8 t +.\TU/lmr/m/n/8 o +.\TU/lmr/m/n/8 r +.\TU/lmr/m/n/8 a +.\TU/lmr/m/n/8 l +.\glue(\spaceskip) 2.832 plus 1.416 minus 0.944 +.\TU/lmr/m/n/8 d +.\TU/lmr/m/n/8 i +.\TU/lmr/m/n/8 s +.\discretionary (penalty 50) +..< \TU/lmr/m/n/8 - +.\TU/lmr/m/n/8 s +.\TU/lmr/m/n/8 e +.\TU/lmr/m/n/8 r +.\discretionary (penalty 50) +..< \TU/lmr/m/n/8 - +.\TU/lmr/m/n/8 t +.\TU/lmr/m/n/8 a +.\discretionary (penalty 50) +..< \TU/lmr/m/n/8 - +.\TU/lmr/m/n/8 t +.\TU/lmr/m/n/8 i +.\TU/lmr/m/n/8 o +.\TU/lmr/m/n/8 n +.\TU/lmr/m/n/8 , +.\glue(\spaceskip) 2.832 plus 1.76999 minus 0.75519 +.\TU/lmr/m/n/8 U +.\TU/lmr/m/n/8 n +.\TU/lmr/m/n/8 i +.\discretionary (penalty 50) +..< \TU/lmr/m/n/8 - +.\TU/lmr/m/n/8 v +.\kern-0.24 (font) +.\TU/lmr/m/n/8 e +.\TU/lmr/m/n/8 r +.\discretionary (penalty 50) +..< \TU/lmr/m/n/8 - +.\TU/lmr/m/n/8 s +.\TU/lmr/m/n/8 i +.\TU/lmr/m/n/8 t +.\TU/lmr/m/n/8 e +.\TU/lmr/m/n/8 i +.\TU/lmr/m/n/8 t +.\glue(\spaceskip) 2.832 plus 1.416 minus 0.944 +.\TU/lmr/m/n/8 L +.\TU/lmr/m/n/8 e +.\TU/lmr/m/n/8 i +.\TU/lmr/m/n/8 - +.\discretionary (penalty 50) +.\glue(\rightskip) 0.0