Skip to content

fix: markdown preview mojibake, admonitions, and lost code blocks - #2766

Open
marcelosalloum wants to merge 2 commits into
mainfrom
fix/md-preview-rendering
Open

fix: markdown preview mojibake, admonitions, and lost code blocks#2766
marcelosalloum wants to merge 2 commits into
mainfrom
fix/md-preview-rendering

Conversation

@marcelosalloum

@marcelosalloum marcelosalloum commented Aug 18, 2026

Copy link
Copy Markdown
Contributor

What

  • Serve text responses with an explicit charset=utf-8 so .md previews no longer render UTF-8 punctuation (em dashes, arrows, emoji) as mojibake
  • 3 new postbuild scripts added:
    • scripts/rewrite_md_admonitions.mjs rewrites Docusaurus admonitions in the generated .md twins to GitHub-style alerts (:::info[Title]> [!NOTE] + blockquoted body); nested and list-indented admonitions were also handled.
    • scripts/rewrite_md_code_examples.mjs regenerates .md twins from their MDX sources, converting <CodeExample> blocks to fenced code blocks with bold labels for title attributes
    • scripts/rewrite_md_titles.mjs prepends the front-matter title as an H1 to .md twins that lack one, skipping hide_title: true pages
  • Add a small local Docusaurus plugin (src/plugins/markdown-source-map) that dumps a route → source-file map at build time, since the twin-regeneration scripts need it and plugin postBuild hooks run concurrently with no reliable ordering

Why

The raw .md being served had several issues:

  • UTF-8 punctuation (em dashes, arrows, emoji) rendered as mojibake
  • CodeExample blocks were completely stripped.
  • Front-matter titles were missing from some .md twins.
  • Admonitions were not being rendered

@marcelosalloum marcelosalloum self-assigned this Aug 18, 2026
@marcelosalloum
marcelosalloum marked this pull request as ready for review August 18, 2026 23:52
Copilot AI balanced review requested due to automatic review settings August 18, 2026 23:52

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds UTF-8 response encoding and converts generated Markdown admonitions into GitHub alerts.

Changes:

  • Adds UTF-8 charset handling in Nginx.
  • Adds post-build admonition conversion.
  • Normalizes one malformed admonition.

Recommendation: NEEDS-CHANGES — fence parsing must preserve valid fenced content.

Reviewed changes

Copilot reviewed 3 out of 4 changed files in this pull request and generated 1 comment.

File Description
scripts/rewrite_md_admonitions.mjs Converts generated admonitions to GitHub alerts.
package.json Registers the new post-build step.
nginx/nginx.conf Enables UTF-8 charset responses.
docs/build/smart-contracts/example-contracts/workspace.mdx Corrects admonition syntax.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread scripts/rewrite_md_admonitions.mjs Outdated
@stellar-jenkins-ci

Copy link
Copy Markdown

@kaankacar

kaankacar commented Aug 19, 2026

Copy link
Copy Markdown
Contributor

Tested on the preview and reproduced with a full local build. The .md twins now serve text/plain; charset=utf-8, and all admonitions across the 910 generated files convert cleanly to GitHub alerts: no leftover ::: lines, HTML output untouched, script is idempotent. LGTM, merge-ready.

@marcelosalloum marcelosalloum changed the title fix: markdown preview mojibake and admonitions fix: markdown preview mojibake, admonitions, and lost code blocks Aug 20, 2026
The generated .md twins lost <CodeExample> content to the upstream
plugin's component cleanup and lacked H1 titles, and the admonition
rewriter's boolean fence toggle desynced on mixed/long fences (flagged
by Copilot review). Fence tracking now follows CommonMark (delimiter
char + length), nested/list-indented admonitions degrade to emoji-
labeled blockquotes since GitHub only renders alerts at top level, and
two new postbuild scripts regenerate code blocks and inject titles
using a route -> source map dumped by a small local plugin (plugin
postBuild hooks run concurrently, so ordering lives in the npm
postbuild chain).
@stellar-jenkins-ci

Copy link
Copy Markdown

@marcelosalloum

Copy link
Copy Markdown
Contributor Author

@kaankacar, thanks tor raising that. I've addressed this edge case and also corrected other issues on the *.md files I've identified later:

  • titles were missing
  • code blocks were being stripped

🔴 Both issues can be confirmed at developers.stellar.org/.../ingestion-pipeline-code vs developers.stellar.org/.../ingestion-pipeline-code.md
✅ Their fix can be confirmed at the preview links (...)pr2766.previews.../ingestion-pipeline-code vs (...)pr2766.previews.../ingestion-pipeline-code.md

@marcelosalloum
marcelosalloum requested review from kaankacar and removed request for ElliotFriend August 20, 2026 18:17
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.

3 participants