Skip to content

Optionally abort on any Pandoc [WARNING] (#2638) - #2640

Merged
yihui merged 7 commits into
mainfrom
pandoc-warn-deprecated-args
Sep 9, 2026
Merged

yihui merged 7 commits into
mainfrom
pandoc-warn-deprecated-args

Conversation

@yihui

@yihui yihui commented Sep 7, 2026

Copy link
Copy Markdown
Collaborator

Follow-up to #2639, split out because it needs to be opt-in.

Motivation

Pandoc prints [WARNING] <message> on stderr for non-fatal issues — deprecated command-line arguments (#2638), missing references, etc. These only warn, they don't fail the conversion, so they slip past our daily nightly-Pandoc CI job unnoticed (a deprecated argument, for instance, stays silent until Pandoc eventually removes it).

Approach

When RMARKDOWN_PANDOC_ERROR_ON_WARNING is set to a truthy value, pandoc_convert() (and hence render()) captures Pandoc's stderr, relays it, and turns any [WARNING] line into an error. This catches any Pandoc warning generically — not only deprecations, and with no per-message enumeration.

Design notes:

  • Opt-in via env var. Capturing stderr changes how Pandoc's output is relayed to the user, so it is off by default. The var is enabled only in check-pandoc-daily.yaml, so the nightly job flags Pandoc warnings in advance.

yihui and others added 3 commits September 7, 2026 16:02
Pandoc prints "[WARNING] Deprecated: <arg>. ..." on stderr for deprecated
command-line arguments, but such arguments only warn -- they do not fail the
conversion -- so they slip past our daily nightly-Pandoc CI job unnoticed
until Pandoc eventually removes the argument (e.g. --mathjax deprecated in
Pandoc 3.11).

When the RMARKDOWN_PANDOC_WARN_DEPRECATED environment variable is set to a
truthy value, pandoc_convert() now captures Pandoc's stderr (via system2(),
which handles this portably, unlike a shell "2>" redirect that broke on
Windows), relays it to the user, and turns any "Deprecated:" line into an R
warning. This catches deprecations generically, without enumerating the
deprecated arguments one by one.

The behaviour is opt-in because capturing stderr changes how Pandoc's output
is relayed; the flag is enabled in the check-pandoc-daily workflow so the
nightly job flags deprecated arguments in advance.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Broaden the opt-in stderr check to relay every "[WARNING] ..." line Pandoc
prints (deprecated arguments, missing references, etc.) as an R warning,
rather than matching only "Deprecated:". This way the nightly-Pandoc CI job
fails on any Pandoc warning, not just deprecations.

The environment variable is renamed RMARKDOWN_PANDOC_WARN_DEPRECATED ->
RMARKDOWN_PANDOC_WARN accordingly.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@yihui yihui changed the title Optionally warn on any deprecated Pandoc argument (#2638) Optionally warn on any Pandoc [WARNING] (#2638) Sep 9, 2026
yihui and others added 3 commits September 8, 2026 21:34
…ontext()

The integration test used --citeproc to provoke a Pandoc [WARNING], but that
option requires Pandoc >= 2.11 and errors out on Pandoc 2.8. Use duplicate
header identifiers instead, which emit a [WARNING] on all supported Pandoc
versions without failing the conversion.

Also remove the testthat::context() calls, deprecated in the 3rd edition,
which emitted "context() was deprecated" warnings during R CMD check.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Pandoc silently de-duplicates auto-generated header identifiers, so two
headers with the same text did not emit any [WARNING] and the expect_warning()
check failed on every Pandoc version. Give both headers the same *explicit*
identifier ({#dup}), which Pandoc reports as "Duplicate identifier" without
failing the conversion.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
When RMARKDOWN_PANDOC_ERROR_ON_WARNING is set, pandoc_convert() captures
Pandoc's stderr and stop()s on any "[WARNING] ..." message. The nightly-Pandoc
workflow sets it so a new deprecation or other Pandoc warning fails the job.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@yihui
yihui force-pushed the pandoc-warn-deprecated-args branch from a320c30 to 6452a85 Compare September 9, 2026 02:31
@yihui yihui changed the title Optionally warn on any Pandoc [WARNING] (#2638) Optionally abort on any Pandoc [WARNING] (#2638) Sep 9, 2026
@yihui
yihui merged commit ea64bc4 into main Sep 9, 2026
@yihui
yihui deleted the pandoc-warn-deprecated-args branch September 9, 2026 02:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant