index.d.ts 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323
  1. import type {Info, State} from './lib/types.js'
  2. /**
  3. * Interface of registered constructs.
  4. *
  5. * When working on extensions that use new constructs, extend the corresponding
  6. * interface to register its name:
  7. *
  8. * ```ts
  9. * declare module 'mdast-util-to-markdown' {
  10. * interface ConstructNameMap {
  11. * // Register a new construct name (value is used, key should match it).
  12. * gfmStrikethrough: 'gfmStrikethrough'
  13. * }
  14. * }
  15. * ```
  16. */
  17. export interface ConstructNameMap {
  18. /**
  19. * Whole autolink.
  20. *
  21. * ```markdown
  22. * > | <https://example.com> and <admin@example.com>
  23. * ^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^
  24. * ```
  25. */
  26. autolink: 'autolink'
  27. /**
  28. * Whole block quote.
  29. *
  30. * ```markdown
  31. * > | > a
  32. * ^^^
  33. * > | b
  34. * ^
  35. * ```
  36. */
  37. blockquote: 'blockquote'
  38. /**
  39. * Whole code (indented).
  40. *
  41. * ```markdown
  42. * ␠␠␠␠console.log(1)
  43. * ^^^^^^^^^^^^^^^^^^
  44. * ```
  45. */
  46. codeIndented: 'codeIndented'
  47. /**
  48. * Whole code (fenced).
  49. *
  50. * ````markdown
  51. * > | ```js
  52. * ^^^^^
  53. * > | console.log(1)
  54. * ^^^^^^^^^^^^^^
  55. * > | ```
  56. * ^^^
  57. * ````
  58. */
  59. codeFenced: 'codeFenced'
  60. /**
  61. * Code (fenced) language, when fenced with grave accents.
  62. *
  63. * ````markdown
  64. * > | ```js
  65. * ^^
  66. * | console.log(1)
  67. * | ```
  68. * ````
  69. */
  70. codeFencedLangGraveAccent: 'codeFencedLangGraveAccent'
  71. /**
  72. * Code (fenced) language, when fenced with tildes.
  73. *
  74. * ````markdown
  75. * > | ~~~js
  76. * ^^
  77. * | console.log(1)
  78. * | ~~~
  79. * ````
  80. */
  81. codeFencedLangTilde: 'codeFencedLangTilde'
  82. /**
  83. * Code (fenced) meta string, when fenced with grave accents.
  84. *
  85. * ````markdown
  86. * > | ```js eval
  87. * ^^^^
  88. * | console.log(1)
  89. * | ```
  90. * ````
  91. */
  92. codeFencedMetaGraveAccent: 'codeFencedMetaGraveAccent'
  93. /**
  94. * Code (fenced) meta string, when fenced with tildes.
  95. *
  96. * ````markdown
  97. * > | ~~~js eval
  98. * ^^^^
  99. * | console.log(1)
  100. * | ~~~
  101. * ````
  102. */
  103. codeFencedMetaTilde: 'codeFencedMetaTilde'
  104. /**
  105. * Whole definition.
  106. *
  107. * ```markdown
  108. * > | [a]: b "c"
  109. * ^^^^^^^^^^
  110. * ```
  111. */
  112. definition: 'definition'
  113. /**
  114. * Destination (literal) (occurs in definition, image, link).
  115. *
  116. * ```markdown
  117. * > | [a]: <b> "c"
  118. * ^^^
  119. * > | a ![b](<c> "d") e
  120. * ^^^
  121. * ```
  122. */
  123. destinationLiteral: 'destinationLiteral'
  124. /**
  125. * Destination (raw) (occurs in definition, image, link).
  126. *
  127. * ```markdown
  128. * > | [a]: b "c"
  129. * ^
  130. * > | a ![b](c "d") e
  131. * ^
  132. * ```
  133. */
  134. destinationRaw: 'destinationRaw'
  135. /**
  136. * Emphasis.
  137. *
  138. * ```markdown
  139. * > | *a*
  140. * ^^^
  141. * ```
  142. */
  143. emphasis: 'emphasis'
  144. /**
  145. * Whole heading (atx).
  146. *
  147. * ```markdown
  148. * > | # alpha
  149. * ^^^^^^^
  150. * ```
  151. */
  152. headingAtx: 'headingAtx'
  153. /**
  154. * Whole heading (setext).
  155. *
  156. * ```markdown
  157. * > | alpha
  158. * ^^^^^
  159. * > | =====
  160. * ^^^^^
  161. * ```
  162. */
  163. headingSetext: 'headingSetext'
  164. /**
  165. * Whole image.
  166. *
  167. * ```markdown
  168. * > | ![a](b)
  169. * ^^^^^^^
  170. * > | ![c]
  171. * ^^^^
  172. * ```
  173. */
  174. image: 'image'
  175. /**
  176. * Whole image reference.
  177. *
  178. * ```markdown
  179. * > | ![a]
  180. * ^^^^
  181. * ```
  182. */
  183. imageReference: 'imageReference'
  184. /**
  185. * Label (occurs in definitions, image reference, image, link reference,
  186. * link).
  187. *
  188. * ```markdown
  189. * > | [a]: b "c"
  190. * ^^^
  191. * > | a [b] c
  192. * ^^^
  193. * > | a ![b][c] d
  194. * ^^^^
  195. * > | a [b](c) d
  196. * ^^^
  197. * ```
  198. */
  199. label: 'label'
  200. /**
  201. * Whole link.
  202. *
  203. * ```markdown
  204. * > | [a](b)
  205. * ^^^^^^
  206. * > | [c]
  207. * ^^^
  208. * ```
  209. */
  210. link: 'link'
  211. /**
  212. * Whole link reference.
  213. *
  214. * ```markdown
  215. * > | [a]
  216. * ^^^
  217. * ```
  218. */
  219. linkReference: 'linkReference'
  220. /**
  221. * List.
  222. *
  223. * ```markdown
  224. * > | * a
  225. * ^^^
  226. * > | 1. b
  227. * ^^^^
  228. * ```
  229. */
  230. list: 'list'
  231. /**
  232. * List item.
  233. *
  234. * ```markdown
  235. * > | * a
  236. * ^^^
  237. * > | 1. b
  238. * ^^^^
  239. * ```
  240. */
  241. listItem: 'listItem'
  242. /**
  243. * Paragraph.
  244. *
  245. * ```markdown
  246. * > | a b
  247. * ^^^
  248. * > | c.
  249. * ^^
  250. * ```
  251. */
  252. paragraph: 'paragraph'
  253. /**
  254. * Phrasing (occurs in headings, paragraphs, etc).
  255. *
  256. * ```markdown
  257. * > | a
  258. * ^
  259. * ```
  260. */
  261. phrasing: 'phrasing'
  262. /**
  263. * Reference (occurs in image, link).
  264. *
  265. * ```markdown
  266. * > | [a][]
  267. * ^^
  268. * ```
  269. */
  270. reference: 'reference'
  271. /**
  272. * Strong.
  273. *
  274. * ```markdown
  275. * > | **a**
  276. * ^^^^^
  277. * ```
  278. */
  279. strong: 'strong'
  280. /**
  281. * Title using single quotes (occurs in definition, image, link).
  282. *
  283. * ```markdown
  284. * > | [a](b 'c')
  285. * ^^^
  286. * ```
  287. */
  288. titleApostrophe: 'titleApostrophe'
  289. /**
  290. * Title using double quotes (occurs in definition, image, link).
  291. *
  292. * ```markdown
  293. * > | [a](b "c")
  294. * ^^^
  295. * ```
  296. */
  297. titleQuote: 'titleQuote'
  298. }
  299. /**
  300. * Construct names for things generated by `mdast-util-to-markdown`.
  301. *
  302. * This is an enum of strings, each being a semantic label, useful to know when
  303. * serializing whether we’re for example in a double (`"`) or single (`'`)
  304. * quoted title.
  305. */
  306. export type ConstructName = ConstructNameMap[keyof ConstructNameMap]
  307. export {toMarkdown} from './lib/index.js'
  308. export {handle as defaultHandlers} from './lib/handle/index.js'
  309. export type {
  310. Handle,
  311. Handlers,
  312. Info,
  313. Join,
  314. Map,
  315. Options,
  316. SafeConfig,
  317. State,
  318. Tracker,
  319. Unsafe
  320. } from './lib/types.js'