posit-dev / posit-dev/quarto-openapi

CSS not applied: contributes.format.html.css ignored for plain html format

Open
#13 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
3
Forks
1
Avg merge
11d 5h
Merged PRs (30d)
3

Description

Problem

The extension's contributes.format.html.css in _extension.yml is silently ignored. The quarto-openapi-table divs are generated correctly by the pre-render script, but the styles from quarto-openapi-styles.css (including overflow-x: auto) are never included in the rendered output.

This affects the bundled example project as well — even with no explicit css field in _quarto.yml, the extension's CSS is not applied.

Root cause

Quarto handles contributes.metadata and contributes.format through different code paths:

  • contributes.metadata is merged globally for all installed extensions via mergeExtensionMetadata() in project-context.ts. This is why the pre-render script works.
  • contributes.format is only applied via readExtensionFormat() in render-contexts.ts, which is gated on the document's format explicitly naming the extension (e.g., format: quarto-openapi-html). For plain format: html, the extension's format contributions are never read.

Since no document ever declares format: quarto-openapi-html, the contributes.format.html.css block in _extension.yml is effectively dead code — regardless of whether the consuming project has its own CSS or not.

Suggested fix

Replace the contributes.format CSS declaration with a Lua filter that injects the stylesheet via quarto.doc.add_html_dependency(), which operates at render time and is always applied.

1. Add a Lua filter (e.g., style-inject.lua):

function Meta(meta)
  quarto.doc.add_html_dependency({
    name = "quarto-openapi-styles",
    version = "0.2.0",
    stylesheets = { "quarto-openapi-styles.css" }
  })
end

2. Update _extension.yml:

title: quarto-openapi
author: Posit Software, PBC
version: 0.2.1
quarto-required: ">=1.6.0"
contributes:
  metadata:
    project:
      pre-render:
        - _extensions/posit-dev/quarto-openapi/openapi-to-markdown.ts
  filters:
    - style-inject.lua

Remove the format block — the Lua filter handles CSS injection now.

Workaround

Until this is fixed, consuming projects can manually include the extension's CSS in their _quarto.yml:

format:
  html:
    css:
      - _extensions/posit-dev/quarto-openapi/quarto-openapi-styles.css

Contributor guide

No contributing guide indexed for this repository

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

Inspect _extension.yml, the existing openapi-to-markdown.ts pre-render entry, and quarto-openapi-styles.css first. Render the bundled example project with plain HTML to confirm the current omission, then verify that the stylesheet is included without a consuming project's explicit CSS configuration.

Written by the indexing model from the issue text.

Assessment

Tech stack
css, lua, typescript, yaml
Domain
documentation
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Clearly specified
Newbie friendliness
68/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.