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
SPEC-TTUI-05~draft— Slice 4 deliverable (§5, Slice 4): migratemarkdown.rs.
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
maxdisplay chars, appending…if shortened.