Skip to content

fix: export links cleanly on formatted lines + don't escape _ in code blocks (#156, part)#182

Merged
JohnMcLear merged 1 commit intomasterfrom
fix/markdown-link-in-bold-and-code-underscore
Apr 17, 2026
Merged

fix: export links cleanly on formatted lines + don't escape _ in code blocks (#156, part)#182
JohnMcLear merged 1 commit intomasterfrom
fix/markdown-link-in-bold-and-code-underscore

Conversation

@JohnMcLear
Copy link
Copy Markdown
Member

Addresses two of the four items in #156:

  1. Link on a bold/italic line corrupted. The exporter closed no open format tags before writing the URL, so processing the URL's chars re-emitted **/* markers inside the Markdown link token ([text](**https://...**)). Close open tags before the URL, emit URL text verbatim, reopen tags afterwards.
  2. Underscores escaped inside code blocks. The final /_/g → \\_ replace ran unconditionally, so snake_case inside a heading: 'code' line turned into snake\\_case in the rendered MD. Skip the escape on code-styled lines.

Leaves the other two items (stray 4-space indent rendering as code; bold markers landing outside the list dash) for follow-ups — they need cleaner changes than a drive-by patch.

…code blocks (#156, part)

Two export-to-Markdown bugs from #156:

1. A link on a line that is also bold/italic came out as
   \`**bold prefix**[link text](**https://linkurl**)\`. The URL handler
   was stepping past the \`[\` without closing the open format tags, so
   every URL character produced another \`**\` inside the link token.
   Close any currently-open inline tags before emitting the URL, write
   the URL text verbatim, and reopen the tags after the closing \`)\`.

2. Underscores inside a \`heading: 'code'\` line were globally escaped to
   \`\\_\` by the final \`assem.replace(/_/g, '\\\\_')\`. Identifiers in
   code blocks should stay literal, so the renderer doesn't turn
   \`snake_case\` into \`snake\\\\_case\`. Skip the underscore escape on
   code-styled lines.

Doesn't address the other two items in #156 (stray indentation turning
into a code block, and bold-list markers landing outside the \`-\`) —
those need follow-ups.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@JohnMcLear JohnMcLear merged commit 58fcf84 into master Apr 17, 2026
3 checks passed
@JohnMcLear JohnMcLear deleted the fix/markdown-link-in-bold-and-code-underscore branch April 17, 2026 14:47
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