Skip to main content

Module markdown

Module markdown 

Source
Expand description

Markdown-aware rendering helpers for the chat scrollback: fenced code-block detection and box-drawing table rendering.

Why: DOC-50 §5 Slice 4 migrates tagent’s repl/tui/markdown.rs (297 lines) into this shared crate verbatim — every function here is already engine-agnostic (pure &str/Vec<String> in, Line/Span out; no ReplApp dependency), so the migration is a straight move rather than a generalization. crate::widgets::scrollback::build_chat_lines is the sole caller, walking a message body line-by-line and dispatching to code_fence_lang/is_executable_shell_lang (fence detection) or is_md_table_row/is_md_table_separator/parse_md_table_cells/ render_markdown_table (table detection) as it goes.

What: no state, no I/O — every function is a pure transform, which is why this module lives under crate::render rather than crate::widgets (see that module’s doc comment for the distinction).

§Spec References

Functions§

code_fence_lang
Parse a fenced code-block opener line and return the language tag.
extract_last_shell_block
Extract the last executable-shell fenced code block body from a message.
is_executable_shell_lang
Whether a fenced-code-block language tag denotes an executable shell.
is_md_table_row
Detect a markdown table row: trimmed line starts with |.
is_md_table_separator
Detect a markdown table separator row: cells contain only -, :, spaces.
parse_md_table_cells
Split a markdown table row on | and trim each cell.
render_markdown_table
Render a parsed markdown table as box-drawing styled Lines.
truncate_cell
Truncate a string to max display chars, appending … if shortened.