quarto-dev / quarto-dev/quarto-cli

[FR] include script in header could do clever insertion based on extension

Open
#10,656 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement html
Dominant language
JavaScript
Stars
6k
Forks
458
Avg merge
1d 9h
Merged PRs (30d)
41

Description

Discussed with @andrewpbray in context of

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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.