Hacktoberfest 2026: die Issues, die Maintainer für den Oktober markiert haben – offen und einsteigerfreundlich. Hacktoberfest-Issues durchsuchen

DecoratedCodeBlock has no docx/pptx renderer — code chunk `filename` header silently dropped

Offen
#14,906 1 Kommentar 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Maintainer antworten meist innerhalb von 1 Tag

Dieses Issue hat noch niemand übernommen.

Bewertung

Schwierigkeit
3/5
Geschätzter Aufwand
1-2 Tage
Anfängerfreundlichkeit
72/100
Issue-Typ
Bug
Klarheit
Größtenteils klar
Aktivitätsstatus
Aktiv
Tech-Stack
lua
Bereich
cli, tooling

Rechercherichtung

Start with src/resources/filters/customnodes/decoratedcodeblock.lua and compare the existing HTML and LaTeX renderers with the fallback path. Render the provided repro with --to docx and --to pptx, then verify that a visible filename representation appears before the code block while HTML and LaTeX behavior remains unchanged.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Beschreibung

code-blocks enhancement

Summary

A code block decorated with a filename (e.g. {r filename="hello.R"} or a .filename attribute) renders correctly in HTML, LaTeX, and Markdown output, but the filename header is silently dropped for docx and pptx (and any other format with no dedicated renderer registered).

Where the gap is

src/resources/filters/customnodes/decoratedcodeblock.lua registers exactly four renderers for the DecoratedCodeBlock custom AST node:

  1. A default/fallback renderer (predicate always true) — walks the code block for folding only:
    _quarto.ast.add_renderer("DecoratedCodeBlock",
      function(_) return true end,
      function(node)
        return _quarto.ast.walk(node.code_block, { CodeBlock = render_folded_block })
      end)
    
  2. A markdown renderer (_quarto.format.isMarkdownOutput())
  3. A latex renderer (_quarto.format.isLatexOutput())
  4. An html renderer (_quarto.format.isHtmlOutput())

Only the html and latex renderers actually read node.filename and render a header for it. Since docx/pptx match none of the three specific predicates, they fall through to the default renderer, which never reads node.filename (or node.caption) at all — it only walks for render_folded_block (itself a no-op for non-HTML output). The result: the code block content survives, but the filename header silently disappears, with no warning.

Repro

---
title: repro
---

```{.python filename="hello.py"}
print("hello")

Render with `quarto render repro.qmd --to docx` (or `--to pptx`). The code block appears; the "hello.py" filename header does not. Compare with `--to html` or `--to latex`, both of which show it.

## Suggested fix

Add a docx/pptx-aware renderer for `DecoratedCodeBlock` (or extend the default renderer to check `_quarto.format.isDocxOutput()`/`isPowerPointOutput()`) that emits *some* visible representation of `node.filename` — e.g. a bold paragraph immediately before the code block, mirroring the semantic intent of the html wrapper (`code-with-filename`) and the latex `\caption`, adapted to what Pandoc's docx/pptx writers can represent natively (Word/PowerPoint have no custom CSS to hook into, so this would need to be a plain paragraph/text run rather than a styled wrapper).

## Context

Found while auditing `decoratedcodeblock.lua`'s renderer coverage against Pandoc's non-core output targets (docx/pptx) for a project that reuses these filters. Confirmed against a fresh clone at `v1.11.3` (and current `main`, `83d48d8e8` — the file is unchanged between the two).
Vorherrschende Sprache
JavaScript
Sterne
6.1k
Forks
466
Ø Merge
21 Std. 36 Min.
Gemergte PRs (30 T.)
79

Entwicklungsumgebung

Erste Schritte

  1. Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
  3. Forken Sie das Repository und arbeiten Sie in einem Branch.
  4. Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.

Mehr aus quarto-dev/quarto-cli

Alle Issues in quarto-dev/quarto-cli

Ähnliche Issues

Weitere Issues zu JavaScript

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.