pmh_definitions.h 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. /* PEG Markdown Highlight
  2. * Copyright 2011-2016 Ali Rantakari -- http://hasseg.org
  3. * Licensed under the GPL2+ and MIT licenses (see LICENSE for more info).
  4. *
  5. * pmh_definitions.h
  6. */
  7. #ifndef pmh_MARKDOWN_DEFINITIONS
  8. #define pmh_MARKDOWN_DEFINITIONS
  9. /** \file
  10. * \brief Global definitions for the parser.
  11. */
  12. /**
  13. * \brief Element types.
  14. *
  15. * The first (documented) ones are language element types.
  16. *
  17. * The last (non-documented) ones are utility types used
  18. * by the parser itself.
  19. *
  20. * \sa pmh_element
  21. */
  22. typedef enum
  23. {
  24. pmh_LINK, /**< Explicit link */
  25. pmh_AUTO_LINK_URL, /**< Implicit URL link */
  26. pmh_AUTO_LINK_EMAIL, /**< Implicit email link */
  27. pmh_IMAGE, /**< Image definition */
  28. pmh_CODE, /**< Code (inline) */
  29. pmh_HTML, /**< HTML */
  30. pmh_HTML_ENTITY, /**< HTML special entity definition */
  31. pmh_EMPH, /**< Emphasized text */
  32. pmh_STRONG, /**< Strong text */
  33. pmh_LIST_BULLET, /**< Bullet for an unordered list item */
  34. pmh_LIST_ENUMERATOR, /**< Enumerator for an ordered list item */
  35. pmh_COMMENT, /**< (HTML) Comment */
  36. // Code assumes that pmh_H1-6 are in order.
  37. pmh_H1, /**< Header, level 1 */
  38. pmh_H2, /**< Header, level 2 */
  39. pmh_H3, /**< Header, level 3 */
  40. pmh_H4, /**< Header, level 4 */
  41. pmh_H5, /**< Header, level 5 */
  42. pmh_H6, /**< Header, level 6 */
  43. pmh_BLOCKQUOTE, /**< Blockquote */
  44. pmh_VERBATIM, /**< Verbatim (e.g. block of code) */
  45. pmh_HTMLBLOCK, /**< Block of HTML */
  46. pmh_HRULE, /**< Horizontal rule */
  47. pmh_REFERENCE, /**< Reference */
  48. pmh_FENCEDCODEBLOCK, /**< Fenced code block */
  49. pmh_NOTE, /**< Note */
  50. pmh_STRIKE, /**< Strike-through */
  51. pmh_FRONTMATTER, /**< Front matter */
  52. pmh_DISPLAYFORMULA, /**< Math display formula */
  53. pmh_INLINEEQUATION, /**< Math inline equation */
  54. pmh_MARK, /**< HTML <mark> tag content */
  55. pmh_TABLE, /**< GFM table */
  56. pmh_TABLEHEADER, /**< GFM table header */
  57. pmh_TABLEBORDER, /**< GFM table border | */
  58. // Utility types used by the parser itself:
  59. // List of pmh_RAW element lists, each to be processed separately from
  60. // others (for each element in linked lists of this type, `children` points
  61. // to a linked list of pmh_RAW elements):
  62. pmh_RAW_LIST, /**< Internal to parser. Please ignore. */
  63. // Span marker for positions in original input to be post-processed
  64. // in a second parsing step:
  65. pmh_RAW, /**< Internal to parser. Please ignore. */
  66. // Additional text to be parsed along with spans in the original input
  67. // (these may be added to linked lists of pmh_RAW elements):
  68. pmh_EXTRA_TEXT, /**< Internal to parser. Please ignore. */
  69. // Separates linked lists of pmh_RAW elements into parts to be processed
  70. // separate from each other:
  71. pmh_SEPARATOR, /**< Internal to parser. Please ignore. */
  72. // Placeholder element used while parsing:
  73. pmh_NO_TYPE, /**< Internal to parser. Please ignore. */
  74. // Linked list of *all* elements created while parsing:
  75. pmh_ALL /**< Internal to parser. Please ignore. */
  76. } pmh_element_type;
  77. /**
  78. * \brief Number of types in pmh_element_type.
  79. * \sa pmh_element_type
  80. */
  81. #define pmh_NUM_TYPES 39
  82. /**
  83. * \brief Number of *language element* types in pmh_element_type.
  84. * \sa pmh_element_type
  85. */
  86. #define pmh_NUM_LANG_TYPES (pmh_NUM_TYPES - 6)
  87. /**
  88. * \brief A Language element occurrence.
  89. */
  90. struct pmh_Element
  91. {
  92. pmh_element_type type; /**< \brief Type of element */
  93. unsigned long pos; /**< \brief Unicode code point offset marking the
  94. beginning of this element in the
  95. input. */
  96. unsigned long end; /**< \brief Unicode code point offset marking the
  97. end of this element in the input. */
  98. struct pmh_Element *next; /**< \brief Next element in list */
  99. char *label; /**< \brief Label (for links and references) */
  100. char *address; /**< \brief Address (for links and references) */
  101. };
  102. typedef struct pmh_Element pmh_element;
  103. /**
  104. * \brief Bitfield enumeration of supported Markdown extensions.
  105. */
  106. enum pmh_extensions
  107. {
  108. pmh_EXT_NONE = 0, /**< No extensions */
  109. pmh_EXT_NOTES = (1 << 0), /**< Footnote syntax:
  110. http://pandoc.org/README.html#footnotes */
  111. pmh_EXT_STRIKE = (1 << 1), /**< Strike-through syntax:
  112. http://pandoc.org/README.html#strikeout */
  113. pmh_EXT_FRONTMATTER = (1 << 2), /**< YAML meta data */
  114. pmh_EXT_MATH = (1 << 3), /**< Math */
  115. pmh_EXT_MARK = (1 << 4), /**< HTML <mark> tag content */
  116. pmh_EXT_MATH_RAW = (1 << 5), /**< Math in format \begin and \end */
  117. pmh_EXT_TABLE = (1 << 6), /** GFM Table */
  118. };
  119. #endif