THE GITHTML FIELD GUIDE

Review a Pandoc filter before running a documentation conversion

Treat a Pandoc filter as a program that runs during conversion, not as harmless formatting data. Review its source and dependencies before executing it, use a suitable isolated test environment, and compare a baseline export. A filter can change document meaning as well as appearance, so verify what it removes, adds, and rewrites.

Identify why the filter is needed

Write down the transformation the document requires: perhaps replacing a custom marker or adding a verified metadata field. Check whether an ordinary converter option already solves the problem. A filter that implements a small necessary transformation is easier to review than a large collection of unrelated helpers. Identify whether the project uses an external executable or a Lua filter and record where its source comes from. Do not run an unknown downloaded filter against a sensitive repository simply because the input looks like a document. Review dependency installation and execution as part of the same trust decision.

Compare a baseline with one controlled transformation

Build a small fixture containing ordinary prose, code, links, and the construct the filter should modify. Convert it once without the filter and once with the reviewed filter, using distinct output paths. Keep the test input free of secrets and avoid production credentials in the environment. Inspect the program for file access, network requests, process execution, and output changes relevant to your setup. The commands below are an illustrative comparison and assume the named filter has already been reviewed. Do not infer safety merely from its filename or from the fact that it is written in Lua.

sh
pandoc fixture.md --standalone --output=baseline.html
pandoc fixture.md --standalone --lua-filter=reviewed-filter.lua \
  --output=filtered.html

Check semantic changes and failure behavior

Compare the visible text, links, headings, and code examples between baseline and filtered output. Confirm that unrelated content remains intact and that the intended transformation occurs exactly where expected. Add a malformed or missing marker case to the disposable fixture and observe whether the filter fails clearly or silently drops content. Record the filter version with the build instructions so another maintainer can reproduce the behavior. If the filter changes, rerun these checks before converting the full collection. A polished output page is not sufficient evidence: the most serious error may be a missing warning or altered literal example that no visual style makes obvious.

  1. Define the required transformation and inspect the filter's source and dependencies.
  2. Use non-sensitive fixtures in an appropriate test environment before touching real documents.
  3. Compare baseline and filtered output, including unrelated content and literal code.
  4. Test malformed input and record the reviewed filter version with the local build recipe.

Sources and further reading

AI-assisted writing with source-linked guidance and illustrative examples. Read our editorial approach or report a correction.

All documentation builds and formats guides →

Read as MarkdownAll guides

Review a Pandoc filter before running a documentation conversion · gitHtml