62#ifndef libMultiMarkdown7_H
63#define libMultiMarkdown7_H
71typedef struct read_ctx read_ctx;
72typedef struct stack stack;
78void mmd_process_file(FILE * in, FILE * out, uint32_t options,
const char * search_path,
const char * source_path);
79void mmd_process_filename(
const char * fname, FILE * out, uint32_t options,
const char * search_path);
80void mmd_process_str(
const char * text, FILE * out, uint32_t options,
const char * search_path,
const char * source_path);
81void mmd_process_str_len(
const char * text,
size_t in_len, FILE * out, uint32_t options,
const char * search_path,
const char * source_path);
86char *
mmd_process_file_to_str(FILE * in,
size_t * out_len, uint32_t options,
const char * search_path,
const char * source_path);
87char * mmd_process_filename_to_str(
const char * fname,
size_t * out_len, uint32_t options,
const char * search_path);
88char * mmd_process_str_to_str(
const char * text,
size_t * out_len, uint32_t options,
const char * search_path,
const char * source_path);
89char * mmd_process_str_len_to_str(
const char * text,
size_t in_len,
size_t * out_len, uint32_t options,
const char * search_path,
const char * source_path);
99mmd_node * mmd_parse_filename(
const char * filename, read_ctx * c, uint32_t options);
100mmd_node * mmd_parse_str(
const char * text, read_ctx * c, uint32_t options);
101mmd_node * mmd_parse_str_len(
const char * text,
size_t in_len, read_ctx * c, uint32_t options);
107void mmd_ast_filename(
const char * fname, FILE * out, uint32_t options);
108void mmd_ast_str(
const char * text, FILE * out, uint32_t options);
109void mmd_ast_str_len(
const char * text,
size_t in_len, FILE * out, uint32_t options);
116void mmd_hash_filename(
const char * fname, FILE * out, uint32_t options);
117void mmd_hash_str(
const char * text, FILE * out, uint32_t options);
118void mmd_hash_str_len(
const char * text,
size_t in_len, FILE * out, uint32_t options);
125read_ctx * mmd_metadata_file(FILE * in, uint32_t options);
126read_ctx * mmd_metadata_str(
const char * text, uint32_t options);
127read_ctx * mmd_metadata_str_len(
const char * text,
size_t in_len, uint32_t options);
133void mmd_node_tree_free(
mmd_node * n);
145void read_ctx_reset(read_ctx * c, uint32_t options);
146void read_ctx_free(read_ctx * c);
148void custom_seed_rand(
void);
217#define MMD_OUT_FORMAT_MASK 0x1f
218#define MMD_SMART_QUOTE_MASK 0x01e0
219#define MMD_LANGUAGE_MASK 0x1E00
222#define MMD_OUT_FORMAT_FROM_OPTS(x) ((x & MMD_OUT_FORMAT_MASK) >> 0)
225#define MMD_SMART_QUOTE_FROM_OPTS(x) ((x & MMD_SMART_QUOTE_MASK) >> 5)
228#define MMD_LANGUAGE_FROM_OPTS(x) ((x & MMD_LANGUAGE_MASK) >> 9)
259#define MMD_TYPE_MASK 0xc0
260#define MMD_TOKEN_MASK 0x80
262#define MMD_NODE_IS_LINE(x) ((((mmd_node*)x)->type & MMD_TYPE_MASK) == 0x00)
263#define MMD_NODE_IS_BLOCK(x) ((((mmd_node*)x)->type & MMD_TYPE_MASK) == 0x40)
264#define MMD_NODE_IS_TOKEN(x) ((((mmd_node*)x)->type & MMD_TOKEN_MASK) == 0x80)
279 LINE_DEF_ABBREVIATION,
287 LINE_FENCE_BACKTICK_3,
288 LINE_FENCE_BACKTICK_4,
289 LINE_FENCE_BACKTICK_5,
290 LINE_FENCE_BACKTICK_START_3,
291 LINE_FENCE_BACKTICK_START_4,
292 LINE_FENCE_BACKTICK_START_5,
300 LINE_LIST_ENUMERATED,
308 LINE_TABLE_SEPARATOR,
312 CODE_FENCE_LINE = 63,
316 BLOCK_BLOCKQUOTE = 64,
319 BLOCK_DEF_ABBREVIATION,
338 BLOCK_LIST_BULLETED_LOOSE,
339 BLOCK_LIST_ENUMERATED,
340 BLOCK_LIST_ENUMERATED_LOOSE,
342 BLOCK_LIST_ITEM_TIGHT,
351 BLOCK_TABLE_SEPARATOR,
362 TOKEN_TEXT_ABBREVIATION,
364 TOKEN_TEXT_WHITESPACE,
367 TOKEN_AMPERSAND_LONG,
376 TEXT_NUMBER_POSS_LIST,
382 TOKEN_BLOCKQUOTE_MARKER,
385 TOKEN_ABBREVIATION_MARKER,
386 TOKEN_FOOTNOTE_MARKER,
387 TOKEN_GLOSSARY_MARKER,
388 TOKEN_CITATION_MARKER,
389 TOKEN_VARIABLE_MARKER,
395 TOKEN_QUOTE_DOUBLE_ALT,
414 TOKEN_PAIR_BRACKET_EMPTY,
415 TOKEN_PAIR_BRACKET_NOT_CITED,
416 TOKEN_PAIR_BRACKET_ABBREVIATION,
417 TOKEN_PAIR_BRACKET_FOOTNOTE,
418 TOKEN_PAIR_BRACKET_GLOSSARY,
419 TOKEN_PAIR_BRACKET_CITATION,
420 TOKEN_PAIR_BRACKET_IMAGE,
421 TOKEN_PAIR_BRACKET_LINK,
422 TOKEN_PAIR_BRACKET_VARIABLE,
424 TOKEN_PAIR_QUOTE_DOUBLE,
425 TOKEN_PAIR_QUOTE_SINGLE,
430 TOKEN_SPECIAL_CHARACTER,
435 TOKEN_ESCAPED_CHARACTER,
453 TOKEN_PAIR_CM_SUB_DEL,
454 TOKEN_PAIR_CM_SUB_ADD,
461 TOKEN_PAIR_SUPERSCRIPT,
462 TOKEN_PAIR_SUBSCRIPT,
464 TOKEN_MATH_PAREN_OPEN,
465 TOKEN_MATH_PAREN_CLOSE,
466 TOKEN_MATH_BRACKET_OPEN,
467 TOKEN_MATH_BRACKET_CLOSE,
468 TOKEN_MATH_DOLLAR_SINGLE,
469 TOKEN_MATH_DOLLAR_DOUBLE,
471 TOKEN_PAIR_MATH_PAREN,
472 TOKEN_PAIR_MATH_BRACKET,
473 TOKEN_PAIR_MATH_DOLLAR_SINGLE,
474 TOKEN_PAIR_MATH_DOLLAR_DOUBLE,
481 OBJECT_REPLACEMENT_CHARACTER,
485void read_ctx_dump_headers(read_ctx * c);
char * mmd_process_file_to_str(FILE *in, size_t *out_len, uint32_t options, const char *search_path, const char *source_path)
void mmd_process_file(FILE *in, FILE *out, uint32_t options, const char *search_path, const char *source_path)
@ MMD_OPTION_CRITIC_REJECT
Reject all proposed changes.
@ MMD_OPTION_RANDOM_NOTE_ID
Use random footnote id # to avoid collisions.
@ MMD_OPTION_PARSE_OPML
Convert from OPML to MMD text before parsing.
@ MMD_OPTION_EMBED_ASSETS
Embed assets (imagees, CSS) within the output file itself (eg. HTML)
@ MMD_OPTION_TRANSCLUDE
Enable file transclusion.
@ MMD_OPTION_MMD_HEADER
Enable use of mmd header and mmd footer metadata.
@ MMD_OPTION_COMPATIBILITY
Limit functionality to core Markdown features.
@ MMD_OPTION_STORE_ASSETS
Store assets (images, CSS) within archive file formats.
@ MMD_OPTION_DOWNLOAD_ASSETS
Attempt to download assets from the internet for storage.
@ MMD_OPTION_COMPLETE
Force creation of complete document.
@ MMD_OPTION_BLOCKS_ONLY
Process block-level tokens only; do not parse inside the blocks.
@ MMD_OPTION_RANDOM_HEADER_ID
Use random header id # to avoid collisions.
@ MMD_OPTION_STATS
Display performance stats on stderr.
@ MMD_OPTION_SNIPPET
Force creation of snippet instead of complete document.
@ MMD_OPTION_CRITIC_ACCEPT
Accept all proposed changes.
@ MMD_OPTION_PARSE_ITMZ
Convert from ITMZ to MMD text before parsing.
void mmd_node_free(mmd_node *n)
Utility functions.
void mmd_ast_file(FILE *in, FILE *out, uint32_t options)
void mmd_hash_file(FILE *in, FILE *out, uint32_t options)
mmd_node * mmd_parse_file(FILE *in, read_ctx *c, uint32_t options)
void mmd_node_tree_describe_hash(mmd_node *n, FILE *out)
Print node tree hash values to designated file stream.
read_ctx * read_ctx_new(uint32_t options)
read_ctx management
@ LANGUAGE_SV
Swedish language markup.
@ LANGUAGE_DE
German language markup.
@ LANGUAGE_NL
Dutch language markup.
@ LANGUAGE_ES
Spanish language markup.
@ LANGUAGE_EN
English language markup.
@ LANGUAGE_HE
Hebrew language markup.
@ LANGUAGE_FR
French language markup.
uint32_t mmd_hash_node(mmd_node *n)
Calculate hash value for individual node (and it's children)
node_types
AST node types.
@ TOKEN_PAIR_STAR_USED
Must immediately follow TOKEN_PAIR_STAR.
@ TOKEN_PAIR_UL_USED
Must immediately follow TOKEN_PAIR_UL.
uint32_t mmd_hash_node_tree(mmd_node *n)
Calculate hash values for AST (and return overall hash value)
@ QUOTES_DUTCH
Dutch smart quotes.
@ QUOTES_ENGLISH
English smart quotes.
@ QUOTES_GERMAN_GUILLEMETS
German guillemets smart quotes.
@ QUOTES_FRENCH
French smart quotes.
@ QUOTES_GERMAN
German smart quotes.
@ QUOTES_SWEDISH
Swedish smart quotes.
@ QUOTES_SPANISH
Spanish smart quotes.
@ FORMAT_AST
Display the AST for informational/debugging purposes.
@ FORMAT_LATEX
LaTeX to generate PDF.
@ FORMAT_OPML
Outline Processor Markup Language for outliners or mind-mapping programs.
@ FORMAT_MMD
Raw MultiMarkdown source text.
@ FORMAT_TEXTBUNDLE
TextBundle is a package file format for macOS/iOS.
@ FORMAT_HASH
Display the AST with hash values for informational/debugging purposes.
@ FORMAT_TEXTPACK
Compressed variant of the TextBundle file format.
@ FORMAT_ITMZ
iThoughts Mind Mapping document
read_ctx * mmd_metadata_filename(const char *fname, uint32_t options)
Line nodes are used specifically for parsing individual lines of text into the block structure.
mmd_node general
mmd_line_node starts with regular mmd_node
size_t c_start
Starting offset (in bytes) for line content (excluding line level markup)
size_t c_len
Byte length for content of the line (excluding line level markup)
Nodes are used to build the AST during parsing.
size_t start
Starting offset (in bytes) in the source text for this node.
struct mmd_node * content
If node was parsed into span-level content, place it here.
struct mmd_node * next
Pointer to next node in the AST.
struct mmd_node * tail
Pointer to last sibling node in the AST.
size_t len
Byte length in the source text for this node.
unsigned char type
type for this node
struct mmd_node * child
Pointer to first child node in the AST.
uint32_t hash
hash for the node, useful when comparing two parse trees for similar branches