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

Asciidoc: don't call pandoc.write() #7645

Merged
merged 3 commits into from
Nov 20, 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
1 change: 1 addition & 0 deletions news/changelog-1.4.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@
## Asciidoc Format

- ([#6589](https://github.com/quarto-dev/quarto-cli/issues/6589)): Don't crash when `format: asciidoc` with a missing title.
- ([#7632](https://github.com/quarto-dev/quarto-cli/issues/7632)): Render citations properly inside callouts

## Confluence Format

Expand Down
18 changes: 14 additions & 4 deletions src/resources/filters/quarto-post/render-asciidoc.lua
Original file line number Diff line number Diff line change
Expand Up @@ -60,16 +60,26 @@ function render_asciidoc()
-- render the callout contents
local admonitionContents = pandoc.write(pandoc.Pandoc(el.content), "asciidoc")
cscheid marked this conversation as resolved.
Show resolved Hide resolved

local admonitionStr;
local admonitionPre
local admonitionPost = "====\n\n"

if el.title then
-- A titled admonition
local admonitionTitle = pandoc.write(pandoc.Pandoc({el.title}), "asciidoc")
admonitionStr = "[" .. admonitionType .. "]\n." .. admonitionTitle .. "====\n" .. admonitionContents .. "====\n\n"
admonitionPre = "[" .. admonitionType .. "]\n." .. admonitionTitle .. "====\n"
else
-- A titleless admonition
admonitionStr = "[" .. admonitionType .. "]\n====\n" .. admonitionContents .. "====\n\n"
admonitionPre = "[" .. admonitionType .. "]\n====\n"
end

if el.content.t == "Para" then
el.content.content:insert(1, pandoc.RawInline("asciidoc", admonitionPre))
el.content.content:insert(pandoc.RawInline("asciidoc", "\n" .. admonitionPost))
elseif pandoc.utils.type(el.content) == "Blocks" then
el.content:insert(1, pandoc.RawBlock("asciidoc", admonitionPre))
el.content:insert(pandoc.RawBlock("asciidoc", admonitionPost))
end
return pandoc.RawBlock("asciidoc", admonitionStr)
return el.content
end,
Inlines = function(el)
-- Walk inlines and see if there is an inline code followed directly by a note.
Expand Down
23 changes: 23 additions & 0 deletions tests/docs/smoke-all/2023/11/20/7632.qmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
---
title: AsciiDoc Citation Test
bibliography: references.bib
_quarto:
tests:
asciidoc:
ensureFileRegexMatches:
- []
- ["@wickham2015"]
---

## Introduction

Foo [@knuth1984].

::: {.callout-important}
Bar [@wickham2015].
:::

## References {.unnumbered}

::: {#refs}
:::
87 changes: 87 additions & 0 deletions tests/docs/smoke-all/2023/11/20/references.bib
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
@Book{xie2015,
title = {Dynamic Documents with {R} and knitr},
author = {Yihui Xie},
publisher = {Chapman and Hall/CRC},
address = {Boca Raton, Florida},
year = {2015},
edition = {2nd},
note = {ISBN 978-1498716963},
url = {https://yihui.name/knitr/},
}
@Book{xie2016,
title = {bookdown: Authoring Books and Technical Documents with {R} Markdown},
author = {Yihui Xie},
publisher = {Chapman and Hall/CRC},
address = {Boca Raton, Florida},
year = {2016},
note = {ISBN 978-1138700109},
url = {https://github.com/rstudio/bookdown},
}
@Book{xie2017,
title = {blogdown: Creating Websites with {R} Markdown},
author = {Yihui Xie and Alison Presmanes Hill and Amber Thomas},
publisher = {Chapman and Hall/CRC},
address = {Boca Raton, Florida},
year = {2017},
note = {ISBN 978-0815363729},
url = {https://github.com/rstudio/blogdown},
}
@Book{xie2018,
title = {R Markdown: The Definitive Guide},
author = {Yihui Xie and J.J. Allaire and Garrett Grolemund},
publisher = {Chapman and Hall/CRC},
address = {Boca Raton, Florida},
year = {2018},
note = {ISBN 9781138359338},
url = {https://bookdown.org/yihui/rmarkdown},
}
@Book{wickham2015,
author = {Wickham, Hadley},
title = {R Packages},
year = {2015},
isbn = {1491910593, 9781491910597},
edition = {1st},
publisher = {O'Reilly Media, Inc.},
}
@article{bion2018,
author = {Ricardo Bion and Robert Chang and Jason Goodman},
title = {How R Helps Airbnb Make the Most of its Data},
journal = {The American Statistician},
volume = {72},
number = {1},
pages = {46-52},
year = {2018},
publisher = {Taylor \& Francis},
doi = {10.1080/00031305.2017.1392362},
URL = {https://doi.org/10.1080/00031305.2017.1392362},
eprint = {https://doi.org/10.1080/00031305.2017.1392362}
}
@article{knuth1984,
title={Literate programming},
author={Knuth, Donald E.},
journal={The Computer Journal},
volume={27},
number={2},
pages={97--111},
year={1984},
publisher={British Computer Society}
}
@article{hartgerink2017,
title={Too good to be false: Nonsignificant results revisited},
author={Hartgerink, Chris HJ and Wicherts, Jelte M and van Assen, Marcel ALM},
journal={Collabra: Psychology},
volume={3},
number={1},
year={2017},
publisher={The Regents of the University of California}
}
@article{lowndes2017,
title={Our path to better science in less time using open data science tools},
author={Lowndes, Julia S Stewart and Best, Benjamin D and Scarborough, Courtney and Afflerbach, Jamie C and Frazier, Melanie R and O’Hara, Casey C and Jiang, Ning and Halpern, Benjamin S},
journal={Nature ecology \& evolution},
volume={1},
number={6},
year={2017},
publisher={Nature Publishing Group}
}