package mosaic
Install
dune-project
Dependency
Authors
Maintainers
Sources
sha256=9e4e90d17f9b2af1b07071fe425bc2c519c849c4f1d1ab73cde512be2d874849
sha512=06e9c4a741590942e81a27738d0b5c0413fafec8cf3b7dae047ad69f155e7b718aa4223818dc161b7d028efffcfd3365905e264d6fd31d453910ddfa91dcf9b9
doc/mosaic.ui/Mosaic_ui/Markdown/index.html
Module Mosaic_ui.Markdown
CommonMark renderer with headings, code blocks, lists, and tables.
Markdown content display.
Parses CommonMark source via cmarkit and renders it as a tree of child Renderable.t values. Supports headings, paragraphs, code blocks, lists, blockquotes, tables, thematic breaks, and inline formatting (emphasis, strong, code spans, links, strikethrough, and task lists).
Style
type style_key = | Default| Heading of int(*Level (1-3 have distinct colors; 4+ share one).
*)| Emphasis| Strong| Code_span| Code_block| Link| Image| Blockquote| Thematic_break| List_marker| Strikethrough| Task_marker| Table_border(*Border color for table borders.
*)| Conceal_punctuation(*Style for markdown syntax markers (
*)\*,\`,[, etc.).
The type for style keys identifying markdown element classes.
type style = style_key -> Ansi.Style.tThe type for style resolvers. Maps a style_key to the Ansi.Style.t to apply when rendering that element.
val default_style : styledefault_style is the built-in terminal style resolver. The mapping is:
Default: no decoration.Heading n: bold; colored by level (magenta for 1, green for 2, cyan for 3, blue for 4+).Emphasis: italic.Strong: bold.Code_spanandCode_block: dim.LinkandImage: underline and cyan.Blockquote: italic and yellow.Thematic_breakandList_marker: dim.Strikethrough: strikethrough.Task_marker: bold.Table_border: dim.Conceal_punctuation: dim.
Props
module Props : sig ... endConstructors
val create :
parent:Renderable.t ->
?index:int ->
?id:string ->
?layout_style:Toffee.Style.t ->
?visible:bool ->
?z_index:int ->
?opacity:float ->
?content:string ->
?style:style ->
?conceal:bool ->
?streaming:bool ->
?render_node:
(Cmarkit.Block.t ->
parent:Renderable.t ->
is_last:bool ->
Renderable.t option) ->
?render_code:
(parent:Renderable.t ->
language:string option ->
content:string ->
Renderable.t) ->
unit ->
tcreate ~parent () is a markdown display widget attached to parent. With:
content: the markdown source text. Defaults to"".style: the style resolver. Defaults todefault_style.conceal: whether to hide markdown syntax characters. Whentrue, a link[[text](url)]is displayed astext (url). Defaults totrue.streaming: whentrue, incomplete trailing content is handled gracefully; the last table row is skipped to avoid flickering during incremental appends. Defaults tofalse.render_node: a custom block renderer called for everyCmarkit.Block.tbefore default rendering. ReturnSome rto replace default rendering with renderabler, orNoneto fall through to the default. The returned renderable must be attached toparent.render_code: a custom code block renderer called for code blocks beforerender_node. Receives the optional language tag and the code content. The returned renderable must be attached toparent. Use this to integrate syntax highlighting.
val node : t -> Renderable.tnode t is the underlying Renderable.t for t.
val set_layout_style : t -> Toffee.Style.t -> unitset_layout_style t s updates the layout style of t to s, preserving the required column direction and full-width sizing.
Content
val set_content : t -> string -> unitset_content t s replaces the markdown source of t with s and re-renders. Unchanged blocks are updated in place without destroying their renderables, making this efficient for streaming appends. No-op when s equals the current content.
See also content.
val content : t -> stringcontent t is the current markdown source of t.
See also set_content.
Configuration
set_style t f changes the style resolver of t to f and re-renders. Re-parsing is skipped when blocks already exist; leaf blocks are updated in place without destroying their renderables.
val set_conceal : t -> bool -> unitset_conceal t v sets whether t hides markdown syntax characters. Re-parsing is skipped when blocks already exist; leaf blocks are updated in place. No-op when v equals the current value.
val set_streaming : t -> bool -> unitset_streaming t v enables (true) or disables (false) streaming mode on t. When enabled, incomplete trailing table rows are skipped. No-op when v equals the current value.
Props application
apply_props t p applies the properties p to t, updating content, style, conceal, and streaming mode as needed.
Formatting and inspecting
val pp : Format.formatter -> t -> unitpp formats a markdown widget for debugging.