Skip to content

Commit 5df4e19

Browse files
authored
Merge pull request #12393 from quarto-dev/fix/lua-api
Fix lua api for cite-method and pdf-engine
2 parents 1383f1e + 007ec23 commit 5df4e19

File tree

7 files changed

+61
-2
lines changed

7 files changed

+61
-2
lines changed

news/changelog-1.7.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,10 @@ All changes included in 1.7:
108108
- ([#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.
109109
- ([#11379](https://github.com/quarto-dev/quarto-cli/issues/11379)): Add `version` shortcode to display the current Quarto version.
110110

111+
## Quarto Lua API
112+
113+
- ([#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).
114+
111115
## Engines
112116

113117
### `julia`

src/command/render/filters.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -838,7 +838,7 @@ function citeMethod(options: PandocOptions): CiteMethod | null {
838838

839839
function pdfEngine(options: PandocOptions): string {
840840
const pdfEngine = options.flags?.pdfEngine ||
841-
options.metadata?.[kPdfEngine] as string ||
841+
options.format.pandoc?.[kPdfEngine] as string ||
842842
"pdflatex";
843843
return pdfEngine;
844844
}

src/resources/pandoc/datadir/init.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2082,7 +2082,7 @@ quarto = {
20822082
is_format = format.isFormat,
20832083

20842084
cite_method = function()
2085-
local citeMethod = param('cite-method', 'citeproc')
2085+
local citeMethod = param('cite-method', nil)
20862086
return citeMethod
20872087
end,
20882088
pdf_engine = function()
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
function Pandoc(doc)
2+
assert(quarto.doc.pdf_engine() == "xelatex", "`quarto.doc.pdf_engine()` should be xelatex but is instead: " .. quarto.doc.pdf_engine())
3+
assert(quarto.doc.cite_method() == "natbib", "`quarto.doc.cite_method()` should return natbib but return instead: " .. (quarto.doc.cite_method() or 'unset'))
4+
return doc
5+
end
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
---
2+
title: testing Lua API value for latex
3+
format:
4+
latex:
5+
pdf-engine: xelatex
6+
cite-method: natbib
7+
references:
8+
- type: article-journal
9+
id: WatsonCrick1953
10+
author:
11+
- family: Watson
12+
given: J. D.
13+
- family: Crick
14+
given: F. H. C.
15+
issued:
16+
date-parts:
17+
- - 1953
18+
- 4
19+
- 25
20+
title: 'Molecular structure of nucleic acids: a structure for
21+
deoxyribose nucleic acid'
22+
title-short: Molecular structure of nucleic acids
23+
container-title: Nature
24+
volume: 171
25+
issue: 4356
26+
page: 737-738
27+
DOI: 10.1038/171737a0
28+
URL: https://www.nature.com/articles/171737a0
29+
language: en-GB
30+
filters:
31+
- 12299-1.lua
32+
---
33+
34+
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
function Pandoc(doc)
2+
assert(quarto.doc.pdf_engine() == "xelatex", "`quarto.doc.pdf_engine()` should be xelatex but is instead: " .. quarto.doc.pdf_engine())
3+
assert(quarto.doc.cite_method() == nil, "`quarto.doc.cite_method()` should return natbib but return instead: " .. (quarto.doc.cite_method() or 'unset'))
4+
return doc
5+
end
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
---
2+
title: testing Lua API value for latex
3+
format:
4+
latex:
5+
pdf-engine: xelatex
6+
cite-method: natbib
7+
filters:
8+
- 12299.lua
9+
---
10+
11+

0 commit comments

Comments
 (0)