quarto-dev / quarto-dev/quarto-cli
Quarto book does not run same working dir for HTML or PDF
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 6k
- Forks
- 458
- Avg merge
- 1d 9h
- Merged PRs (30d)
- 41
Description
- Create a project
quarto create project book test-quarto-book --no-prompt
- Tweak content
cd .\test-quarto-book\
mkdir chapters
mv intro.qmd .\chapters\
rm .\summary.qmd
rm .\references.qmd
- Modify config by adding a filter, and moving
intro.qmdintochapters
project:
type: book
book:
title: "Test-quarto-book"
author: "Norah Jones"
date: "11/03/2024"
chapters:
- index.qmd
- chapters/intro.qmd
bibliography: references.bib
format:
html:
theme: cosmo
pdf:
documentclass: scrreprt
filters:
- workdir.lua
- Add this Lua filter
Pandoc = function(doc)
quarto.log.output("LUA_WD: "..pandoc.system.get_working_directory())
end
Now see the difference of context
For HTML
> quarto render --to html
[1/2] index.qmd
LUA_WD: C:\Users\chris\AppData\Local\Temp\quarto\test-quarto-book
[2/2] chapters\intro.qmd
LUA_WD: C:\Users\chris\AppData\Local\Temp\quarto\test-quarto-book\chapters
Output created: _book\index.html
For PDF
> quarto render --to pdf
[1/2] index.qmd
[2/2] chapters\intro.qmd
pandoc
to: latex
output-file: index.tex
standalone: true
toc: true
number-sections: true
top-level-division: chapter
pdf-engine: xelatex
variables:
graphics: true
tables: true
default-image-extension: pdf
metadata
crossref:
chapters: true
documentclass: scrreprt
papersize: letter
classoption:
- DIV=11
- numbers=noendperiod
header-includes:
- '\KOMAoption{captions}{tableheading}'
block-headings: true
bibliography:
- references.bib
title: Test-quarto-book
author: Norah Jones
date: 11/03/2024
LUA_WD: C:\Users\chris\AppData\Local\Temp\quarto\test-quarto-book
Rendering PDF
running xelatex - 1
This is XeTeX, Version 3.141592653-2.6-0.999995 (TeX Live 2023) (preloaded format=xelatex)
restricted \write18 enabled.
entering extended mode
running xelatex - 2
This is XeTeX, Version 3.141592653-2.6-0.999995 (TeX Live 2023) (preloaded format=xelatex)
restricted \write18 enabled.
entering extended mode
Output created: _book\Test-quarto-book.pdf
You can see for PDF we use the Lua filters only once and not twice, with only the project root as workdir.
What is the impact ?
I believe this causes issues with extensions filter like
Do
quarto add quarto-ext/include-code-files --no-prompt
Add configuration to _config.yml
filters:
- include-code-files
and create chapters/test.c
/* test*/
void setup(){
}
void loop(){
}
and add into chapters/intro.qmd
```{.c include='test.c'}
```
Now quarto render --to html works because test.c is resolved according to .qmd working dir but quarto render --to pdf does not work and shows this log
Cannot open file test.c | Skipping includes
This is because Lua will resolve test.c based on project directory this time.
To confirm this, add these lines in the extension file
--- Filter function for code blocks
local function transclude (cb)
if cb.attributes.include then
local content = ""
quarto.log.output("LUA_DIR: "..pandoc.system.get_working_directory())
local fh = io.open(cb.attributes.include)
We know see this:
LUA_DIR: C:\Users\chris\AppData\Local\Temp\quarto\test-quarto-book
Cannot open file test.c | Skipping includes
So it means depending on the format used, the path resolution in Quarto Lua will be different.
- Either this is a bug and behavior should not be different,
- Or we should provide helper to use in Lua so that path are resolved correctly.
For example if include= was always relative to root project
```{.c include='chapters/test.c'}
```
and in Lua using quarto.project.directory
local fh = io.open(pandoc.path.join({quarto.project.directory, cb.attributes.include}))
This would make it work for HTML and PDF with same syntax.
Status on this
Anyhow, this is for illustration. There is a difference in Lua processing for Book chapters between HTML and PDF. If this is a limitation because of a requirement for Book rendering, we should find a way to provide the right tools in Quarto Lua API.
Or maybe this is just a matter of updating the include-code-files extension for this logic - but it seems it could be more than that to me...
Opening for discussion and future reference
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the difference with the book configuration, workdir.lua, chapters/intro.qmd, and the include-code-files example using chapters/test.c. Compare the HTML and PDF logs, especially pandoc.system.get_working_directory(), then inspect the Lua filter and extension file to identify the rendering-path boundary. Done should mean the issue’s intended path-resolution behavior is established and implemented or documented consistently for both formats.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- lua
- Domain
- build-system, tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100