quarto-dev / quarto-dev/quarto-cli
[FR] include script in header could do clever insertion based on extension
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 6k
- Forks
- 458
- Avg merge
- 1d 9h
- Merged PRs (30d)
- 41
Description
Discussed with @andrewpbray in context of
- https://github.com/quarto-dev/quarto-cli/discussions/10654 with @andrewpbray
As a user, it seems natural to do
format:
html:
include-in-header:
- file: mysidebar.js
to include a .js script in header of an HTML document
This won't work because file really expect only HTML content to be inserted directly. So a .html file content really.
In .pdf context, it would be .tex content, and in typst context a .typ file.
Maybe for HTML there is a way to be clever and write the HTML wrapping when .js or .css is detected as a file.
Regarding current situation, it says nothing, and does try to include the .js file content in the HTML document. Which creates an invalid HTML at the end, silently.
So we could also force .html extension check here when used format: html.
include-in-header can be technically as global option across format, but it seems format specific anyway, because raw content needs to be passed for the template.
Anyhow, registering the idea so that it is not lost in closed discussion.
Context of the discussion was Extension resource, and there is more to it than this option. Read the discussion for more.
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
Read the issue's include-in-header examples and the linked discussion, comparing the expected behavior for HTML, PDF, and Typst output. Define the format-specific handling or validation for file extensions, then verify that JavaScript input no longer silently produces invalid HTML and that existing raw-content behavior remains clear.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- tooling
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 28/100