Skip to content

fix: protect tilde-fenced code blocks from strikethrough conversion - #36

Merged
blaipr merged 1 commit into
mainfrom
fix/tilde-fence-strikethrough
Sep 2, 2026
Merged

blaipr merged 1 commit into
mainfrom
fix/tilde-fence-strikethrough

Conversation

@blaipr

@blaipr blaipr commented Sep 2, 2026

Copy link
Copy Markdown
Member

Problem

The strikethrough pre-processor in md_to_confluence_storage protected fenced code by splitting on ```.*?``` only. Python-Markdown's fenced_code extension also accepts ~~~ fences and runs longer than three characters, so a ~~ inside a ~~~ block (a shell here-doc, Lua's ~~, Perl) was rewritten to <del>…</del> inside the code, and a block containing a literal ``` ```` was split at the wrong place.

Change

Fences are now found with the same shape the extension uses — ^({3,}|~{3,})opening a line, closed by the identical run at the start of a line — and the text between fences goes through the existing inline-code-aware replacement. The function is split into_replace_strikethrough(fence walk) and_strike_outside_code` (inline spans), with no change to what happens outside fences.

Compatibility

Upload only. Backtick fences and inline code behave exactly as before; ~~~ fences and 4+-character fences are now left untouched like backtick ones.

Checklist

  • ruff check src tests, ruff format --check src tests and python -m pytest tests/ pass
  • Tests added for the change (tests/test_md_to_storage.py::TestStrikethrough)
  • Docs updated (docs/conversion.md, Code blocks)
  • docs/conversion.md updated because an equivalence changed
  • CHANGELOG.md updated under Unreleased

@blaipr
blaipr force-pushed the fix/tilde-fence-strikethrough branch from 52db68f to a204398 Compare September 2, 2026 22:39
@blaipr
blaipr merged commit b585e6c into main Sep 2, 2026
1 check passed
@blaipr
blaipr deleted the fix/tilde-fence-strikethrough branch September 2, 2026 22:40
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