quarto-dev / quarto-cli

Open-source scientific and technical publishing system built on Pandoc.
https://quarto.org
Other
3.75k stars 306 forks source link

`revealjs-url` path is resolved relative to the `quarto render` command, not the project being rendered #10444

Open gadenbuie opened 1 month ago

gadenbuie commented 1 month ago

Bug description

When revealjs-url is used, the path is not relative to the document in which the key appears, but rather the working directory where quarto render or quarto preview are called. I believe the path to revealjs-url should be relative to the source document and should be resolved as part of the metadata resolution.

Steps to reproduce

quarto create project website reprex --no-prompt --no-open
cd reprex

mkdir slides
cd slides

# Checkout a version of revealjs
gh repo clone hakimel/reveal.js revealjs-4.5.0
cd revealjs-4.5.0
git checkout 4.5.0
cd ..

# Write slide content
cat <<EOF > slides.qmd
---
format:
  revealjs:
    revealjs-url: revealjs-4.5.0
---
EOF

Note the relative path in revealjs-url. Calling quarto render slide.qmd from inside slides/ works, but if you move up one directory, the website fails to render.

quarto render slides.qmd

cd ..
quarto render
[1/5] index.qmd
[2/5] slides/slides.qmd
ERROR: WalkError: No such file or directory (os error 2): readdir 'revealjs-4.5.0/dist' for path "revealjs-4.5.0/dist"

If you make revealjs-url relative to the website root, it will work for a bit. But if you happen to have your website inside a folder in your repo, e.g. website/, then quarto render website will fail (this is effectively what's called by the quarto-actions/publish action).

Expected behavior

revealjs-url should be relative to the place where it's defined, and should not change when quarto render is called from a different directory.

Actual behavior

quarto render works from some directories and fails from others.

Your environment

Default quarto-actions/publish action (same version of quarto as reported below). Also locally on MacOS 14.5

Quarto check output

Quarto 1.5.55
[✓] Checking versions of quarto binary dependencies...
      Pandoc version 3.2.0: OK
      Dart Sass version 1.70.0: OK
      Deno version 1.41.0: OK
      Typst version 0.11.0: OK
[✓] Checking versions of quarto dependencies......OK
[✓] Checking Quarto installation......OK
      Version: 1.5.55
      Path: /Applications/quarto/bin

[✓] Checking tools....................OK
      TinyTeX: (external install)
      Chromium: (not installed)

[✓] Checking LaTeX....................OK
      Using: TinyTex
      Path: /Users/garrick/Library/TinyTeX/bin/universal-darwin
      Version: 2022

[✓] Checking basic markdown render....OK

[✓] Checking Python 3 installation....OK
      Version: 3.12.2
      Path: /Users/garrick/.rye/py/cpython@3.12.2/bin/python3
      Jupyter: (None)

      Jupyter is not available in this Python installation.
      Install with python3 -m pip install jupyter

[✓] Checking R installation...........OK
      Version: 4.4.1
      Path: /Library/Frameworks/R.framework/Versions/4.4-arm64/Resources
      LibPaths:
        - /Users/garrick/Library/R/arm64/4.4/library
        - /Library/Frameworks/R.framework/Versions/4.4-arm64/Resources/library
      knitr: 1.48
      rmarkdown: 2.27

[✓] Checking Knitr engine render......OK
mcanouil commented 1 month ago

You mean revealjs-url? not remarkjs-url? (Remark.js is not supported)

gadenbuie commented 1 month ago

You mean revealjs-url? not remarkjs-url? (Remark.js is not supported)

Yeah and apparently I remembered the right one somewhere around halfway through writing up the issue.

cderv commented 2 weeks ago

For context on this one, my understanding is that we are copying the folder and then passing the final path as value directly to Pandoc's own variable for this https://pandoc.org/MANUAL.html#variables-for-html-slides

https://github.com/quarto-dev/quarto-cli/blob/814604696f1a36c4351245100f72c7fb75fba5eb/src/format/reveal/format-reveal-theme.ts#L73-L99

then it is used in HTML template as is https://github.com/quarto-dev/quarto-cli/blob/814604696f1a36c4351245100f72c7fb75fba5eb/src/resources/formats/revealjs/pandoc/revealjs.template#L19-L20

The problem here happens for the copy of the provided folder. Here is the stack trace

Stack trace:
    at wrapErrorWithPath (file:///C:/Users/chris/Documents/DEV_R/quarto-cli/src/vendor/deno.land/std@0.217.0/fs/walk.ts:50:10)
    at walkSync (file:///C:/Users/chris/Documents/DEV_R/quarto-cli/src/vendor/deno.land/std@0.217.0/fs/walk.ts:219:11)
    at walkSync.next (<anonymous>)
    at copyMinimal (file:///C:/Users/chris/Documents/DEV_R/quarto-cli/src/core/copy.ts:70:11)
    at file:///C:/Users/chris/Documents/DEV_R/quarto-cli/src/format/reveal/format-reveal-theme.ts:98:5
    at Array.forEach (<anonymous>)
    at revealTheme (file:///C:/Users/chris/Documents/DEV_R/quarto-cli/src/format/reveal/format-reveal-theme.ts:97:22)
    at Object.formatExtras (file:///C:/Users/chris/Documents/DEV_R/quarto-cli/src/format/reveal/format-reveal.ts:153:29)
    at runPandoc (file:///C:/Users/chris/Documents/DEV_R/quarto-cli/src/command/render/pandoc.ts:393:31)
    at eventLoopTick (ext:core/01_core.js:153:7)

I guess in project context, it was designed to use a folder at project root to use for all presentation. Or it may not even work at all for a project setting

Possibly, just using absolute path before doing the copy could solve this.