Skip to main content

Module markdown

Module markdown 

Source
Expand description

CommonMark and GitHub Flavored Markdown highlighter and interactive hook.

Lives at src/batteries/markdown/; this shim keeps the public path twrite_core::markdown stable regardless of file layout. CommonMark and GitHub Flavored Markdown battery: highlighter and interactive hook.

The battery is split into focused modules (promoted from a single batteries/markdown.rs once it outgrew one file, per the registry contract in crate::batteries):

  • [config]: MarkdownConfig / ConcealMode shared settings.
  • [table]: GFM pipe-table detection (blocks, pipes, delimiter rows).
  • [highlight]: MarkdownHighlighter (SyntaxHighlighter impl).
  • hook: MarkdownHook (EditorHook impl: shortcuts, lists, tables).
  • [links]: single-line hyperlink extraction shared by highlighting and click handling.

Everything here is built only on the public core API (SyntaxHighlighter, EditorHook, HighlightTag, ConcealedLine, …) and emits only existing HighlightTag variants plus Custom("markdown.table.*") names, so no twrite-gpui-side code is required.

Structs§

MarkdownConfig
Configuration settings for Markdown editing, highlighting, and WYSIWYG rendering.
MarkdownHighlighter
A syntax highlighter for CommonMark and GFM Markdown documents using pulldown-cmark.
MarkdownHook
An editor hook providing Markdown shortcuts (Ctrl+B, Ctrl+I, Ctrl+K), smart list continuation, and task list toggles.
TableBlock
A contiguous GFM pipe-table block: header + delimiter + 0..N body rows.
TableLayout
Display-column widths for one TableBlock, measured on unconcealed source cell content so widths stay stable as the cursor moves (inactive rows conceal markers; per-row padding absorbs the difference and pipes still align everywhere).

Enums§

ConcealMode
Display mode for markdown syntax delimiters (like # , **, *, ~~, `) on inactive lines.
TableAlignment
Column alignment parsed from a GFM delimiter cell (---, :--, --:, :-:).
TableRowKind
Which row of a TableBlock a buffer row is.

Constants§

TABLE_CELL_TAG
Custom tag for GFM table body cell content.
TABLE_DELIMITER_TAG
Custom tag for GFM table delimiter rows (| --- | :-: |).
TABLE_HEADER_TAG
Custom highlight tag names emitted for GFM tables.

Functions§

extract_markdown_links
Extracts all markdown hyperlink destinations and their label character ranges from a single line.
fence_rows
Collects every fence-marker row in a single linear pass.
find_unescaped_pipes
Byte offsets of cell-separator pipes in line.
is_fenced_row
Returns whether row sits inside a fenced code block.
parse_delimiter_row
Parses a GFM delimiter row into per-column alignments.
split_table_cells
Splits line into cell-content byte ranges plus separator pipe offsets.
table_block_at
Locates the GFM pipe-table block containing row, if any.
table_block_at_with_fences
table_block_at with a caller-provided fence index.
table_layouts
Finds every table block in the buffer with its measured TableLayout.
table_layouts_with_fences
table_layouts with a caller-provided fence index.