Skip to content

Docu: cleanUpMarkdown.sh turned closing code fences into opening ones - #370

Open
tombouctou wants to merge 1 commit into
FeynCalc:masterfrom
tombouctou:fix-closing-fences
Open

tombouctou wants to merge 1 commit into
FeynCalc:masterfrom
tombouctou:fix-closing-fences

Conversation

@tombouctou

Copy link
Copy Markdown

Documentation/Scripts/cleanUpMarkdown.sh labels code cells as Mathematica with

sed -z -i -e 's|\n\n```\n|\n\n```mathematica\n|g' $1;

The pattern is meant for opening fences, but it also matches a closing fence that follows an empty line, i.e. a cell whose last line is blank. Such a cell is then "closed" by ````mathematica`, which opens a new block instead. pandoc renders the cell as a paragraph of raw text (see the bottom of QED/TwoLoops/Renormalization-LeAle: "```mathematica FCCompareResults[leptonSE$RenConstants2L, …"), or, in TID and UnDeclareNonCommutative, pulls the output that follows into the code block.

Changes

  • cleanUpMarkdown.sh: the sed -z rule is replaced by an awk pass that tracks whether it is inside a cell and labels only opening fences. As before, it does so only for a bare ````` after an empty line. Closing fences are left alone.
  • 56 Markdown files already affected (14 in Documentation/Markdown, 42 examples) get their closing fence back: inside a cell, a ````mathematica` line becomes `````. Nothing else in them changes; each file has a one-line diff.

Verification

  • The repair is idempotent over the whole tree: running it again changes nothing.
  • pandoc renders none of the 56 files with a stray `````.
  • The rendered code-block count goes up by exactly one where a cell had been swallowed, e.g. TID, LeAle, Renormalization2, UnDeclareNonCommutative.
  • The new rule was tested on a small file with a cell ending in a blank line, a labelled opening fence, an unlabelled opening fence after text, and an unlabelled opening fence after an empty line.
  • Rendering LeAle through generateHTML.sh's pandoc command (template + md2html.lua) gives a proper code block where the website currently shows raw text.

The same fix for hotfix-stable (54 files there) is a separate PR, so the stable manual can be regenerated too.

The website side, where the already generated HTML of 76 pages is fixed, is FeynCalc/feyncalc.github.io#28.

🤖 Generated with Claude Code

…ning ones

The rule that labels code cells as Mathematica,

    sed -z 's|\n\n```\n|\n\n```mathematica\n|g'

also matched a closing fence that follows an empty line (a cell ending in
a blank line), so the cell was closed by "```mathematica" - which opens a
new block instead. pandoc then renders the cell as a paragraph of raw text
("```mathematica FCCompareResults[...]", e.g. at the bottom of
QED/TwoLoops/Renormalization-LeAle on the website) or swallows the output
after it into the code block (TID, UnDeclareNonCommutative).

The rule is replaced by an awk pass that tracks whether it is inside a cell
and labels only opening fences (still only after an empty line, as before),
and the 56 Markdown files already affected (14 in Documentation/Markdown,
42 examples) get their closing fence back.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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