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