fix: markdown preview mojibake, admonitions, and lost code blocks - #2766
fix: markdown preview mojibake, admonitions, and lost code blocks#2766marcelosalloum wants to merge 2 commits into
Conversation
There was a problem hiding this comment.
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.
|
Preview is available here: |
|
Tested on the preview and reproduced with a full local build. The |
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).
|
Preview is available here: |
|
@kaankacar, thanks tor raising that. I've addressed this edge case and also corrected other issues on the *.md files I've identified later:
🔴 Both issues can be confirmed at developers.stellar.org/.../ingestion-pipeline-code vs developers.stellar.org/.../ingestion-pipeline-code.md |
What
charset=utf-8so.mdpreviews no longer render UTF-8 punctuation (em dashes, arrows, emoji) as mojibakepostbuildscripts added:scripts/rewrite_md_admonitions.mjsrewrites Docusaurus admonitions in the generated.mdtwins to GitHub-style alerts (:::info[Title]→> [!NOTE]+ blockquoted body); nested and list-indented admonitions were also handled.scripts/rewrite_md_code_examples.mjsregenerates.mdtwins from their MDX sources, converting<CodeExample>blocks to fenced code blocks with bold labels fortitleattributesscripts/rewrite_md_titles.mjsprepends the front-matter title as an H1 to.mdtwins that lack one, skippinghide_title: truepagessrc/plugins/markdown-source-map) that dumps a route → source-file map at build time, since the twin-regeneration scripts need it and pluginpostBuildhooks run concurrently with no reliable orderingWhy
The raw
.mdbeing served had several issues:.mdtwins.