You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This isn't a bug report or anything—just a note about how to use {rmdfiltr}'s word count with Quarto.
Quarto doesn't support inline R code in YAML (quarto-dev/quarto-cli#1391 (comment)), so adding !expr rmdfiltr::add_wordcount_filter() to the YAML in a .qmd file doesn't work. Additionally, there's no way to specify pandoc_args, so there's no straightforward way to make citeproc run before the wordcount filter.
Fortunately, this GitHub comment shows that it's possible to make a Lua filter that basically behaves like --citeproc by feeding the whole document to pandoc.utils.citeproc(). That means we can create a little Lua script like citeproc.lua:
-- Lua filter that behaves like `--citeproc`functionPandoc (doc)
returnpandoc.utils.citeproc(doc)
end
This creates a pandoc command that looks something like this, feeding the document to the citeproc "filter" first, then feeding that to the word count script:
There's still no way that I've found to dynamically generate /path/to/wordcount.lua like !expr rmdfiltr::add_wordcount_filter(), so users need to download the Lua file themselves and put it somewhere in their project.
The Lua files can also be included in a Quarto format extension like this so there's no need to manually deal with Lua files in the YAML. Instead, users can just specify a wordcount-enabled format:
title: Somethingformat:
wordcount-html: default
The text was updated successfully, but these errors were encountered:
This isn't a bug report or anything—just a note about how to use {rmdfiltr}'s word count with Quarto.
Quarto doesn't support inline R code in YAML (quarto-dev/quarto-cli#1391 (comment)), so adding
!expr rmdfiltr::add_wordcount_filter()
to the YAML in a .qmd file doesn't work. Additionally, there's no way to specifypandoc_args
, so there's no straightforward way to make citeproc run before the wordcount filter.Fortunately, this GitHub comment shows that it's possible to make a Lua filter that basically behaves like
--citeproc
by feeding the whole document topandoc.utils.citeproc()
. That means we can create a little Lua script likeciteproc.lua
:…and then include that as a filter:
This creates a pandoc command that looks something like this, feeding the document to the citeproc "filter" first, then feeding that to the word count script:
There's still no way that I've found to dynamically generate
/path/to/wordcount.lua
like!expr rmdfiltr::add_wordcount_filter()
, so users need to download the Lua file themselves and put it somewhere in their project.The Lua files can also be included in a Quarto format extension like this so there's no need to manually deal with Lua files in the YAML. Instead, users can just specify a wordcount-enabled format:
The text was updated successfully, but these errors were encountered: