topmark.processors.builtins.markdown¶
topmark / processors / builtins / markdown
Processor for files with HTML/XML-style block comments ().
This processor treats Markdown as a line-based format that happens to support
HTML comment blocks (<!-- ... -->) for the TopMark header. It does not
use XML positional logic or prolog/doctype handling; headers are inserted at
the top of the document (line-based strategy).
Markdown-specific behavior
- Uses HTML block comments (
<!-- ... -->) as the header block wrapper. - Inserts the TopMark header at the logical top of the file (index 0) so it precedes any existing banner comments or headings.
- Ignores TopMark markers that appear inside fenced code blocks (``` / ~~~), even if they look like partial or malformed headers. This keeps README examples from being treated as real headers and allows Builder/Planner to insert a header at the top when appropriate.
MarkdownHeaderProcessor ¶
Bases: BlockCommentMixin, HeaderProcessor
Header processor for Markdown formats (HTML comment-based, line-oriented).
This processor uses <!-- ... --> block comments for the TopMark header and
relies on the line-based placement strategy from HeaderProcessor. It
adds Markdown-specific safeguards to ignore header-like markers that appear
inside fenced code blocks (``` or ~~~).
Source code in src/topmark/processors/builtins/markdown.py
get_header_bounds ¶
Detect the TopMark header in Markdown, ignoring fenced code blocks.
This override delegates to the base header-bounds logic after hiding any TopMark markers that appear inside fenced code blocks (``` or ~~~). Markers in fenced regions are treated as plain text so README examples do not affect header detection.
Source code in src/topmark/processors/builtins/markdown.py
prepare_header_for_insertion ¶
prepare_header_for_insertion(
*,
original_lines,
insert_index,
rendered_header_lines,
newline_style,
)
Ensure a single blank line after the header block in Markdown.
- Insert at top of file (index 0) with no leading blank.
- If body content follows and the first body line is not blank, append exactly one blank line after the header block.