How to append content of a .qmd file to the one currently rendered using a lua fragment? #6025
-
DescriptionHi, Currently, the script looks like this: -- End slide content
local end_slide = io.open("ending.qmd", "r")
local end_content = end_slide:read("*all")
end_slide:close()
-- Append to the rest of the slides
local main_slides = io.open("template.qmd", "a")
main_slides:write(end_content)
main_slides:close() Is there a way to refer to the currently rendered file, instead of hardcoding its name into the script (e.g. "template.qmd")? Ideally, I would like to call the lua script as a fragment in the YAML. Thanks a lot! |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 10 replies
-
I'm not sure this is the right approach: Lua filters are called relatively late in the rendering process, after Quarto has already processed the qmd files and pandoc has parsed the results into an abstract syntax tree. (Pandoc Lua readers act earlier than that, but I doubt they're relevant here). So in that sense, it seems too late to include a qmd file at this stage. It sounds like you could use quarto includes instead? Or perhaps adjust the document template, if using latex/html/typst/etc formats. |
Beta Was this translation helpful? Give feedback.
-
You could also consider Quarto Project, and using a pre-render script (About Project Script. You could add your content using a script to all the other .qmd that requires it before Quarto does its processing
Using Using Lua, you could just consider the
If the aim is to add some content after body, then using the Pandoc includes features is probably easier than modifying template Hope it helps |
Beta Was this translation helpful? Give feedback.
-
Hi there, I made a filter called append-qmd that I believe does what you're after. Simply acquire that repository and add your contact info to a Also, pandoc has a filter called include-files that is a little more flexible but is less automated. You have to write a code block with class |
Beta Was this translation helpful? Give feedback.
-
@clroberts-adfg This is pretty much exactly what I was after. Thanks a lot! |
Beta Was this translation helpful? Give feedback.
Hi there,
I made a filter called append-qmd that I believe does what you're after. Simply acquire that repository and add your contact info to a
.qmd
file; place it in the same directory as the.lua
script.Also, pandoc has a filter called include-files that is a little more flexible but is less automated. You have to write a code block with class
.include
in the body of your main document to prompt inclusion of external markdown files .