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
{{ message }}
Repository navigation
render-time section name given partial anchor #8546
When a section name is partially defined by a shortcode (env, for example) that dynamic portion of the name is not included in the anchor for that section.
Steps to reproduce
---title: anchorsformat:
html:
toc: true---## version {{< env VERSION >}}
section something
## version 2023.12.0
section 2023.12.0
Render like:
VERSION=2024.01.0 quarto render
Expected behavior
The document contains #version-2024.01.0 and version-2023.12.0 anchors.
Actual behavior
The document contains #version and version-2023.12.0 anchors.
Your environment
No response
Quarto check output
Quarto 1.4.549
[✓] 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.549
Path: /Applications/quarto/bin
[✓] Checking tools....................OK
TinyTeX: (external install)
Chromium: (not installed)
[✓] Checking LaTeX....................OK
Using: TinyTex
Path: /Users/aron/Library/TinyTeX/bin/universal-darwin
Version: 2022
[✓] Checking basic markdown render....OK
[✓] Checking Python 3 installation....OK
Version: 3.11.7
Path: /usr/local/opt/[email protected]/bin/python3.11
Jupyter: (None)
Jupyter is not available in this Python installation.
Install with python3 -m pip install jupyter
[✓] Checking R installation...........OK
Version: 4.3.1
Path: /Library/Frameworks/R.framework/Resources
LibPaths:
- /Library/Frameworks/R.framework/Versions/4.3-x86_64/Resources/library
knitr: 1.45
rmarkdown: 2.25
[✓] Checking Knitr engine render......OK
@cscheid - no, the whitespace between < and env does not matter. That variation is in this example but wasn't in my original document. I'll correct the text in this issue to have whitespace so that's not questioned.
This is more than a shortcode issue. We don't update the section heading identifiers if their content changes in a filter (which is the case with shortcode evaluation)
Heading identifiers are used to create crossref indices, so we need to be careful about which parts of our filter pipeline expect identifiers to be stable. We also need to be sure that we're using precisely the same algorithm that Pandoc uses to generate the ids, since this risks regressing on IDs of every website out there.
I'm inclined to say we're not going to consider this a bug, and recommend you set those identifiers yourself unless there's a very compelling reason to do it.
@cscheid - Do you have a recommended way to use an environment variable value within a section heading and its anchor without dropping to R/Python?
We use this approach when generating a release-notes page; the "current" version is generated dynamically and injected by the build script into the environment provided to Quarto.
If you don't see a straightforward path, we'll have to shift back to static identifiers. Not a terrible change, but would require some adjustment to our tooling.
Do you have a recommended way to use an environment variable value within a section heading and its anchor without dropping to R/Python?
I'd consider a Lua filter. Unfortunately, we don't have a great Lua filter entry point that targets precisely what you need.
A Lua filter that's declared at: pre-quarto would see the heading content (and identifiers) before shortcodes are resolved. Here, you can change the identifier without risking crossref issues, but you don't see the shortcode resolution.
A Lua filter that's declared at: post-quarto would see the heading content (and identifiers) after shortcodes are resolved. Here, you see the shortcode resolution but if you change the identifier, then crossref entries might be corrupted.
Activity
aronatkins commentedon Feb 1, 2024
Attempting to use
{# ... }is not successful.## version {{< env VERSION >}} {#version-{{< env VERSION >}}}This misses the
{# ...}and produces HTML with the anchor#version-version-:aronatkins commentedon Feb 1, 2024
@cscheid - no, the whitespace between
<andenvdoes not matter. That variation is in this example but wasn't in my original document. I'll correct the text in this issue to have whitespace so that's not questioned.cscheid commentedon Feb 1, 2024
This is more than a shortcode issue. We don't update the section heading identifiers if their content changes in a filter (which is the case with shortcode evaluation)
cscheid commentedon Feb 1, 2024
consider:
This gives
I'm not sure if it's enough to change the heading identifier in a filter.
cscheid commentedon Feb 1, 2024
Yeah, this is tricky.
Heading identifiers are used to create crossref indices, so we need to be careful about which parts of our filter pipeline expect identifiers to be stable. We also need to be sure that we're using precisely the same algorithm that Pandoc uses to generate the ids, since this risks regressing on IDs of every website out there.
I'm inclined to say we're not going to consider this a bug, and recommend you set those identifiers yourself unless there's a very compelling reason to do it.
aronatkins commentedon Feb 2, 2024
@cscheid - Do you have a recommended way to use an environment variable value within a section heading and its anchor without dropping to R/Python?
We use this approach when generating a release-notes page; the "current" version is generated dynamically and injected by the build script into the environment provided to Quarto.
If you don't see a straightforward path, we'll have to shift back to static identifiers. Not a terrible change, but would require some adjustment to our tooling.
cscheid commentedon Feb 2, 2024
I'd consider a Lua filter. Unfortunately, we don't have a great Lua filter entry point that targets precisely what you need.
A Lua filter that's declared
at: pre-quartowould see the heading content (and identifiers) before shortcodes are resolved. Here, you can change the identifier without risking crossref issues, but you don't see the shortcode resolution.A Lua filter that's declared
at: post-quartowould see the heading content (and identifiers) after shortcodes are resolved. Here, you see the shortcode resolution but if you change the identifier, then crossref entries might be corrupted.