std1.0.0-beta-7 SafeC docs

std :: serial::markdown

Struct std::MdNode

#include <std/serial/markdown.h> source

struct MdNode {
    int kind;
    int level;
    int ordered;
    int start;
    int tight;
    int align;
    int header;
    struct String text;
    struct String info;
    struct String id;
    struct String title;
    struct Vec<&heap MdNode> children;
}

Fields

§int kindsource
§int levelsource

MD_HEADING: 1-6

§int orderedsource

MD_LIST: 1 = ordered, 0 = bullet

§int startsource

MD_LIST (ordered): the first item's number

§int tightsource

MD_LIST: 1 if no blank lines separate items/blocks (no <p> in items)

§int alignsource

MD_TABLE_CELL: MD_ALIGN_*

§int headersource

MD_TABLE_ROW / MD_TABLE_CELL: part of the header row

§struct String textsource

MD_TEXT/MD_CODE_SPAN/MD_CODE_BLOCK/MD_HTML_*: content; MD_LINK/MD_IMAGE: URL

§struct String infosource

MD_CODE_BLOCK: info string ("c", "bash"); MD_CONTAINER: kind

§struct String idsource

MD_HEADING: id (heading_ids option), else empty

§struct String titlesource

MD_LINK/MD_IMAGE: title attribute

§struct Vec<&heap MdNode> childrensource

block children, or inline children

Methods

§static &heap MdNode parse(const &char text)source · definition

Parses 'text' with every extension off (MdOptions::commonmark()) into a heap-allocated MD_DOC root node (release it with doc.free()).

§static &heap MdNode parse_opts(const &char text, const &MdOptions opts)source · definition

Parses 'text' with the given extensions.

§struct String render_html() constsource · definition

Renders this node (usually the MD_DOC root) to an HTML fragment. Text is HTML-escaped; only raw HTML nodes (html option) pass through. Headings carry their id, code blocks class="language-<info word>", containers render as <div class="custom-block KIND"> with a <p class="custom-block-title"> (the title, or KIND upper-cased), and 'details' containers as <details class="custom-block details"> with a <summary>.

§struct String render_markdown() constsource · definition

Renders this node back to Markdown text (a round-trip — not byte-identical to arbitrary input: 'x' and 'x' both come back as 'x', every list marker as '-' or 'N.').

§void plain_text(&String out) constsource · definition

Appends the node's text content — every MD_TEXT/MD_CODE_SPAN/code block below it, without markup — to 'out' (for outlines, search indexes, slugs). Hard and soft breaks become spaces.

§void drop()source · definition

Recursively frees this node's whole subtree and the node itself (every MdNode is heap-allocated by MdNode::parse) — don't use it after.

§void free() consumesource · definition

= drop()