quarto-dev / quarto-dev/quarto-cli
include-before-body does not preserve key order when using both text and file
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 6k
- Forks
- 458
- Avg merge
- 1d 9h
- Merged PRs (30d)
- 41
Description
Bug description
include-before-body does not preserve order of keys when both text and file keys are used. Similarly unexpected behavior occurs with include-after-body and include-in-header as well.
Steps to reproduce
example.qmd
---
include-before-body:
- text: a man
- file: _aplan.md
- text: a canal panama
format:
html: default
pdf: default
---
> The above text should read "a man a plan a canal panama", but the order of the `include-before-body` keys is not preserved.
_aplan.md
a plan
Expected behavior
I expect the order of include keys to be preserved so that the output would read
a man a plan a canal panama
Actual behavior
It appears that the keys are sorted before inclusion, so that file contents are included before text contents. I would expect that the order of keys is preserved for includes. This results in the out of order output:
a plan a man a canal panama
Your environment
- OS: macOS Sonoma 14.2.1
Quarto check output
[✓] Checking versions of quarto binary dependencies...
Pandoc version 3.1.1: OK
Dart Sass version 1.55.0: OK
[✓] Checking versions of quarto dependencies......OK
[✓] Checking Quarto installation......OK
Version: 1.3.450
Path: /Applications/quarto/bin
[✓] Checking basic markdown render....OK
[✓] Checking Python 3 installation....OK
Version: 3.11.6
Path: /opt/homebrew/opt/python@3.11/bin/python3.11
Jupyter: 5.3.0
Kernels: python3
(/) Checking Jupyter engine render....0.00s - Debugger warning: It seems that frozen modules are being used, which may
0.00s - make the debugger miss breakpoints. Please pass -Xfrozen_modules=off
0.00s - to python to disable frozen modules.
0.00s - Note: Debugging will proceed. Set PYDEVD_DISABLE_FILE_VALIDATION=1 to disable this validation.
0.00s - Debugger warning: It seems that frozen modules are being used, which may
0.00s - make the debugger miss breakpoints. Please pass -Xfrozen_modules=off
0.00s - to python to disable frozen modules.
0.00s - Note: Debugging will proceed. Set PYDEVD_DISABLE_FILE_VALIDATION=1 to disable this validation.
[✓] Checking Jupyter engine render....OK
[✓] Checking R installation...........OK
Version: 4.3.2
Path: /Library/Frameworks/R.framework/Resources
LibPaths:
- /Library/Frameworks/R.framework/Versions/4.3-arm64/Resources/library
knitr: 1.44
rmarkdown: 2.25
[✓] Checking Knitr engine render......OK
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 behavior with example.qmd and _aplan.md, checking include-before-body first and then the analogous include-after-body and include-in-header cases. Trace the include handling from the CLI entry point, and consider the work complete when mixed text and file entries retain their declared order in the rendered output.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- cli
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100