-
Notifications
You must be signed in to change notification settings - Fork 19
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
Citations and cross-references in Quarto #215
Comments
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
OK, I figured this out. Proof of concept with bad user interface: https://vincentarelbundock.github.io/tinytable/vignettes/tinytable.html#quarto-data-processing Background on two issues:
On Github, I added a new global option to re-enable Quarto pre-processing. I also added an example to the vignette with a reference. The user experience is terrible, but it works. I'm not sure how to make the experience better. We can't enable pre-processing all the time, because there are tons of conflicts with nice features and styles. What does Should we insert that span automatically when the global option is set and a user calls |
Oh cool, yeah, this is roughly what {gt} does too. You have to disable quarto processing in an option—see
I'm fairly certain that when rendering to HTML, Quarto assumes that the content of chunks that create tables (like {gt}, {kableExtra}, {tinytable} and friends) is HTML. If that content has markdown content that needs to be parsed at the time of the whole document (like citation keys and cross references), it won't because Quarto assumes that all the formatting has been done (like with the markdown package for {tinytable}, or whatever {gt} uses to create its HTML), and the table is ready to go. The special span tells Quarto to do some further processing on those cells (e.g. parse the citation key). There's also a similar feature for LaTeX—there's a |
Thanks for the info. I've added a Mark a single cell for Quarto processing:
Apply Quarto data processing to all tables using a theme and a global option:
|
Closing this now, but feel free to open separate issues if you run into issues that you believe can be fixed on |
Sorry to jump back into this, but is the fix given by the extra
Everything works OK when output to html... |
@giabaio are you using the development version from GitHub? If so, what specific errors are you getting? |
I am on the Github version. Here's the error message
|
Weird. I don't get the same error. Can you make sure you are also running the latest Quarto? Maybe even try prerelase if 1.4 doesn't work. |
I was on a fairly recent commit on quarto-cli; just updated to the latest, but I still get the same error... I am investigating further too... |
With Quarto 1.5.29 on macOS I'm getting the same error: ---
title: "Reference stuff"
references:
- type: article-journal
id: Lovelace1842
author:
- family: Lovelace
given: Augusta Ada
issued:
date-parts:
- - 1842
title: >-
Sketch of the analytical engine invented by Charles Babbage, by LF Menabrea,
officer of the military engineers, with notes upon the memoir by the translator
title-short: Molecular structure of nucleic acids
container-title: Taylor’s Scientific Memoirs
volume: 3
page: 666-731
language: en-GB
---
```{r}
library(tinytable)
x <- data.frame(Thing = 1234, Citation = "@Lovelace1842")
tt(x) |> format_tt(quarto = TRUE)
``` Here's the error:
Though also, if there wasn't an error, the citation still wouldn't be processed and the |
Wait, the issue might be here: Line 410 in 0a999dd
I might be reading the code wrong here and it might already be doing it elsewhere in that file, but the content inside base64enc::base64encode(charToRaw("@Lovelace1842"))
#> QExvdmVsYWNlMTg0Mg== If you put the citation key in the data.frame as the base64-encoded version, it will render to PDF just fine:
Here's the PDF—the |
I can replicate this! |
Aaah thanks so much for the deep dive! I was convinced this worked on my computer but it doesn't. (Was on the move without computer; sorry!) I just pushed a new commit on Github which should at least give us compilation, as shown in Andrew's last post. Thanks both! |
Thank you both! One step closer!... :-) |
Oh awesome! I just looking for a base R, no-external-packages method for base64-encoding to eliminate dependencies, but there isn't one. Everyone seems to use one of these:
I was this close to looking up the algorithm and trying to figure it out for a custom function here, but you just added |
Oh yeah, adding an option package by Simon Urbanek feels like we're maintaining the spirit of the project 😂 |
When using Markdown inside tables with Quarto, Quarto ignores the content and will not parse it. That's ordinarily okay—using
format_tt(..., markdown = TRUE)
will format most things just fine.It gets tricky with syntax that Quarto should parse, like cross references and citations. For instance, take this:
It emits this HTML:
The @Lovelace1842 citation key isn't parsed and appears in the table:
Quarto has the ability to treat specific text as Markdown, though, if you wrap it in an element with a
data-qmd
attribute set. Atd
element containing this should render as an actual citation:This is an issue with all table-making packages (see here for a discussion about it at Quarto quarto-dev/quarto-cli#3340). {gt} has it fixed and there's an open issue at {knitr} for it, with more details too: yihui/knitr#2289
I don't know the best way to handle this with {tinytable} though.
format_tt(..., markdown = TRUE)
uses the {markdown} package to convert to HTML rather than Quarto, and that's great.One additional complication is that this also doesn't work in LaTeX, and neither does {gt}, but
knitr::kable()
does somehow (see quarto-dev/quarto-cli#3340 (comment)).The text was updated successfully, but these errors were encountered: