zepinglee / citeproc-lua

A Lua implementation of the Citation Style Language (CSL) for use with LaTeX
MIT License
66 stars 8 forks source link

Issue with hyperref package and % signs in URLs #30

Closed nickw2066 closed 1 year ago

nickw2066 commented 2 years ago

With the following JSON file:

[
    {
        "id": "McCarthy2007-Biblia5",
        "type": "book",
        "editor": [
            {
                "family": "McCarthy",
                "given": "Carmel"
            },
            {
                "family": "Schenker",
                "given": "A."
            },
            {
                "family": "Goldman",
                "given": "Y. A. P."
            },
            {
                "family": "van der Kooij",
                "given": "A."
            },
            {
                "family": "Norton",
                "given": "G. J."
            }
        ],
        "title": "Biblia Hebraica Quinta: Deuteronomy",
        "title-short": "BHQ Deuteronomy",
        "source": "PDF",
        "volume": "5",
        "publisher-place": "Stuttgart",
        "publisher": "Deutsche Bibelgesellshaft",
        "URL": "https://linker2.worldcat.org/?jHome=https%3A%2F%2Fgldtl.idm.oclc.org%2Flogin%3Furl%3Dhttps%3A%2F%2Flibguides.thedtl.org%2Fc.php%3Fg%3D1208840&linktype=best",
        "issued": {
            "date-parts": [
                [
                    "2007"
                ]
            ]
        },
        "accessed": {
            "date-parts": [
                [
                    "2022",
                    "09",
                    "16"
                ]
            ]
        }
    }
]

this code complies fine:

% !TEX encoding = UTF-8 Unicode
\documentclass[12pt,oneside]{article}

\usepackage{citation-style-language}
\cslsetup{style = apa}
\addbibresource{myBib.json}

\begin{document}

Test\cite[page = 588]{McCarthy2007-Biblia5}

\newpage
\printbibliography
\end{document}

But when I try to use the hyperref package

% !TEX encoding = UTF-8 Unicode
\documentclass[12pt,oneside]{article}

\usepackage{citation-style-language}
\cslsetup{style = apa}
\addbibresource{myBib.json}

\usepackage{hyperref}

\begin{document}

Test\cite[page = 588]{McCarthy2007-Biblia5}

\newpage
\printbibliography
\end{document}

I get the following error (in texmaker):

! File ended while scanning use of \environment thebibliography .<inserted text>\par<> "mwe url percentage.tex"I suspect you have forgotten a `}', causing meto read past where you wanted me to stop.I'll try to recover; but if the error is serious,you'd better type `E' or `X' now and fix your file.! Emergency stop.<> "mwe url percentage.tex" (job aborted, no legal \end found)Here is how much of LuaTeX's memory you used:8329 strings out of 477250100000,552014 words of node,token memory allocated 393 words of node memory still in use:2 hlist, 1 rule, 1 dir, 3 kern, 1 glyph, 2 attribute, 53 glue_spec, 2 attribute_list nodesavail lists: 1:1,2:41,3:10,4:1,5:35,6:3,7:162,8:6,9:41,11:329312 multiletter control sequences out of 65536+60000015 fonts using 723367 bytes77i,5n,74p,245b,325s stack positions out of 10000i,1000n,20000p,200000b,200000s! ==> Fatal error occurred, no output PDF file produced!

When I remove the % signs from the URL in the JSON file, the code (with the hyperref package) compiles fine.

Do you know what the error is?

Thanks, Nick

zepinglee commented 2 years ago

Thanks for your feedback and I can reproduce the bug.

zepinglee commented 1 year ago

I've added the catcode tricks (ac96717) and now the special characters are correctly recognized. It turns out that I have to modify almost all the test files. Anyway now it works fine with the given example.