diff --git a/news/changelog-1.7.md b/news/changelog-1.7.md index 9a0f4f8bc6..3d21616046 100644 --- a/news/changelog-1.7.md +++ b/news/changelog-1.7.md @@ -108,6 +108,10 @@ All changes included in 1.7: - ([#11664](https://github.com/quarto-dev/quarto-cli/issues/11664)): `lipsum` shortcode is no longer randomly generated by default, use `{{< lipsum random=true >}}` to restore randomness. - ([#11379](https://github.com/quarto-dev/quarto-cli/issues/11379)): Add `version` shortcode to display the current Quarto version. +## Quarto Lua API + +- ([#12299](https://github.com/quarto-dev/quarto-cli/issues/12299)): `quarto.doc.pdf_engine()` now correctly returns the PDF engine used for the document. `quarto.doc.cite_method()` now returns `nil` if no citation method will be used (i.e. no references is the document set). + ## Engines ### `julia` diff --git a/src/command/render/filters.ts b/src/command/render/filters.ts index 20fd5e9764..bae4f4d1a1 100644 --- a/src/command/render/filters.ts +++ b/src/command/render/filters.ts @@ -838,7 +838,7 @@ function citeMethod(options: PandocOptions): CiteMethod | null { function pdfEngine(options: PandocOptions): string { const pdfEngine = options.flags?.pdfEngine || - options.metadata?.[kPdfEngine] as string || + options.format.pandoc?.[kPdfEngine] as string || "pdflatex"; return pdfEngine; } diff --git a/src/resources/pandoc/datadir/init.lua b/src/resources/pandoc/datadir/init.lua index 26317928b6..0835e7d031 100644 --- a/src/resources/pandoc/datadir/init.lua +++ b/src/resources/pandoc/datadir/init.lua @@ -2082,7 +2082,7 @@ quarto = { is_format = format.isFormat, cite_method = function() - local citeMethod = param('cite-method', 'citeproc') + local citeMethod = param('cite-method', nil) return citeMethod end, pdf_engine = function() diff --git a/tests/docs/smoke-all/2025/03/27/12299-1.lua b/tests/docs/smoke-all/2025/03/27/12299-1.lua new file mode 100644 index 0000000000..3c9cb9071d --- /dev/null +++ b/tests/docs/smoke-all/2025/03/27/12299-1.lua @@ -0,0 +1,5 @@ +function Pandoc(doc) + assert(quarto.doc.pdf_engine() == "xelatex", "`quarto.doc.pdf_engine()` should be xelatex but is instead: " .. quarto.doc.pdf_engine()) + assert(quarto.doc.cite_method() == "natbib", "`quarto.doc.cite_method()` should return natbib but return instead: " .. (quarto.doc.cite_method() or 'unset')) + return doc +end \ No newline at end of file diff --git a/tests/docs/smoke-all/2025/03/27/12299-1.qmd b/tests/docs/smoke-all/2025/03/27/12299-1.qmd new file mode 100644 index 0000000000..47857e4ff6 --- /dev/null +++ b/tests/docs/smoke-all/2025/03/27/12299-1.qmd @@ -0,0 +1,34 @@ +--- +title: testing Lua API value for latex +format: + latex: + pdf-engine: xelatex + cite-method: natbib +references: +- type: article-journal + id: WatsonCrick1953 + author: + - family: Watson + given: J. D. + - family: Crick + given: F. H. C. + issued: + date-parts: + - - 1953 + - 4 + - 25 + title: 'Molecular structure of nucleic acids: a structure for + deoxyribose nucleic acid' + title-short: Molecular structure of nucleic acids + container-title: Nature + volume: 171 + issue: 4356 + page: 737-738 + DOI: 10.1038/171737a0 + URL: https://www.nature.com/articles/171737a0 + language: en-GB +filters: + - 12299-1.lua +--- + + diff --git a/tests/docs/smoke-all/2025/03/27/12299.lua b/tests/docs/smoke-all/2025/03/27/12299.lua new file mode 100644 index 0000000000..d309fc1746 --- /dev/null +++ b/tests/docs/smoke-all/2025/03/27/12299.lua @@ -0,0 +1,5 @@ +function Pandoc(doc) + assert(quarto.doc.pdf_engine() == "xelatex", "`quarto.doc.pdf_engine()` should be xelatex but is instead: " .. quarto.doc.pdf_engine()) + assert(quarto.doc.cite_method() == nil, "`quarto.doc.cite_method()` should return natbib but return instead: " .. (quarto.doc.cite_method() or 'unset')) + return doc +end \ No newline at end of file diff --git a/tests/docs/smoke-all/2025/03/27/12299.qmd b/tests/docs/smoke-all/2025/03/27/12299.qmd new file mode 100644 index 0000000000..11238be328 --- /dev/null +++ b/tests/docs/smoke-all/2025/03/27/12299.qmd @@ -0,0 +1,11 @@ +--- +title: testing Lua API value for latex +format: + latex: + pdf-engine: xelatex + cite-method: natbib +filters: + - 12299.lua +--- + +