`include-before-body` and `include-after-body` have no effect for docx output

オープン
#15,403 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
3/5
見積もり時間
1〜2日
初心者へのやさしさ
58/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
javascript, lua
領域
backend

調査の方向性

Start with src/resources/filters/quarto-init/includes.lua and src/resources/filters/common/meta.lua, which the issue links to, and trace how include content becomes a raw block for docx. Check the existing tests for docx includes, then reproduce with the provided before.xml and after.xml example. Done means both markers appear in word/document.xml for include-before-body and include-after-body.

索引モデルが issue の本文から書いたものです。

説明

bug docx

I have:

  • searched the issue tracker for similar issues
  • installed the latest version of Quarto CLI
  • formatted my issue following the Bug Reports guide

Bug description

Since Pandoc 3.2.1, --include-before-body and --include-after-body work with docx: the files are OpenXML fragments inserted in the document body. With Quarto, their content never reaches word/document.xml. The same happens with text in include-before and include-after.

Quarto reads include files in a Lua filter and adds their content to the metadata as a raw block, with FORMAT as the raw format:

https://github.com/quarto-dev/quarto-cli/blob/cda41021442b20964e10e265b9dcdf81f490c18e/src/resources/filters/quarto-init/includes.lua#L44-L61

https://github.com/quarto-dev/quarto-cli/blob/cda41021442b20964e10e265b9dcdf81f490c18e/src/resources/filters/common/meta.lua#L32-L40

For docx, FORMAT is docx, so the raw block is RawBlock("docx", ...). Pandoc's docx writer only keeps raw openxml and drops the rest. A markdown document with both a ```{=docx} and a ```{=openxml} block shows it: only the openxml one is in the output.

Steps to reproduce

before.xml:

<w:p><w:r><w:t>MARKER-BEFORE</w:t></w:r></w:p>

after.xml:

<w:p><w:r><w:t>MARKER-AFTER</w:t></w:r></w:p>

doc.qmd:

---
title: Hello
format:
  docx:
    include-before-body: before.xml
    include-after-body: after.xml
---

Body text.
quarto render doc.qmd
unzip -p doc.docx word/document.xml | grep -o 'MARKER-[A-Z]*'

Actual behavior

No output: neither paragraph is in word/document.xml. Same with include-before: '<w:p>...</w:p>' and include-after: in YAML.

Expected behavior

Both paragraphs are in the document, like with Pandoc directly:

quarto pandoc -f markdown -t docx --include-before-body before.xml --include-after-body after.xml -o p.docx doc.qmd
unzip -p p.docx word/document.xml | grep -o 'MARKER-[A-Z]*'
# MARKER-BEFORE
# MARKER-AFTER

A post-render Lua filter that changes the format of these raw blocks in include-before to openxml makes the paragraph appear, and the result opens in Word. We could use openxml as the raw format for docx when adding includes.

Your environment

  • OS: Windows 11
  • Same result with Quarto 1.11.9, 1.12.3, and main at cda4102 (Pandoc 3.13). Not a regression as far as I can tell.

Related: #15399

主要言語
JavaScript
スター
6.2k
フォーク
492
平均マージ
15時間 15分
マージ済み PR(30日)
94

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

quarto-dev/quarto-cli のほかの issue

quarto-dev/quarto-cli の issue をすべて見る

似ている issue

JavaScript の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。