quarto-dev / quarto-cli

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

footer icons need HTML, which prevents extensions from resolving assets #9473

Open aronatkins opened 3 months ago

aronatkins commented 3 months ago

Bug description

An extension defining a custom project type wants to declare a shared footer and use some images as icons within that footer. For example:

website:
  page-footer:
    right:
      - text: "<img src='/images/posit-logo-black-TM.svg' id='footer-right-posit-logo'>"
        href: "https://posit.co"

If the page footer supported an image attribute and took an image path, the in-extension path could be resolved without resorting to HTML.

website:
  page-footer:
    right:
      - image: "/images/posit-logo-black-TM.svg"
        href: "https://posit.co"

My understanding is that Quarto does not attempt to resolve asset paths within text, but can do so for fields which are known to contain file references.

Steps to reproduce

No response

Expected behavior

No response

Actual behavior

No response

Your environment

No response

Quarto check output

Quarto 1.4.551
[✓] Checking versions of quarto binary dependencies...
      Pandoc version 3.1.11: OK
      Dart Sass version 1.69.5: OK
      Deno version 1.37.2: OK
[✓] Checking versions of quarto dependencies......OK
[✓] Checking Quarto installation......OK
      Version: 1.4.551
      Path: /Users/aron/quarto/quarto-1.4.551-macos/bin

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

[✓] Checking LaTeX....................OK
      Using: Installation From Path
      Path: /Library/TeX/texbin
      Version: 2024

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

[✓] Checking Python 3 installation....OK
      Version: 3.12.2
      Path: /opt/homebrew/opt/python@3.12/bin/python3.12
      Jupyter: (None)

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

[✓] Checking R installation...........OK
      Version: 4.3.3
      Path: /Library/Frameworks/R.framework/Resources
      LibPaths:
        - /Library/Frameworks/R.framework/Versions/4.3-arm64/Resources/library
      knitr: 1.45
      rmarkdown: 2.26

[✓] Checking Knitr engine render......OK
mcanouil commented 3 months ago

In the case of the addition of image, then image-alt and image-title should also be added. Possibly other attributes (image-width) as done for the about page template: https://github.com/mcanouil/quarto-cli/blob/31d5390770394d678b737bdc2d135f54f7eb9684/src/resources/projects/website/about/_image.ejs.html

mcanouil commented 3 months ago

FYI, markdown works in text (at least in 1.5).

  page-footer:
    right:
      - text: "![](/images/posit-logo-black-TM.svg){#footer-right-posit-logo width=100px}"
        href: "https://posit.co"

Although, Quarto will raise a warning:

WARNING (src/resources/filters/./quarto-pre/parsefiguredivs.lua:517) Figure with invalid crossref category: footer-right-posit-logo
Won't be able to cross-reference this figure.
cscheid commented 3 months ago

Although, Quarto will raise a warning

We're raising a warning because of the dashes being used here. (We've considered removing this warning because it causes too many false positives like that. I'll probably do it right now.)

aronatkins commented 3 months ago

@mcanouil - I cannot replicate your text example. When an extension declares page-footer with an image like your example, the resulting HTML contains paths which are relative to the extension directory and not resolved.

mcanouil commented 3 months ago

The example was mostly about the statement saying that HTML is required.

The main issue with assets inside extension is how to tell Quarto how to find them, both when creating an extension and using them. Currently, if you use some paths in a template.qmd at the root of your extension, the directory tree does not contains org/user account, while it will when quarto add/use. One way to "solve" this is format-resources (https://quarto.org/docs/journals/formats.html#format-resources). Unfortunately, it means to copy the assets from the extension into the main directory.

mcanouil commented 3 months ago

It would be nice if Quarto could look for resources inside extensions without having to set "_extensions/account/ext-name" (path if installed using quarto add) for all resources.

mcanouil commented 2 months ago

For reference: