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

Update to pandoc 3.1.11 and typst 0.10.0 #7914

Merged
merged 7 commits into from
Dec 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions configuration
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@
export DENO=v1.37.2
# TODO figure out where 0.1.41 apple silicon libs are available
export DENO_DOM=v0.1.35-alpha-artifacts
export PANDOC=3.1.9
export PANDOC=3.1.11
export DARTSASS=1.69.5
export ESBUILD=0.19.5
export TYPST=0.9.0
export TYPST=0.10.0


# NB: we can't put comments in the same line as export statements because it
Expand Down
2 changes: 2 additions & 0 deletions src/core/pandoc/format-extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
export const kPandocExtensions = [
"+abbreviations",
"-abbreviations",
"+alerts",
"-alerts",
"+all_symbols_escapable",
"-all_symbols_escapable",
"+amuse",
Expand Down
2 changes: 1 addition & 1 deletion src/format/html/format-html-appendix.ts
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ export async function processDocumentAppendix(

// Move the footnotes into the appendix
if (!hasMarginRefs(format, flags)) {
const footnoteEls = doc.querySelectorAll('aside[role="doc-endnotes"]');
const footnoteEls = doc.querySelectorAll('section[role="doc-endnotes"]');
if (footnoteEls && footnoteEls.length === 1) {
const footnotesEl = footnoteEls.item(0) as Element;
footnotesEl.tagName = "SECTION";
Expand Down
13 changes: 0 additions & 13 deletions src/resources/filters/quarto-post/typst.lua
Original file line number Diff line number Diff line change
Expand Up @@ -93,18 +93,5 @@ function render_typst_fixups()
pandoc.RawInline("typst", "]"),
})
end,
Cite = function(cite)
if PANDOC_VERSION <= pandoc.types.Version('3.1.9') then
-- Patch for https://github.com/quarto-dev/quarto-cli/issues/7586
-- TODO: Remove when Pandoc > 3.1.9 is used https://github.com/jgm/pandoc/issues/9188
if PANDOC_WRITER_OPTIONS.extensions:includes("citations") then
citations = pandoc.List()
for _, citation in pairs(cite.citations) do
citations:insert(pandoc.RawInline('typst', "#cite(<" .. citation.id .. ">)"))
end
return citations
end
end
end
}
end
2 changes: 1 addition & 1 deletion src/resources/formats/pdf/pandoc/latex.template
Original file line number Diff line number Diff line change
Expand Up @@ -425,7 +425,7 @@ $endif$
$if(csquotes)$
\usepackage{csquotes}
$endif$
\IfFileExists{bookmark.sty}{\usepackage{bookmark}}{\usepackage{hyperref}}
\usepackage{bookmark}
\IfFileExists{xurl.sty}{\usepackage{xurl}}{} % add URL line breaks if available
\urlstyle{$if(urlstyle)$$urlstyle$$else$same$endif$}
$if(links-as-notes)$
Expand Down
3 changes: 2 additions & 1 deletion src/resources/formats/pdf/pandoc/template.tex
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,8 @@
$if(csquotes)$
\usepackage{csquotes}
$endif$
\IfFileExists{bookmark.sty}{\usepackage{bookmark}}{\usepackage{hyperref}}
\usepackage{bookmark}

\IfFileExists{xurl.sty}{\usepackage{xurl}}{} % add URL line breaks if available
\urlstyle{same} % disable monospaced font for URLs
$if(links-as-notes)$
Expand Down
5 changes: 0 additions & 5 deletions src/resources/formats/typst/pandoc/definitions.typst
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
// Some definitions presupposed by pandoc's typst output.
#let blockquote(body) = [
#set text( size: 0.92em )
#block(inset: (left: 1.5em, top: 0.2em, bottom: 0.2em))[#body]
]

#let horizontalrule = [
#line(start: (25%,0%), end: (75%,0%))
]
Expand Down
60 changes: 31 additions & 29 deletions src/resources/formats/typst/pandoc/quarto/definitions.typ
Original file line number Diff line number Diff line change
Expand Up @@ -62,38 +62,40 @@
}

#show figure: it => {
if type(it.kind) != "string" {
return it
}
let kind_match = it.kind.matches(regex("^quarto-callout-(.*)")).at(0, default: none)
if kind_match != none {
let kind = kind_match.captures.at(0, default: "other")
kind = upper(kind.first()) + kind.slice(1)
// now we pull apart the callout and reassemble it with the crossref name and counter

// when we cleanup pandoc's emitted code to avoid spaces this will have to change
let old_callout = it.body.children.at(1).body.children.at(1)
let old_title_block = old_callout.body.children.at(0)
let old_title = old_title_block.body.body.children.at(2)

// TODO use custom separator if available
let new_title = if empty(old_title) {
[#kind #it.counter.display()]
} else {
[#kind #it.counter.display(): #old_title]
}

let new_title_block = block_with_new_content(
old_title_block,
block_with_new_content(
old_title_block.body,
old_title_block.body.body.children.at(0) +
old_title_block.body.body.children.at(1) +
new_title))

block_with_new_content(old_callout,
new_title_block +
old_callout.body.children.at(1))
if kind_match == none {
return it
}
let kind = kind_match.captures.at(0, default: "other")
kind = upper(kind.first()) + kind.slice(1)
// now we pull apart the callout and reassemble it with the crossref name and counter

// when we cleanup pandoc's emitted code to avoid spaces this will have to change
let old_callout = it.body.children.at(1).body.children.at(1)
let old_title_block = old_callout.body.children.at(0)
let old_title = old_title_block.body.body.children.at(2)

// TODO use custom separator if available
let new_title = if empty(old_title) {
[#kind #it.counter.display()]
} else {
it
[#kind #it.counter.display(): #old_title]
}

let new_title_block = block_with_new_content(
old_title_block,
block_with_new_content(
old_title_block.body,
old_title_block.body.body.children.at(0) +
old_title_block.body.body.children.at(1) +
new_title))

block_with_new_content(old_callout,
new_title_block +
old_callout.body.children.at(1))
}

#show ref: it => locate(loc => {
Expand Down
10 changes: 8 additions & 2 deletions src/resources/formats/typst/pandoc/template.typst
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#let conf(
title: none,
authors: none,
authors: (),
keywords: (),
date: none,
abstract: none,
cols: 1,
Expand All @@ -13,6 +14,11 @@
sectionnumbering: none,
doc,
) = {
set document(
title: title,
author: authors.map(author => author.name),
keywords: keywords,
)
set page(
paper: paper,
margin: margin,
Expand All @@ -31,7 +37,7 @@
]]
}

if authors != none {
if authors != none and authors != [] {
let count = authors.len()
let ncols = calc.min(count, 3)
grid(
Expand Down
24 changes: 15 additions & 9 deletions src/resources/formats/typst/pandoc/typst.template
Original file line number Diff line number Diff line change
Expand Up @@ -23,19 +23,22 @@ $if(author)$
authors: (
$for(author)$
$if(author.name)$
( name: [$author.name$],
affiliation: [$author.affiliation$],
email: [$author.email$] ),
( name: "$author.name$",
affiliation: "$author.affiliation$",
email: "$author.email$" ),
$else$
( name: [$author$],
affiliation: [],
email: [] ),
( name: "$author$",
affiliation: "",
email: "" ),
$endif$
$endfor$
),
$endif$
$if(keywords)$
keywords: ($for(keywords)$$keyword$$sep$,$endfor$),
$endif$
$if(date)$
date: [$date$],
date: "$date$",
$endif$
$if(lang)$
lang: "$lang$",
Expand Down Expand Up @@ -76,14 +79,17 @@ $endfor$
$if(toc)$
#outline(
title: auto,
depth: none
depth: $toc-depth$
);
$endif$

$body$

$if(citations)$
$if(bibliographystyle)$
$if(csl)$

#set bibliography(style: "$csl$")
$elseif(bibliographystyle)$

#set bibliography(style: "$bibliographystyle$")
$endif$
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ _quarto:
- "<tbl-foo>"
- "@fig-foo"
- "@tbl-foo"
- "#link\\(\"https://www.example.com/\"\\)\\[#.*image\\(\"img/surus.jpg\"\\)\\)\\]"
- "#link\\(\"https://www.example.com/\"\\)\\[#.*image\\(\"img/surus.jpg\"\\)\\)"
---

This tests:
Expand Down