From 433c7c3d18b2c75d9e42341d5cef2f6422cf146c Mon Sep 17 00:00:00 2001 From: Christophe Dervieux Date: Thu, 27 Mar 2025 17:25:24 +0100 Subject: [PATCH 1/5] Add a test --- tests/docs/smoke-all/2025/03/27/12299.lua | 5 +++++ tests/docs/smoke-all/2025/03/27/12299.qmd | 11 +++++++++++ 2 files changed, 16 insertions(+) create mode 100644 tests/docs/smoke-all/2025/03/27/12299.lua create mode 100644 tests/docs/smoke-all/2025/03/27/12299.qmd 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..f404714d44 --- /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() == "natbib", "`quarto.doc.cite_method()` should return natbib but return instead: " .. quarto.doc.cite_method()) + 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 +--- + + From eee790d707dee4ea116b6c9aaeaed91a9d3050f0 Mon Sep 17 00:00:00 2001 From: Christophe Dervieux Date: Thu, 27 Mar 2025 17:29:17 +0100 Subject: [PATCH 2/5] `pdf-engine` is in `format.pandoc` not `metadata` --- src/command/render/filters.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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; } From 52271d929449a22d4b3997a34121ba32cecc4de6 Mon Sep 17 00:00:00 2001 From: Christophe Dervieux Date: Thu, 27 Mar 2025 17:45:14 +0100 Subject: [PATCH 3/5] in lua api, don't set a default if `cite-method` is false --- src/resources/pandoc/datadir/init.lua | 2 +- tests/docs/smoke-all/2025/03/27/12299.lua | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) 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.lua b/tests/docs/smoke-all/2025/03/27/12299.lua index f404714d44..d309fc1746 100644 --- a/tests/docs/smoke-all/2025/03/27/12299.lua +++ b/tests/docs/smoke-all/2025/03/27/12299.lua @@ -1,5 +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()) + 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 From 985346a448d02b2903d9b60e398d7bfabdb61d30 Mon Sep 17 00:00:00 2001 From: Christophe Dervieux Date: Thu, 27 Mar 2025 17:47:23 +0100 Subject: [PATCH 4/5] Add a test for when `cite-method` is correctly taken into account When `cite-method` is set in YAML, its value is only considered when references will be used either by `bibliography` or `references` in YAML header --- tests/docs/smoke-all/2025/03/27/12299-1.lua | 5 +++ tests/docs/smoke-all/2025/03/27/12299-1.qmd | 34 +++++++++++++++++++++ 2 files changed, 39 insertions(+) create mode 100644 tests/docs/smoke-all/2025/03/27/12299-1.lua create mode 100644 tests/docs/smoke-all/2025/03/27/12299-1.qmd 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 +--- + + From 007ec2334b736d034612b8f4760fb16e9a9279d3 Mon Sep 17 00:00:00 2001 From: Christophe Dervieux Date: Thu, 27 Mar 2025 18:14:35 +0100 Subject: [PATCH 5/5] add to changelog [skip ci] --- news/changelog-1.7.md | 4 ++++ 1 file changed, 4 insertions(+) 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`