libMultiMarkdown7 7.0.0-alpha.1
Lightweight markup processor to produce HTML, LaTeX, and more.
|
#include <stdint.h>
#include <stdio.h>
Go to the source code of this file.
Data Structures | |
struct | mmd_node |
Nodes are used to build the AST during parsing. More... | |
struct | mmd_line_node |
Line nodes are used specifically for parsing individual lines of text into the block structure. More... |
Macros | |
#define | MMD_OUT_FORMAT_MASK 0x1f |
Macros to extract specific options. | |
#define | MMD_SMART_QUOTE_MASK 0x01e0 |
#define | MMD_LANGUAGE_MASK 0x1E00 |
#define | MMD_OUT_FORMAT_FROM_OPTS(x) |
Extract Output format from options. | |
#define | MMD_SMART_QUOTE_FROM_OPTS(x) |
Extract Smart Quotes language from options. | |
#define | MMD_LANGUAGE_FROM_OPTS(x) |
Extract markup language from options. | |
#define | MMD_TYPE_MASK 0xc0 |
Macros to determine node class based on type value. | |
#define | MMD_TOKEN_MASK 0x80 |
#define | MMD_NODE_IS_LINE(x) |
#define | MMD_NODE_IS_BLOCK(x) |
#define | MMD_NODE_IS_TOKEN(x) |
Typedefs | |
typedef struct mmd_node | mmd_node |
typedef struct read_ctx | read_ctx |
typedef struct stack | stack |
typedef struct mmd_line_node | mmd_line_node |
Enumerations | |
enum | output_format { FORMAT_HTML , FORMAT_EPUB , FORMAT_LATEX , FORMAT_BEAMER , FORMAT_MEMOIR , FORMAT_FODT , FORMAT_ODT , FORMAT_TEXTBUNDLE , FORMAT_TEXTBUNDLE_COMPRESSED , FORMAT_OPML , FORMAT_ITMZ , FORMAT_MMD , FORMAT_HTML_WITH_ASSETS } |
enum | smart_quote_language { QUOTES_ENGLISH , QUOTES_DUTCH , QUOTES_FRENCH , QUOTES_GERMAN , QUOTES_GERMAN_GUILLEMETS , QUOTES_SPANISH , QUOTES_SWEDISH } |
enum | language { LANGUAGE_EN , LANGUAGE_ES , LANGUAGE_DE , LANGUAGE_FR , LANGUAGE_NL , LANGUAGE_SV , LANGUAGE_HE } |
enum | mmd_options { MMD_OPTION_TRANSCLUDE = 1 << 13 , MMD_OPTION_STATS = 1 << 14 , MMD_OPTION_BLOCKS_ONLY = 1 << 15 , MMD_OPTION_MMD_HEADER = 1 << 16 , MMD_OPTION_RANDOM_NOTE_ID = 1 << 17 , MMD_OPTION_RANDOM_HEADER_ID = 1 << 18 , MMD_OPTION_COMPATIBILITY = 1 << 19 , MMD_OPTION_CRITIC_ACCEPT = 1 << 20 , MMD_OPTION_CRITIC_REJECT = 1 << 21 } |
enum | node_types { LINE_ATX_1 = 1 , LINE_ATX_2 , LINE_ATX_3 , LINE_ATX_4 , LINE_ATX_5 , LINE_ATX_6 , LINE_BACKTICK , LINE_BLOCKQUOTE , LINE_CONTINUATION , LINE_DEF_ABBREVIATION , LINE_DEF_CITATION , LINE_DEF_FOOTNOTE , LINE_DEF_GLOSSARY , LINE_DEF_LINK , LINE_DEFINITION , LINE_EMPTY , LINE_FALLBACK , LINE_FENCE_BACKTICK_3 , LINE_FENCE_BACKTICK_4 , LINE_FENCE_BACKTICK_5 , LINE_FENCE_BACKTICK_START_3 , LINE_FENCE_BACKTICK_START_4 , LINE_FENCE_BACKTICK_START_5 , LINE_HR , LINE_HTML , LINE_HTML_BLOCK , LINE_HTML_BLOCKISH , LINE_HTML_BlOCKISH , LINE_INDENTED_SPACE , LINE_INDENTED_TAB , LINE_LIST_BULLETED , LINE_LIST_ENUMERATED , LINE_META , LINE_PLAIN , LINE_SETEXT_1 , LINE_SETEXT_2 , LINE_START_COMMENT , LINE_STOP_COMMENT , LINE_TABLE , LINE_TABLE_SEPARATOR , LINE_TOC , LINE_YAML , CODE_FENCE_LINE = 63 , BLOCK_BLOCKQUOTE = 64 , BLOCK_CODE_FENCED , BLOCK_CODE_INDENTED , BLOCK_DEF_ABBREVIATION , BLOCK_DEF_CITATION , BLOCK_DEF_FOOTNOTE , BLOCK_DEF_GLOSSARY , BLOCK_DEF_LINK , BLOCK_DEFINITION , BLOCK_DEFLIST , BLOCK_EMPTY , BLOCK_GENERAL , BLOCK_H1 , BLOCK_H2 , BLOCK_H3 , BLOCK_H4 , BLOCK_H5 , BLOCK_H6 , BLOCK_HEADING , BLOCK_HR , BLOCK_HTML , BLOCK_LIST_BULLETED , BLOCK_LIST_BULLETED_LOOSE , BLOCK_LIST_ENUMERATED , BLOCK_LIST_ENUMERATED_LOOSE , BLOCK_LIST_ITEM , BLOCK_LIST_ITEM_TIGHT , BLOCK_META , BLOCK_PARA , BLOCK_SETEXT_1 , BLOCK_SETEXT_2 , BLOCK_TABLE , BLOCK_TABLE_HEADER , BLOCK_TABLE_SECTION , BLOCK_TERM , BLOCK_TOC , BLOCK_FIGURE , TOKEN_EOF = 128 , TOKEN_NL , TOKEN_LINEBREAK , TOKEN_TEXT , TOKEN_TEXT_ABBREVIATION , TOKEN_TEXT_GLOSSARY , TOKEN_TEXT_WHITESPACE , TOKEN_AMPERSAND , TOKEN_AMPERSAND_LONG , TOKEN_HTML_ENTITY , TOKEN_HASH , TOKEN_STAR , TOKEN_PLUS , TOKEN_MINUS , TEXT_NUMBER_POSS_LIST , TOKEN_UL , TOKEN_COLON , TOKEN_ATX_MARKER , TOKEN_BLOCKQUOTE_MARKER , TOKEN_DEFLIST_COLON , TOKEN_LIST_MARKER , TOKEN_ABBREVIATION_MARKER , TOKEN_FOOTNOTE_MARKER , TOKEN_GLOSSARY_MARKER , TOKEN_CITATION_MARKER , TOKEN_VARIABLE_MARKER , TOKEN_BACKTICK , TOKEN_APOSTROPHE , TOKEN_QUOTE_SINGLE , TOKEN_QUOTE_DOUBLE , TOKEN_QUOTE_DOUBLE_ALT , TOKEN_ELLIPSIS , TOKEN_DASH_M , TOKEN_DASH_N , TOKEN_DASH_N_RANGE , TOKEN_PAREN_LEFT , TOKEN_PAREN_RIGHT , TOKEN_BRACKET_LEFT , TOKEN_BRACKET_RIGHT , TOKEN_ANGLE_LEFT , TOKEN_ANGLE_RIGHT , TOKEN_BRACE_LEFT , TOKEN_BRACE_RIGHT , TOKEN_PAIR_ANGLE , TOKEN_PAIR_BACKTICK , TOKEN_PAIR_BRACE , TOKEN_PAIR_BRACKET , TOKEN_PAIR_BRACKET_EMPTY , TOKEN_PAIR_BRACKET_NOT_CITED , TOKEN_PAIR_BRACKET_ABBREVIATION , TOKEN_PAIR_BRACKET_FOOTNOTE , TOKEN_PAIR_BRACKET_GLOSSARY , TOKEN_PAIR_BRACKET_CITATION , TOKEN_PAIR_BRACKET_IMAGE , TOKEN_PAIR_BRACKET_LINK , TOKEN_PAIR_BRACKET_VARIABLE , TOKEN_PAIR_PAREN , TOKEN_PAIR_QUOTE_DOUBLE , TOKEN_PAIR_QUOTE_SINGLE , TOKEN_PAIR_STAR , TOKEN_PAIR_STAR_USED , TOKEN_PAIR_UL , TOKEN_PAIR_UL_USED , TOKEN_SPECIAL_CHARACTER , TOKEN_PAIR_EMPH , TOKEN_PAIR_STRONG , TOKEN_ESCAPED_CHARACTER , TOKEN_NBSP , TOKEN_PIPE , TOKEN_CM_ADD_OPEN , TOKEN_CM_ADD_CLOSE , TOKEN_CM_DEL_OPEN , TOKEN_CM_DEL_CLOSE , TOKEN_CM_SUB_OPEN , TOKEN_CM_SUB_DIV , TOKEN_CM_SUB_CLOSE , TOKEN_CM_COM_OPEN , TOKEN_CM_COM_CLOSE , TOKEN_CM_HI_OPEN , TOKEN_CM_HI_CLOSE , TOKEN_PAIR_CM_ADD , TOKEN_PAIR_CM_DEL , TOKEN_PAIR_CM_SUB_DEL , TOKEN_PAIR_CM_SUB_ADD , TOKEN_PAIR_CM_COM , TOKEN_PAIR_CM_HI , TOKEN_SUPERSCRIPT , TOKEN_SUBSCRIPT , TOKEN_MATH_PAREN_OPEN , TOKEN_MATH_PAREN_CLOSE , TOKEN_MATH_BRACKET_OPEN , TOKEN_MATH_BRACKET_CLOSE , TOKEN_MATH_DOLLAR_SINGLE , TOKEN_MATH_DOLLAR_DOUBLE , TOKEN_PAIR_MATH_PAREN , TOKEN_PAIR_MATH_BRACKET , TOKEN_PAIR_MATH_DOLLAR_SINGLE , TOKEN_PAIR_MATH_DOLLAR_DOUBLE , TOKEN_TABLE_CELL , TOKEN_TABLE_DIVIDER , TOKEN_MANUAL_LABEL , OBJECT_REPLACEMENT_CHARACTER } |
AST node types. More... |
Functions | |
void | mmd_process_file (FILE *in, FILE *out, uint32_t options, const char *search_path, const char *source_path) |
void | mmd_process_filename (const char *fname, FILE *out, uint32_t options, const char *search_path) |
void | mmd_process_str (const char *text, FILE *out, uint32_t options, const char *search_path, const char *source_path) |
void | mmd_process_str_len (const char *text, size_t in_len, FILE *out, uint32_t options, const char *search_path, const char *source_path) |
char * | mmd_process_file_to_str (FILE *in, size_t *out_len, uint32_t options, const char *search_path, const char *source_path) |
char * | mmd_process_filename_to_str (const char *fname, size_t *out_len, uint32_t options, const char *search_path) |
char * | mmd_process_str_to_str (const char *text, size_t *out_len, uint32_t options, const char *search_path, const char *source_path) |
char * | 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) |
mmd_node * | mmd_parse_file (FILE *in, read_ctx *c, uint32_t options) |
mmd_node * | mmd_parse_filename (const char *filename, read_ctx *c, uint32_t options) |
mmd_node * | mmd_parse_str (const char *text, read_ctx *c, uint32_t options) |
mmd_node * | mmd_parse_str_len (const char *text, size_t in_len, read_ctx *c, uint32_t options) |
void | mmd_ast_file (FILE *in, FILE *out, uint32_t options) |
void | mmd_ast_filename (const char *fname, FILE *out, uint32_t options) |
void | mmd_ast_str (const char *text, FILE *out, uint32_t options) |
void | mmd_ast_str_len (const char *text, size_t in_len, FILE *out, uint32_t options) |
read_ctx * | mmd_metadata_filename (const char *fname, uint32_t options) |
read_ctx * | mmd_metadata_file (FILE *in, uint32_t options) |
read_ctx * | mmd_metadata_str (const char *text, uint32_t options) |
read_ctx * | mmd_metadata_str_len (const char *text, size_t in_len, uint32_t options) |
void | mmd_node_free (mmd_node *n) |
Utility functions. | |
void | mmd_node_tree_free (mmd_node *n) |
uint32_t | mmd_hash_node_tree (mmd_node *n) |
Calculate hash values for AST (and return overall hash value) | |
uint32_t | mmd_hash_node (mmd_node *n) |
Calculate hash value for individual node (and it's children) | |
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 | |
void | read_ctx_reset (read_ctx *c, uint32_t options) |
void | read_ctx_free (read_ctx *c) |
void | custom_seed_rand (void) |
libMultiMarkdown7 – Lightweight markup processor to produce HTML, LaTeX, and more.
Definition in file libMultiMarkdown.h.
#define MMD_LANGUAGE_FROM_OPTS | ( | x | ) |
Extract markup language from options.
Definition at line 190 of file libMultiMarkdown.h.
#define MMD_LANGUAGE_MASK 0x1E00 |
Definition at line 181 of file libMultiMarkdown.h.
#define MMD_NODE_IS_BLOCK | ( | x | ) |
Definition at line 225 of file libMultiMarkdown.h.
#define MMD_NODE_IS_LINE | ( | x | ) |
Definition at line 224 of file libMultiMarkdown.h.
#define MMD_NODE_IS_TOKEN | ( | x | ) |
Definition at line 226 of file libMultiMarkdown.h.
#define MMD_OUT_FORMAT_FROM_OPTS | ( | x | ) |
Extract Output format from options.
Definition at line 184 of file libMultiMarkdown.h.
#define MMD_OUT_FORMAT_MASK 0x1f |
Macros to extract specific options.
Definition at line 179 of file libMultiMarkdown.h.
#define MMD_SMART_QUOTE_FROM_OPTS | ( | x | ) |
Extract Smart Quotes language from options.
Definition at line 187 of file libMultiMarkdown.h.
#define MMD_SMART_QUOTE_MASK 0x01e0 |
Definition at line 180 of file libMultiMarkdown.h.
#define MMD_TOKEN_MASK 0x80 |
Definition at line 222 of file libMultiMarkdown.h.
#define MMD_TYPE_MASK 0xc0 |
Macros to determine node class based on type value.
Definition at line 221 of file libMultiMarkdown.h.
typedef struct mmd_line_node mmd_line_node |
Definition at line 217 of file libMultiMarkdown.h.
typedef struct mmd_node mmd_node |
Definition at line 50 of file libMultiMarkdown.h.
typedef struct read_ctx read_ctx |
Definition at line 51 of file libMultiMarkdown.h.
typedef struct stack stack |
Definition at line 52 of file libMultiMarkdown.h.
enum language |
Definition at line 151 of file libMultiMarkdown.h.
enum mmd_options |
Definition at line 162 of file libMultiMarkdown.h.
enum node_types |
AST node types.
Definition at line 230 of file libMultiMarkdown.h.
enum output_format |
Enumerator | |
---|---|
FORMAT_HTML | Plain HTML. |
FORMAT_LATEX | LaTeX to generate PDF. |
FORMAT_MMD | Raw MultiMarkdown source text. |
Definition at line 123 of file libMultiMarkdown.h.
enum smart_quote_language |
Definition at line 140 of file libMultiMarkdown.h.
void mmd_ast_file | ( | FILE * | in, |
FILE * | out, | ||
uint32_t | options ) |
Process MultiMarkdown text into AST and output a description to the specified file stream TODO: Add this to test suite for regression testing
read_ctx * mmd_metadata_filename | ( | const char * | fname, |
uint32_t | options ) |
Process MultiMarkdown text for metadata read_ctx will need to be freed when finished TODO: Make metadata extraction API simpler
mmd_node * mmd_parse_file | ( | FILE * | in, |
read_ctx * | c, | ||
uint32_t | options ) |
Parse MultiMarkdown text into AST Returns a tree of mmd_nodes that will need to be freed read_ctx will be updated to contain structured information from the parse necessary to create a full document (e.g. metadata, link definitions, etc.) After parsing, you should not need to parse the original text again, though you may have to grab certain character ranges
void mmd_process_file | ( | FILE * | in, |
FILE * | out, | ||
uint32_t | options, | ||
const char * | search_path, | ||
const char * | source_path ) |
Process MultiMarkdown text into another format Output is sent to designated file stream (e.g. stdout) search_path and source_path are used for file transclusion, can be nil to disable
char * mmd_process_file_to_str | ( | FILE * | in, |
size_t * | out_len, | ||
uint32_t | options, | ||
const char * | search_path, | ||
const char * | source_path ) |
Returns text string (or binary data) – will need to be freed Length of output will be stored in out_len (especially needed for binary data formats)