Markdown
lib/markdown/tui_markdown.sh - Markdown renderer for reading and editing: wrapped, styled rows with a source-line map, plus a source-preserving styler for editors. ← API index for the full module list.
Render and style
| Function | Summary |
|---|---|
tui.md.render |
Renders Markdown TEXT into rows of at most WIDTH cells. |
tui.md.style |
Styles Markdown TEXT for source editors: one row per source line, with every character kept. |
tui.md.strip |
Removes the SGR (color and attribute) sequences from STR, then prints the result or stores it in VAR. |
tui.md.row_for_line |
Stores in VAR the 0-based index of the first rendered row of the block that holds source line LINE (1-based). |
tui.md.line_for_row |
Stores in VAR the source line (1-based) of rendered row ROW, using the last render. |
tui.md.style_set |
Replaces the SGR sequence of one style class. |
tui.md.mono |
Switches the style table to attributes only (bold, underline, reverse, dim, no colors) with on, or back to the colored table with off. |
tui.md.breaks |
Chooses whether a single newline inside a paragraph breaks the line (on) or joins the lines with a space (off, the default). |
tui.md.fonts |
Switches headings that have a font (see tui.md.heading_font) between block letters (on) and plain styled text (off, the default). |
tui.md.heading_font |
Sets the block font used for heading level LEVEL while tui.md.fonts is on. |
tui.md.style_spec |
Restyles one Markdown style class from SPEC, given as FG[/BG][:MOD,MOD...]. |
tui.md.style_spec_of |
Stores in VAR the spec of the current style of CLASS. |
tui.md.style_reset |
Restores the default style of CLASS, or of every style class when CLASS is omitted. |
tui.md.heading_font_of |
Stores in VAR the font name of heading level LEVEL, or style when that level has no font. |
tui.md.config_apply |
Loads the persisted Markdown settings from the app config: md.fonts (0/1), md.breaks (0/1), md.link_url (inline or hidden), md.font.N (a font name or style, N = 1..6) and md.style.CLASS (a style spec). |
tui.md.render
tui.md.render TEXT WIDTH
Renders Markdown TEXT into rows of at most WIDTH cells.
Parameters
TEXT: the Markdown source.WIDTH: the row width in cells. Values below 1 are treated as 1.
Results
TUI_MD_ROWS: array with one styled row per terminal row. Every row starts and ends in the reset state.TUI_MD_MAP: source line (1-based) of each row. Blank separator rows map to the blank line before the next block.TUI_MD_LINK_URLSandTUI_MD_LINK_TEXTS: the links, in document order.TUI_MD_LINK_ROWS: the row of each link, in the same order.TUI_MD_HEADS: oneLEVEL|TITLE|FIRST_ROW|LAST_ROW|LINEentry per heading.TUI_MD_ANCHORS: maps the GitHub-style slug of each heading to its row.
Notes
- Supported: ATX headings (
#to######), setext headings (===and---underlines), paragraphs with soft and hard breaks (two trailing spaces or a backslash), block quotes (nested), bullet and ordered lists (nested, tight or loose), task lists (- [ ]and- [x]), fenced code (```or~~~, clipped rather than wrapped, padded toWIDTH), indented code, thematic breaks, bold, italic, both,strike,code,[text](url "title")links,<autolinks>, reference links[text][ref]with[ref]: urldefinitions, backslash escapes, images as placeholders (seetui.md.images), pipe tables (seetui.md.tables) and a small HTML subset:<br>,<img>,<a>,<b>,<i>,<code>,<s>,<hr>,<h1>to<h6>and comments. Other tags are dropped and their text is kept. - Not supported: raw HTML beyond that subset, math, footnotes.
- Wide characters (CJK, emoji) count two cells under a UTF-8 locale.
- Control bytes and foreign escape sequences are removed from the input.
- Containers (quote, list) need a few cells more than their prefix.
- Text longer than
TUI_MD_MAX_BYTES(default 262144) skips inline parsing and setsTUI_MD_DEGRADED=1. TUI_MD_LINK_URLselects how links show their target:inline(default,text (url)) orhidden.
Example
tui.md.render "$(<README.md)" 80
printf '%s\n' "${TUI_MD_ROWS[@]}"
See also: tui.md.style, tui.md.row_for_line, tui.md.line_for_row
tui.md.style
tui.md.style TEXT
Styles Markdown TEXT for source editors: one row per source line, with every character kept.
Parameters
TEXT: the Markdown source.
Results
TUI_MD_ROWS: one styled row per source line. Stripping the SGR sequences gives the input back.TUI_MD_MAP: identity map.
Notes
- Delimiters are drawn with the
markerclass. Headings, quotes, list markers, fences, emphasis, code and links are styled.
See also: tui.md.render, tui.md.style_set
tui.md.strip
tui.md.strip STR [VAR]
Removes the SGR (color and attribute) sequences from STR, then prints the result or stores it in VAR.
Parameters
STR: the styled string.VAR: optional variable name. When given, the result is stored there and nothing is printed. No subshell is used.
Example
tui.md.strip "$line" plain
tui.md.row_for_line
tui.md.row_for_line LINE VAR
Stores in VAR the 0-based index of the first rendered row of the block that holds source line LINE (1-based).
Parameters
LINE: the 1-based source line.VAR: the variable that receives the row index.
Notes
- Uses the map of the last
tui.md.render. The result is0whenLINEis before the first block. - Use it to keep the scroll position when switching between the source and the rendered view.
tui.md.line_for_row
tui.md.line_for_row ROW VAR
Stores in VAR the source line (1-based) of rendered row ROW, using the last render.
Parameters
ROW: the 0-based rendered row index.VAR: the variable that receives the line number.
Notes
- The result is
0when the row does not exist.
tui.md.style_set
tui.md.style_set CLASS SGR
Replaces the SGR sequence of one style class.
Parameters
CLASS: one ofh1h2h3h4h5h6strongemcodecodeblockquotebulletlinkhrmarker.SGR: a full escape sequence such as$'\e[1;31m'.
See also: tui.md.mono
tui.md.mono
tui.md.mono on|off
Switches the style table to attributes only (bold, underline, reverse, dim, no colors) with on, or back to the colored table with off.
Parameters
on|off: the mode to select.
Notes
- Switching resets the overrides made with
tui.md.style_set.
tui.md.breaks
tui.md.breaks on|off|toggle
Chooses whether a single newline inside a paragraph breaks the line (on) or joins the lines with a space (off, the default).
Parameters
on|off|toggle: the setting to select;toggleflips it (default).
Returns: 1 for an unknown argument.
Notes
- Takes effect on the next
tui.md.render; re-render what is on screen after changing it. - A blank line always separates paragraphs. The setting also applies to lines inside list items and quotes, and can be preset with
TUI_MD_BREAKS=1.
Example
tui.md.breaks on
tui.md.render $'one\ntwo' 40 # two rows: "one", "two"
tui.md.fonts
tui.md.fonts on|off|toggle
Switches headings that have a font (see tui.md.heading_font) between block letters (on) and plain styled text (off, the default).
Parameters
on|off|toggle: the setting to select;toggleflips it (default).
Returns: 1 for an unknown argument.
Notes
- Off by default in the library.
tui.config.applyturns them on unlessmd.fontsis set in the config (Settings > Markdown). - Takes effect on the next
tui.md.render. Presettable withTUI_MD_FONTS=1. - Words are packed into as many banner lines as the width needs. A heading whose single word is wider than the width falls back to plain text.
- Heading text is drawn without its inline markup, in capitals (the banner fonts are upper-case).
tui.md.styleis never affected. - The first use loads the banner renderer (
terminal_renderer.sh).
Example
tui.md.fonts on
tui.md.render "# Title" 80 # five block-letter rows
tui.md.heading_font
tui.md.heading_font LEVEL FONT
Sets the block font used for heading level LEVEL while tui.md.fonts is on.
Parameters
LEVEL: heading level1to6.FONT:block5(5 rows),blk3,seg3,box3(3 rows),half2(2 rows),styleor""for no font at that level: only the style class (bold, underline, color) is applied.
Returns: 1 for an unknown level or font; the setting is left unchanged.
Notes
- Defaults: level 1
block5, level 2box3, the others plain. - The heading style’s underline is dropped on block rows; it would strike through the letters.
Example
tui.md.heading_font 3 seg3 # ### headings in seg3
tui.md.heading_font 1 "" # # headings stay plain
tui.md.style_spec
tui.md.style_spec CLASS SPEC
Restyles one Markdown style class from SPEC, given as FG[/BG][:MOD,MOD...].
Parameters
CLASS: one ofh1toh6,strong,em,code,codeblock,quote,bullet,link,hr,marker,strike,hl_keyword,hl_string,hl_comment,hl_number,hl_var,page,table(the outline of tables) ortable_head(the header row).pageis the document background: every rendered row is padded to the width under it. It is empty by default.SPEC:FGoptionally followed by/BG, then optionally:and comma-separated modifiers.FGandBGaredefault(BGonly), a name fromTUI_MD_COLORS(black red green yellow blue magenta cyan white gray bright_red bright_green bright_yellow bright_blue bright_magenta bright_cyan bright_white) or#rrggbb. Modifiers are fromTUI_MD_MODS(bold dim italic underline reverse strike). An emptySPECrestores the default style ofCLASS.
Returns: 1 and changes nothing for an unknown class, color or modifier.
Notes
- The spec is remembered, so
tui.md.style_spec_ofreports it back. tui.md.style_resetundoes the change.- A spec set here goes on top of the base look chosen with
tui.md.profile.
Example
tui.md.style_spec h1 "cyan:bold,underline"
tui.md.style_spec code "#ff8000"
tui.md.style_spec page "white/#102030:bold"
tui.md.style_spec_of
tui.md.style_spec_of CLASS VAR
Stores in VAR the spec of the current style of CLASS.
Parameters
CLASS: a style class, as fortui.md.style_spec.VAR: the name of the variable that receives the spec.
Notes
- The spec has the form
FG[/BG][:MOD,MOD...], as fortui.md.style_spec. - The spec is the one
CLASSwas set with. A class that was never set has its spec read back from its default SGR sequence, for exampledefault:bold.
Example
tui.md.style_spec_of h1 spec # spec="cyan:bold,underline" after the h1 example
tui.md.style_reset
tui.md.style_reset [CLASS]
Restores the default style of CLASS, or of every style class when CLASS is omitted.
Parameters
CLASS: optional, one style class as fortui.md.style_spec.
Notes
- Also forgets the specs set by
tui.md.style_specfor the affected classes. - The profile style of each affected class shows again (see
tui.md.profile).
Example
tui.md.style_reset h1 # only h1
tui.md.style_reset # every class
tui.md.heading_font_of
tui.md.heading_font_of LEVEL VAR
Stores in VAR the font name of heading level LEVEL, or style when that level has no font.
Parameters
LEVEL: heading level1to6.VAR: the name of the variable that receives the font name.
Example
tui.md.heading_font_of 1 font # font=block5 with the defaults
tui.md.config_apply
tui.md.config_apply
Loads the persisted Markdown settings from the app config: md.fonts (0/1), md.breaks (0/1), md.link_url (inline or hidden), md.font.N (a font name or style, N = 1..6) and md.style.CLASS (a style spec).
Notes
- Called by
tui.config.apply. The Settings > Markdown page writes these keys. - A style key is applied with
tui.md.style_spec, so an invalid value is ignored.
Example
tui.config.apply # also loads the md.* keys
Editor overlay and pages
| Function | Summary |
|---|---|
tui.md.style_lines |
Styles consecutive source lines for an editor overlay: one row per LINE, characters unchanged, delimiters in the marker class. |
tui.md.fence_before |
Stores in VAR the code-fence state ("" or CHAR:LEN) in force at source line TOP (0-based) of TEXT. |
tui.md.show |
Renders TEXT as Markdown into the scrolling pane PANE (scroll="v"). |
tui.md.show_file |
Renders the contents of FILE into the scrolling pane PANE, as tui.md.show does. Returns 1 when FILE cannot be read. |
tui.md.forget |
Stops re-rendering a pane that was filled by tui.md.show or <markdown>. |
tui.md.style_lines
tui.md.style_lines FENCE LINE...
Styles consecutive source lines for an editor overlay: one row per LINE, characters unchanged, delimiters in the marker class.
Parameters
FENCE: the code-fence state in force before the first line:""outside a fence,CHAR:LENinside one (as stored bytui.md.fence_before).LINE...: the source lines, in order.
Results
TUI_MD_ROWS: array with one styled row perLINE.
Notes
- Rows of lines outside fences are memoized. The memo is dropped when
tui.md.style_setortui.md.monochange the style table.
Example
tui.md.fence_before "$(<notes.md)" 40 fence
tui.md.style_lines "$fence" "${visible[@]}"
See also: tui.md.style, tui.md.fence_before
tui.md.fence_before
tui.md.fence_before TEXT TOP VAR
Stores in VAR the code-fence state ("" or CHAR:LEN) in force at source line TOP (0-based) of TEXT.
Parameters
TEXT: the Markdown source.TOP: the 0-based source line. The state is the one before that line.VAR: the name of the variable that receives the state.
Notes
- The state is the
FENCEargument oftui.md.style_lines.
Example
tui.md.fence_before "$(<notes.md)" 40 fence
See also: tui.md.style_lines
tui.md.show
tui.md.show PANE TEXT [FILE]
Renders TEXT as Markdown into the scrolling pane PANE (scroll="v").
Parameters
PANE: the ID of a pane withscroll="v".TEXT: the Markdown source.FILE: whereTEXTcame from. Relative links (other.md,../x.md#anchor) resolve against its folder andtui.md.backcan return to it.
Notes
- The text is remembered, and the pane is rendered again when its width changes (resize, first layout, page switch).
<markdown pane="ID" src="FILE"/>in markup does the same with the contents of a file.
Example
tui.md.show help_pane "$(<README.md)"
See also: tui.md.show_file, tui.md.render
tui.md.show_file
tui.md.show_file PANE FILE
Renders the contents of FILE into the scrolling pane PANE, as tui.md.show does. Returns 1 when FILE cannot be read.
Parameters
PANE: the ID of a pane withscroll="v".FILE: the path of the Markdown file.
Example
tui.md.show_file help_pane docs/help.md || tui.set_label status "no help"
See also: tui.md.show
tui.md.forget
tui.md.forget PANE
Stops re-rendering a pane that was filled by tui.md.show or <markdown>.
Parameters
PANE: the pane id.
Notes
- Call it before putting other content into the pane (a tab that shows something else): otherwise the next resize or page switch renders the remembered Markdown over it.
- The pane’s current content stays until it is replaced. Unknown panes are ignored.
Example
tui.md.forget content
tui.output content "$other_view"
Documents in panes
The settings that choose how Markdown is drawn (profile, tables, images, highlighting), and the navigation, search, folding and copy functions of a document shown in a pane.
| Function | Summary |
|---|---|
tui.md.profile |
Chooses the base look of the Markdown styles: DABT’s own style table, or the active theme’s .md_CLASS rules. |
tui.md.tables |
Chooses how pipe tables are drawn. |
tui.md.table_overflow |
Chooses what happens to a table cell that is wider than its column. |
tui.md.images |
Chooses what  draws in a rendered document. |
tui.md.image_protocol |
Stores in VAR the image protocol of the terminal: kitty, iterm2 or none. |
tui.md.highlight |
Registers the highlighter of a code fence language. |
tui.md.link_next |
Focuses the next link of the document shown in PANE, wrapping at the end. |
tui.md.link_prev |
Focuses the previous link of the document shown in PANE, wrapping at the start. |
tui.md.link_open |
Follows the focused link of the document shown in PANE. Returns 1 when no link is focused. |
tui.md.on_link |
Sets the function that tui.md.link_open calls first, as FN URL TEXT PANE. |
tui.md.on_navigate |
Sets the function called as FN FILE PANE after a relative .md link has loaded FILE into PANE. |
tui.md.back |
Returns PANE to the document and scroll position before the last followed link or anchor. |
tui.md.search |
Searches the rendered document in PANE for TEXT, case-insensitively as plain text. |
tui.md.search_next |
Jumps to the next match of the search in PANE, wrapping at the end. |
tui.md.search_prev |
Jumps to the previous match of the search in PANE, wrapping at the start. |
tui.md.search_info |
Stores in VAR the search state of PANE: 3/12, no match, or an empty string when no search is set. |
tui.md.outline_choose |
Opens a list (tui.choose) of the headings of the document shown in PANE, indented by level; choosing one scrolls the pane to its top. |
tui.md.fold_toggle |
Folds or unfolds the section under a heading of the document shown in PANE. |
tui.md.copy |
Copies part of the document shown in PANE to the clipboard with tui.clipboard.copy, and notifies. |
tui.md.forward |
Goes forward in PANE’s document history after tui.md.back: the document (and scroll position) the last back stepped over. Following a link starts a new trail and drops what was ahead. |
tui.md.search_prompt |
Asks for a search text in a prompt, then runs tui.md.search on PANE with it. An empty text clears the search; the match shown (3/12) or No match is announced as a notification. |
tui.md.keys |
Chooses which default Markdown keys act on PANE (<markdown keys="..."/> does the same in markup). |
tui.md.click |
Follows the link drawn under the screen cell X,Y of PANE, exactly like focusing it and calling tui.md.link_open. A left click on a link in a Markdown pane does this by itself. |
tui.action.md_keys |
Opens a scrollable list of the Markdown reading commands (links, back, search, outline, folds, copy) with the keys bound to them right now: the defaults and the app’s own binds. A command without a key shows -. Bound to f2 by default, and listed in the command palette as “Help: Markdown reading keybinds”. |
tui.md.profile
tui.md.profile dabt|theme
Chooses the base look of the Markdown styles: DABT’s own style table, or the active theme’s .md_CLASS rules.
Parameters
dabt|theme:dabtis DABT’s own style table;themetakes the.md_CLASSrules of the active theme (fg,bgandmods, as for any theme class) and keeps DABT’s look for the classes the theme does not define.
Returns: 1 for another name.
Notes
- The classes are
h1toh6,strong,em,code,codeblock,quote,bullet,link,hr,marker,strike,hl_keyword,hl_string,hl_comment,hl_number,hl_var,page,table(the outline of tables) andtable_head(the header row). - Styles set with
tui.md.style_specalways go on top of the profile. - Persisted as
md.profilein the config (seetui.md.config_apply).
Example
tui.md.profile theme
tui.md.tables
tui.md.tables grid|rounded|plain|stacked
Chooses how pipe tables are drawn.
Parameters
grid|rounded|plain|stacked:griddraws box lines,roundeddraws the box with round corners,plainhas no frame and a rule under the header,stackedwrites each row asHeader: valuelines.
Returns: 1 for another name.
Notes
stackedis also used when the pane is too narrow for the table.- Persisted as
md.tablesin the config.
Example
tui.md.tables plain
tui.md.table_overflow
tui.md.table_overflow wrap|truncate
Chooses what happens to a table cell that is wider than its column.
Parameters
wrap|truncate:wrapmakes the row taller,truncatecuts the cell with an ellipsis.
Returns: 1 for another name.
Notes
- Persisted as
md.table_overflowin the config.
Example
tui.md.table_overflow truncate
tui.md.images
tui.md.images placeholder|alt|hidden|graphics
Chooses what  draws in a rendered document.
Parameters
placeholder|alt|hidden|graphics:placeholderdraws[img: alt],altdraws only the alt text,hiddendraws nothing,graphicsdraws the picture itself where the terminal allows it and falls back to the placeholder where it does not.
Returns: 1 for another name.
Notes
graphicsneeds a terminal wheretui.md.image_protocolsayskitty(kitty, Ghostty) and a paragraph that holds only images, linked or not; several share a row like badges and wrap like words. Each picture is sent once, by file path, as a virtual placement, and drawn as rows of Unicode placeholder cells, so it scrolls, clips and folds like text. Images inside a sentence or a heading stay placeholders.- Formats: PNG is used as it is. SVG (
rsvg-convert) and GIF, JPEG, WebP and others (ImageMagickmagickorconvert, elseffmpeg: the first frame) are converted once into a PNG under~/.cache/DABT/md-images. Without such a tool they are placeholders. - Remote images (
http://,https://) are fetched only withTUI_MD_IMAGE_FETCH=1(configmd.fetch, Settings > Markdown):curlorwgetdownloads in the background, 15 s and 8 MB at most, and the pane re-renders when a file arrived. - Size: about 9 x 18 pixels per cell, at most
TUI_MD_IMAGE_MAX_COLSxTUI_MD_IMAGE_MAX_ROWS(60 x 20) and never wider than the pane. Relative paths resolve against the document’s folder (TUI_MD_BASE_DIR;tui.md.show_filesets it). - The size comes from the PNG header.
- Persisted as
md.imagesin the config.
Example
tui.md.images alt
tui.md.image_protocol
tui.md.image_protocol VAR
Stores in VAR the image protocol of the terminal: kitty, iterm2 or none.
Parameters
VAR: the name of the variable that receives the protocol.
Notes
kittyis reported for kitty and Ghostty (the protocol with Unicode placeholders thattui.md.images graphicsdraws),iterm2for iTerm2 and WezTerm (another protocol, not drawn),noneotherwise and also inside tmux, which needs passthrough.- Detection reads
TUI_MD_IMAGE_PROTOCOL(an override:kitty,iterm2,none), thenTMUX,KITTY_WINDOW_ID,TERM,TERM_PROGRAM,GHOSTTY_RESOURCES_DIRandLC_TERMINAL. - Only
kittyis drawn by DABT; the iTerm2 protocol is detected but pictures stay placeholders there.
Example
tui.md.image_protocol proto # proto=kitty in kitty
tui.md.highlight
tui.md.highlight LANG FN
Registers the highlighter of a code fence language.
Parameters
LANG: the fence language, matched case-insensitively.FN: the function, called asFN LINE. It setsTUI_MD_HLtoLINEwith SGR spans; the characters are unchanged. An emptyFNunregisters the language.
Notes
- Built in:
bash(alsosh,shell,zsh) andjson, using the classeshl_keyword,hl_string,hl_comment,hl_numberandhl_var.
Example
tui.md.highlight ini my_ini_highlight
tui.md.link_next
tui.md.link_next PANE
Focuses the next link of the document shown in PANE, wrapping at the end.
Notes
- The document is re-rendered with the focus style (class
link_focus) and the view scrolls to the link.
Example
tui.md.link_next docs
tui.md.link_prev
tui.md.link_prev PANE
Focuses the previous link of the document shown in PANE, wrapping at the start.
Notes
- The document is re-rendered with the focus style (class
link_focus) and the view scrolls to the link.
Example
tui.md.link_prev docs
tui.md.link_open
tui.md.link_open PANE
Follows the focused link of the document shown in PANE. Returns 1 when no link is focused.
Notes
- The function set with
tui.md.on_linkis called first, asFN URL TEXT PANE; return0when it handled the link. #anchorscrolls to that heading (GitHub-style slug).- A relative
.mdor.md#anchorlink loads that file in the pane and calls the function set withtui.md.on_navigate. - Anything else is copied to the clipboard with a notification.
- Before a jump, the position is pushed for
tui.md.back.
Example
tui.md.link_open docs
tui.md.on_link
tui.md.on_link FN
Sets the function that tui.md.link_open calls first, as FN URL TEXT PANE.
Notes
- Return
0fromFNwhen it handled the link; any other status falls through to the default behaviour.
Example
tui.md.on_link my_link_handler
tui.md.on_navigate
tui.md.on_navigate FN
Sets the function called as FN FILE PANE after a relative .md link has loaded FILE into PANE.
Example
tui.md.on_navigate my_navigate_handler
tui.md.back
tui.md.back PANE
Returns PANE to the document and scroll position before the last followed link or anchor.
Returns: 1 when there is nothing to go back to.
Notes
- Each pane keeps its own stack.
Example
tui.md.back docs
tui.md.search
tui.md.search PANE TEXT
Searches the rendered document in PANE for TEXT, case-insensitively as plain text.
Parameters
TEXT: the text to find; an emptyTEXTclears the search.
Returns: 1 when there is no match.
Notes
- Every match is drawn in reverse video and the view jumps to the first one.
- Step through the matches with
tui.md.search_nextandtui.md.search_prev;tui.md.search_inforeports the position.
Example
tui.md.search docs "config key"
tui.md.search_next
tui.md.search_next PANE
Jumps to the next match of the search in PANE, wrapping at the end.
Example
tui.md.search_next docs
tui.md.search_prev
tui.md.search_prev PANE
Jumps to the previous match of the search in PANE, wrapping at the start.
Example
tui.md.search_prev docs
tui.md.search_info
tui.md.search_info PANE VAR
Stores in VAR the search state of PANE: 3/12, no match, or an empty string when no search is set.
Parameters
VAR: the name of the variable that receives the text.
Example
tui.md.search_info docs info # info="3/12"
tui.md.outline_choose
tui.md.outline_choose PANE
Opens a list (tui.choose) of the headings of the document shown in PANE, indented by level; choosing one scrolls the pane to its top.
Example
tui.md.outline_choose docs
tui.md.fold_toggle
tui.md.fold_toggle PANE [HEADING]
Folds or unfolds the section under a heading of the document shown in PANE.
Parameters
HEADING: the index of the heading inTUI_MD_HEADSorder. Default: the heading at the top of the view.
Notes
- A folded section shows a
▸ N rows foldedline in its place.
Example
tui.md.fold_toggle docs 2
tui.md.copy
tui.md.copy PANE [doc|section|rendered]
Copies part of the document shown in PANE to the clipboard with tui.clipboard.copy, and notifies.
Parameters
doc|section|rendered:doccopies the document source,sectionthe source of the section at the top of the view (default),renderedthe rendered plain text.
Example
tui.md.copy docs doc
tui.md.forward
tui.md.forward PANE
Goes forward in PANE’s document history after tui.md.back: the document (and scroll position) the last back stepped over. Following a link starts a new trail and drops what was ahead.
Notes
- Returns 1 when there is nothing ahead.
- Default keys:
alt+right(while the pane has the keyboard) and the forward thumb button of the mouse.
Example
tui.bind alt+n "tui.md.forward docs" --always
tui.md.search_prompt
tui.md.search_prompt PANE
Asks for a search text in a prompt, then runs tui.md.search on PANE with it. An empty text clears the search; the match shown (3/12) or No match is announced as a notification.
Example
tui.bind alt+s "tui.md.search_prompt docs" --always
tui.md.keys
tui.md.keys PANE reader|chords|none
Chooses which default Markdown keys act on PANE (<markdown keys="..."/> does the same in markup).
Parameters
reader: the alt chords and the plain reading keys:nNnext / previous link,Enterfollow,b/Backspaceback,/search,][next / previous match,ooutline,zfold,y/Ycopy section / document,gGtop / bottom. Plain keys act only while the pane has the keyboard (click it or pressf6), so they never take keys from a text box.chords(the default): only the alt chords (alt+j,alt+k,alt+l,alt+b,alt+left/alt+right(back / forward) and the thumb buttons,alt+s,alt+g,alt+h,alt+o,alt+z,alt+y,alt+u).none: no default Markdown key acts on the pane.
Notes
- A key acts on the keyboard pane, else the pane under the pointer, else the pane of the focused widget, else the only (or last shown) Markdown pane.
f2lists the keys. - The keys are the
markdownandmarkdown_readerdefault groups:tui.defaults.off markdown_readerremoves the plain ones everywhere. Your owntui.bindalways wins. - Returns 1 for another mode.
Example
tui.md.keys docs reader
tui.md.click
tui.md.click PANE X Y
Follows the link drawn under the screen cell X,Y of PANE, exactly like focusing it and calling tui.md.link_open. A left click on a link in a Markdown pane does this by itself.
Notes
- Returns 1 when the cell is not on a link (the click is then an ordinary click on the pane).
- Links that wrap onto the next row are followed from either row.
Example
tui.md.click docs "$TUI_EVENT_X" "$TUI_EVENT_Y"
tui.action.md_keys
tui.action.md_keys
Opens a scrollable list of the Markdown reading commands (links, back, search, outline, folds, copy) with the keys bound to them right now: the defaults and the app’s own binds. A command without a key shows -. Bound to f2 by default, and listed in the command palette as “Help: Markdown reading keybinds”.
