Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issues compiling minimal example #18

Closed
massimiliano-leoni opened this issue Jun 30, 2022 · 8 comments
Closed

Issues compiling minimal example #18

massimiliano-leoni opened this issue Jun 30, 2022 · 8 comments
Labels
bug Something isn't working

Comments

@massimiliano-leoni
Copy link

Hello! I'm really interested in using this package but somehow I can't make it work.
I am trying to compile the same example as in the readme,

\documentclass{article}

\usepackage{citation-style-language}
\cslsetup{style = apa}
\addbibresource{library.bib}

\begin{document}

\cite{Abrams2015a}
\printbibliography

\end{document}

I am on a [derivative of] Ubuntu 20.04, I installed the latest TexLive [2022] manually and the latest Lua.
When I do lualatex test.tex I get

mf-dist/scripts/citation-style-language/citeproc-bib.lua:158: invalid use of '%' in replacement string
stack traceback:
        [C]: in function 'string.gsub'
        ...mf-dist/scripts/citation-style-language/citeproc-bib.lua:158: in function '
citeproc-bib.unescape'
        ...mf-dist/scripts/citation-style-language/citeproc-bib.lua:127: in function '
citeproc-bib.convert_field'
        ...mf-dist/scripts/citation-style-language/citeproc-bib.lua:68: in function 'c
iteproc-bib.parse_item'
        ...mf-dist/scripts/citation-style-language/citeproc-bib.lua:40: in function 'c
iteproc-bib.parse'
        .../texmf-dist/scripts/citation-style-language/csl-core.lua:99: in upvalue 're
ad_data_file'
        .../texmf-dist/scripts/citation-style-language/csl-core.lua:109: in upvalue 'r
ead_data_files'
        .../texmf-dist/scripts/citation-style-language/csl-core.lua:126: in function '
csl-core.make_citeproc_sys'
        .../texmf-dist/scripts/citation-style-language/csl-core.lua:162: in function '
csl-core.init'
        ...stall/texmf-dist/scripts/citation-style-language/csl.lua:34: in function 'c
sl.init'
        [\directlua]:1: in main chunk.
\lua_now:e #1->\__lua_now:n {#1}

where the interesting bit is scripts/citation-style-language/citeproc-bib.lua:158: invalid use of '%' in replacement string. I commented that line out and ran again and this time I got a similar error that says

scripts/citation-style-language/citeproc-bib.lua:405: bad argument #1 to 'lower' (string expected, got nil)

so I went to that line and changed

  if bib_fields.eprint and string.lower(bib_fields.eprinttype) == "pubmed" and not item.PMID then

to

  if bib_fields.eprint and bib_fields.eprinttype and string.lower(bib_fields.eprinttype) == "pubmed" and not item.PMID then

to avoid the error. Now when I run lualatex it kinda hangs, cpu working but nothing really happening.

Can you help me out?
Thanks in advance!

@zepinglee
Copy link
Owner

@massimiliano-leoni Can you provide the contents of entry Abrams2015a in library.bib?

@massimiliano-leoni
Copy link
Author

massimiliano-leoni commented Jun 30, 2022

@zepinglee the entry is

@article{Abrams2015a,
abstract = {Recirculation, a phenomenon in which reinfused oxygenated blood is withdrawn by the drainage cannula without passing through the systemic circulation, decreases the efficiency with which venovenous extracorporeal membrane oxygenation (ECMO) provides oxygenation. The precise amount of recirculation may be difficult to quantify. However, interventions should be attempted to reduce recirculation when oxygen delivery is suboptimal and recirculation is suspected. Several techniques, including the use of dual-lumen cannulae, have been successful in minimizing recirculation in venovenous ECMO. This article will provide an overview of the factors that affect recirculation, methods that may be used to quantify recirculation, and interventions that may reduce recirculation, thereby increasing ECMO efficiency.},
annote = {Number: 2},
author = {Abrams, Darryl and Bacchetta, Matthew and Brodie, Daniel},
doi = {10.1097/MAT.0000000000000179},
file = {:home/mleoni/LaBibliotecaDelleScienze/Papers/Abrams, Bacchetta, Brodie/ASAIO Journal/Abrams, Bacchetta, Brodie - 2015 - Recirculation in Venovenous Extracorporeal Membrane Oxygenation(2).pdf:pdf},
issn = {1058-2916},
journal = {ASAIO Journal},
keywords = {Animals,Blood Circulation,Cardiovascular,Catheters,Extracorporeal Membrane Oxygenation,Hemodynamics,Humans,Models,Oxygen},
month = {mar},
number = {2},
pages = {115--121},
pmid = {25423117},
title = {{Recirculation in Venovenous Extracorporeal Membrane Oxygenation}},
url = {https://journals.lww.com/00002480-201503000-00001},
volume = {61},
year = {2015}
}

@massimiliano-leoni
Copy link
Author

I realised that the example provided in the repository, which I hadn't tried, does in fact compile. I tried to compile my own example having only Abrams2015a in the bibliography file and it compiles too. This meant that one of the entries makes it go into an infinite loop.
I used the power of bisection to skim through my bib file and I found the offending entry:


@article{Chen2008,
abstract = {The myocardial tissue lacks significant intrinsic regenerative capability to replace the lost cells. Therefore, the heart is a major target of research within the field of tissue engineering, which aims to replace infarcted myocardium and enhance cardiac function. The primary objective of this work was to develop a biocompatible, degradable and superelastic heart patch from poly(glycerol sebacate) (PGS). PGS was synthesised at 110, 120 and 130 °C by polycondensation of glycerol and sebacic acid with a mole ratio of 1:1. The investigation was focused on the mechanical and biodegrading behaviours of the developed PGS. PGS materials synthesised at 110, 120 and 130 °C have Young's moduli of 0.056, 0.22 and 1.2 MPa, respectively, which satisfy the mechanical requirements on the materials applied for the heart patch and 3D myocardial tissue engineering construction. Degradation assessment in phosphate buffered saline and Knockout™ DMEM culture medium has demonstrated that the PGS has a wide range of degradability, from being degradable in a couple of weeks to being nearly inert. The matching of physical characteristics to those of the heart, the ability to fine tune degradation rates in biologically relevant media and initial data showing biocompatibility indicate that this material has promise for cardiac tissue engineering applications. {\textcopyright} 2007 Elsevier Ltd. All rights reserved.},
author = {Chen, Qi-Zhi and Bismarck, Alexander and Hansen, Ulrich and Junaid, Sarah and Tran, Michael Q. and Harding, Si{\^{a}}n E. and Ali, Nadire N. and Boccaccini, Aldo R.},
doi = {10.1016/j.biomaterials.2007.09.010},
file = {::},
isbn = {0142-9612},
issn = {01429612},
journal = {Biomaterials},
keywords = {Biocompatibility,Degradation,Heart patch,Mechanical property,Myocardial tissue engineering,Poly(glycerol sebacate),human,rat},
mendeley-tags = {human,rat},
month = {jan},
number = {1},
pages = {47--57},
pmid = {17915309},
title = {{Characterisation of a soft elastomer poly(glycerol sebacate) designed to match the mechanical properties of myocardial tissue}},
url = {http://linkinghub.elsevier.com/retrieve/pii/S0142961207007156},
volume = {29},
year = {2008}
}

There's something in this entry that makes things go wrong. I hope this information is useful.

@massimiliano-leoni
Copy link
Author

This entry is offending too

@article{Strachinaru2017,
abstract = {The propagation velocity of shear waves relates to tissue stiffness. We prove that a regular clinical cardiac ultrasound system can determine shear wave velocity with a conventional unmodified tissue Doppler imaging (TDI) application. The investigation was performed on five tissue phantoms with different stiffness using a research platform capable of inducing and tracking shear waves and a clinical cardiac system (Philips iE33, achieving frame rates of 400–700 Hz in TDI by tuning the normal system settings). We also tested the technique in vivo on a normal individual and on typical pathologies modifying the consistency of the left ventricular wall. The research platform scanner was used as reference. Shear wave velocities measured with TDI on the clinical cardiac system were very close to those measured by the research platform scanner. The mean difference between the clinical and research systems was 0.18 ± 0.22 m/s, and the limits of agreement, from −0.27 to +0.63 m/s. In vivo, the velocity of the wave induced by aortic valve closure in the interventricular septum increased in patients with expected increased wall stiffness.},
author = {Strachinaru, Mihai and Bosch, Johan G. and van Dalen, Bas M. and van Gils, Lennart and van der Steen, Antonius F.W. and de Jong, Nico and Geleijnse, Marcel L. and Vos, Hendrik J.},
doi = {10.1016/j.ultrasmedbio.2017.04.012},
file = {::},
issn = {03015629},
journal = {Ultrasound in Medicine {\&} Biology},
keywords = {Elastography,High-frame-rate tissue Doppler,Shear waves,Stiffness,human,in-vivo},
mendeley-tags = {human,in-vivo},
month = {aug},
number = {8},
pages = {1596--1606},
pmid = {28545859},
title = {{Cardiac Shear Wave Elastography Using a Clinical Ultrasound System}},
url = {https://linkinghub.elsevier.com/retrieve/pii/S0301562917301771},
volume = {43},
year = {2017}
}

zepinglee added a commit that referenced this issue Jul 1, 2022
@zepinglee
Copy link
Owner

"^(%w+)%s*=%s*(%b{}),?%s*(.-)$",
'^(%w+)%s*=%s*"([^"]*)",?%s*(.-)$',
"^(%w+)%s*=%s*(%w+),?%s*(.-)$",

These patterns fail to match field names like mendeley-tags and somehow cause infinite loop.
6c16e30 should fix it.

I suggest CSL-JSON format for data input if you are using Zotero. The current bib parser is a naive implementation and it's likely to fail in some cases. I'm planning to rewrite it with lpeg in the future but I'm currently working on the disambiguation feature.

@massimiliano-leoni
Copy link
Author

I'm using Mendeley desktop [but not for long since they're discontinuing it...] and it can't export to CSL-JSON. I'll try Zotero and JabRef, the latter looks somewhat better to me but it exports to CSL-YAML, not CSL-JSON. Does that work?

@zepinglee
Copy link
Owner

I'm using Mendeley desktop [but not for long since they're discontinuing it...] and it can't export to CSL-JSON. I'll try Zotero and JabRef, the latter looks somewhat better to me but it exports to CSL-YAML, not CSL-JSON. Does that work?

YAML is not supported at the moment.

I find lua-tinyyaml is in CTAN and TeX Live (as a part of the markdown package). So it should be easy to support YAML format.

@ThiloteE
Copy link

ThiloteE commented Jul 5, 2022

JabRef is .bib native and indeed currently is not able to export to CSL-JSON.

Maybe https://pandoc.org/ could help here?

Of course not a satisfactory solution in the mid or long run, but if push comes to shove, you could simply rename the mendely-tags field to mendelytags or something else via "find and replace" to get the compilation going. Various text editors can do this job, or also JabRef via Edit > Manage field names and content.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants