-
Notifications
You must be signed in to change notification settings - Fork 6
Open
Description
The current markup parsing logic requires improvement to prevent formatting rules from accidentally modifying text inside code blocks. We need to implement a mechanism to safely isolate code sections before applying other transformations.
While we considered a full migration to Markdig (with EmphasisExtra, AutoLinks, and custom BBCode extensions), we have decided to proceed with a custom "Hide-Replace-Restore" implementation for now.
We will implement a pipeline that processes text in three stages:
- Hide: Scan the input text for
codeblocks (both Markdown backticks and BBCode[code]). Extract these sections into a temporary array and replace them in the main text with unique placeholders (e.g.,%%CODE_BLOCK_0%%). - Replace: Perform all necessary text formatting, regex replacements, etc. on the main text (which now contains only placeholders for code).
- Restore: Iterate through the text one last time and replace the placeholders with the original, untouched code content from the array.