// // Header file for miniature markdown library. // // https://www.msweet.org/mmd // // Copyright © 2017-2024 by Michael R Sweet. // // Licensed under Apache License v2.0. See the file "LICENSE" for more // information. // #ifndef MMD_H # define MMD_H # include # include # ifdef __cplusplus extern "C" { # endif // __cplusplus // // Constants... // enum mmd_option_e { MMD_OPTION_NONE = 0x00, // No markdown extensions MMD_OPTION_METADATA = 0x01, // Jekyll metadata extension MMD_OPTION_TABLES = 0x02, // Github table extension MMD_OPTION_TASKS = 0x04, // Github task item extension (check boxes) MMD_OPTION_ALL = 0x07 // All supported markdown extensions }; typedef unsigned mmd_option_t; typedef enum mmd_type_e { MMD_TYPE_NONE = -1, MMD_TYPE_DOCUMENT, // The document root MMD_TYPE_METADATA, // Document metadata MMD_TYPE_BLOCK_QUOTE, //
MMD_TYPE_ORDERED_LIST, //
    MMD_TYPE_UNORDERED_LIST, //
      MMD_TYPE_LIST_ITEM, //
    • MMD_TYPE_TABLE, // MMD_TYPE_TABLE_HEADER, // MMD_TYPE_TABLE_BODY, // MMD_TYPE_TABLE_ROW, // MMD_TYPE_HEADING_1 = 10, //

      MMD_TYPE_HEADING_2, //

      MMD_TYPE_HEADING_3, //

      MMD_TYPE_HEADING_4, //

      MMD_TYPE_HEADING_5, //

      MMD_TYPE_HEADING_6, //
      MMD_TYPE_PARAGRAPH, //

      MMD_TYPE_CODE_BLOCK, //

      
        MMD_TYPE_THEMATIC_BREAK,		// 
      MMD_TYPE_TABLE_HEADER_CELL, //
      MMD_TYPE_TABLE_BODY_CELL_LEFT, // MMD_TYPE_TABLE_BODY_CELL_CENTER, // MMD_TYPE_TABLE_BODY_CELL_RIGHT, // MMD_TYPE_NORMAL_TEXT = 100, // Normal text MMD_TYPE_EMPHASIZED_TEXT, // text MMD_TYPE_STRONG_TEXT, // text MMD_TYPE_STRUCK_TEXT, // text MMD_TYPE_LINKED_TEXT, // text MMD_TYPE_CODE_TEXT, // text MMD_TYPE_IMAGE, // MMD_TYPE_HARD_BREAK, //
      MMD_TYPE_SOFT_BREAK, // MMD_TYPE_METADATA_TEXT, // name: value MMD_TYPE_CHECKBOX // [ ] or [x] } mmd_type_t; // // Types... // typedef struct _mmd_s mmd_t; // Markdown node typedef size_t (*mmd_iocb_t)(void *cbdata, char *buffer, size_t bytes); // mmdLoadIO callback function // // Functions... // extern char *mmdCopyAllText(mmd_t *node); extern void mmdFree(mmd_t *node); extern const char *mmdGetExtra(mmd_t *node); extern mmd_t *mmdGetFirstChild(mmd_t *node); extern mmd_t *mmdGetLastChild(mmd_t *node); extern const char *mmdGetMetadata(mmd_t *doc, const char *keyword); extern mmd_t *mmdGetNextSibling(mmd_t *node); extern mmd_option_t mmdGetOptions(void); extern mmd_t *mmdGetParent(mmd_t *node); extern mmd_t *mmdGetPrevSibling(mmd_t *node); extern const char *mmdGetText(mmd_t *node); extern mmd_type_t mmdGetType(mmd_t *node); extern const char *mmdGetURL(mmd_t *node); extern bool mmdGetWhitespace(mmd_t *node); extern bool mmdIsBlock(mmd_t *node); extern mmd_t *mmdLoad(mmd_t *root, const char *filename); extern mmd_t *mmdLoadFile(mmd_t *root, FILE *fp); extern mmd_t *mmdLoadIO(mmd_t *root, mmd_iocb_t cb, void *cbdata); extern mmd_t *mmdLoadString(mmd_t *root, const char *s); extern void mmdSetOptions(mmd_option_t options); # ifdef __cplusplus } # endif // __cplusplus #endif // !MMD_H