Skip to content

Refine markup parser #53

@magicxor

Description

@magicxor

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:

  1. Hide: Scan the input text for code blocks (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%%).
  2. Replace: Perform all necessary text formatting, regex replacements, etc. on the main text (which now contains only placeholders for code).
  3. Restore: Iterate through the text one last time and replace the placeholders with the original, untouched code content from the array.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions