markdown.renderer.diagram.block

markdown.renderer.diagram

block(renderer, source, width, opts) -> rendered

Draw a renderer's diagram fence as a block of text

Returns the picture's rows, each ended by a newline, or nil when the source gives no picture; the renderer then draws the fence as a code block. width is the columns the block may take and opts.indent the blank columns before it; the theme's diagram.block_indent is added to that. The picture stands bare, with no frame, placed in the room left by the theme's diagram.align.

The renderer gives the theme, __state.tss, and its cfg: graphics, hide_images, cell_w and cell_h.

Each run of a row is styled by the TSS element diagram.<style>, where <style> is the name the mermaid group gave it. THEMES.md lists every style, under "The diagram object".

Where cfg.graphics is set and cfg.hide_images is not, the strokes are pixels. A row then opens with a Kitty graphics command that lays its strip under the row, and the row's text is its labels. cfg.cell_w and cfg.cell_h give a cell's size in pixels; without them a cell of 10 by 20 is taken, and the terminal fits the strip to the row's cells either way. A part's fg inks its strokes, as RGB, and its fill, when the theme gives one, fills its ground.

Elsewhere the strokes are box characters, in the same rows and columns. opts.flat asks for them whatever cfg says.