@tinta-lang/syntax 0.0.0-stage → 0.1.0-dev.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/THIRD_PARTY_NOTICES.txt +13651 -0
- package/dist/directive.d.ts +40 -0
- package/dist/editing.d.ts +46 -0
- package/dist/enrichment.d.ts +5 -0
- package/dist/expression.d.ts +26 -0
- package/dist/image-destinations.d.ts +3 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.js +10118 -0
- package/dist/parser.d.ts +40 -0
- package/dist/registry.d.ts +144 -0
- package/dist/source.d.ts +28 -0
- package/package.json +280 -3
- package/parser-provenance.json +1419 -0
- package/patches/README.md +5 -0
- package/patches/micromark.patch +84 -0
- package/vendor/@noble/hashes/LICENSE +21 -0
- package/vendor/@noble/hashes/_md.js +209 -0
- package/vendor/@noble/hashes/_u64.js +77 -0
- package/vendor/@noble/hashes/package.json +91 -0
- package/vendor/@noble/hashes/sha2.js +446 -0
- package/vendor/@noble/hashes/utils.js +687 -0
- package/vendor/character-entities/index.js +2132 -0
- package/vendor/character-entities/license +22 -0
- package/vendor/character-entities/package.json +78 -0
- package/vendor/decode-named-character-reference/index.js +19 -0
- package/vendor/decode-named-character-reference/license +22 -0
- package/vendor/decode-named-character-reference/package.json +90 -0
- package/vendor/devlop/lib/default.js +9 -0
- package/vendor/devlop/license +22 -0
- package/vendor/devlop/package.json +80 -0
- package/vendor/longest-streak/index.js +36 -0
- package/vendor/longest-streak/license +22 -0
- package/vendor/longest-streak/package.json +73 -0
- package/vendor/markdown-table/index.js +393 -0
- package/vendor/markdown-table/license +22 -0
- package/vendor/markdown-table/package.json +77 -0
- package/vendor/mdast-util-from-markdown/index.js +2 -0
- package/vendor/mdast-util-from-markdown/lib/index.js +1270 -0
- package/vendor/mdast-util-from-markdown/license +22 -0
- package/vendor/mdast-util-from-markdown/package.json +98 -0
- package/vendor/mdast-util-gfm-strikethrough/index.js +5 -0
- package/vendor/mdast-util-gfm-strikethrough/lib/index.js +133 -0
- package/vendor/mdast-util-gfm-strikethrough/license +22 -0
- package/vendor/mdast-util-gfm-strikethrough/package.json +84 -0
- package/vendor/mdast-util-gfm-table/index.js +2 -0
- package/vendor/mdast-util-gfm-table/lib/index.js +300 -0
- package/vendor/mdast-util-gfm-table/license +22 -0
- package/vendor/mdast-util-gfm-table/package.json +101 -0
- package/vendor/mdast-util-gfm-task-list-item/index.js +4 -0
- package/vendor/mdast-util-gfm-task-list-item/lib/index.js +141 -0
- package/vendor/mdast-util-gfm-task-list-item/license +22 -0
- package/vendor/mdast-util-gfm-task-list-item/package.json +90 -0
- package/vendor/mdast-util-phrasing/index.js +1 -0
- package/vendor/mdast-util-phrasing/lib/index.js +45 -0
- package/vendor/mdast-util-phrasing/license +23 -0
- package/vendor/mdast-util-phrasing/package.json +78 -0
- package/vendor/mdast-util-to-markdown/index.js +3 -0
- package/vendor/mdast-util-to-markdown/lib/configure.js +98 -0
- package/vendor/mdast-util-to-markdown/lib/handle/blockquote.js +40 -0
- package/vendor/mdast-util-to-markdown/lib/handle/break.js +41 -0
- package/vendor/mdast-util-to-markdown/lib/handle/code.js +86 -0
- package/vendor/mdast-util-to-markdown/lib/handle/definition.js +83 -0
- package/vendor/mdast-util-to-markdown/lib/handle/emphasis.js +67 -0
- package/vendor/mdast-util-to-markdown/lib/handle/heading.js +84 -0
- package/vendor/mdast-util-to-markdown/lib/handle/html.js +27 -0
- package/vendor/mdast-util-to-markdown/lib/handle/image-reference.js +78 -0
- package/vendor/mdast-util-to-markdown/lib/handle/image.js +92 -0
- package/vendor/mdast-util-to-markdown/lib/handle/index.js +45 -0
- package/vendor/mdast-util-to-markdown/lib/handle/inline-code.js +86 -0
- package/vendor/mdast-util-to-markdown/lib/handle/link-reference.js +78 -0
- package/vendor/mdast-util-to-markdown/lib/handle/link.js +129 -0
- package/vendor/mdast-util-to-markdown/lib/handle/list-item.js +73 -0
- package/vendor/mdast-util-to-markdown/lib/handle/list.js +107 -0
- package/vendor/mdast-util-to-markdown/lib/handle/paragraph.js +27 -0
- package/vendor/mdast-util-to-markdown/lib/handle/root.js +34 -0
- package/vendor/mdast-util-to-markdown/lib/handle/strong.js +67 -0
- package/vendor/mdast-util-to-markdown/lib/handle/text.js +30 -0
- package/vendor/mdast-util-to-markdown/lib/handle/thematic-break.js +27 -0
- package/vendor/mdast-util-to-markdown/lib/index.js +213 -0
- package/vendor/mdast-util-to-markdown/lib/join.js +56 -0
- package/vendor/mdast-util-to-markdown/lib/unsafe.js +160 -0
- package/vendor/mdast-util-to-markdown/lib/util/association.js +33 -0
- package/vendor/mdast-util-to-markdown/lib/util/character.js +32 -0
- package/vendor/mdast-util-to-markdown/lib/util/check-bullet-ordered.js +25 -0
- package/vendor/mdast-util-to-markdown/lib/util/check-bullet-other.js +42 -0
- package/vendor/mdast-util-to-markdown/lib/util/check-bullet.js +25 -0
- package/vendor/mdast-util-to-markdown/lib/util/check-emphasis.js +25 -0
- package/vendor/mdast-util-to-markdown/lib/util/check-fence.js +25 -0
- package/vendor/mdast-util-to-markdown/lib/util/check-list-item-indent.js +25 -0
- package/vendor/mdast-util-to-markdown/lib/util/check-quote.js +25 -0
- package/vendor/mdast-util-to-markdown/lib/util/check-rule-repetition.js +25 -0
- package/vendor/mdast-util-to-markdown/lib/util/check-rule.js +25 -0
- package/vendor/mdast-util-to-markdown/lib/util/check-strong.js +25 -0
- package/vendor/mdast-util-to-markdown/lib/util/compile-pattern.js +30 -0
- package/vendor/mdast-util-to-markdown/lib/util/container-flow.js +93 -0
- package/vendor/mdast-util-to-markdown/lib/util/container-phrasing.js +704 -0
- package/vendor/mdast-util-to-markdown/lib/util/encode-character-reference.js +11 -0
- package/vendor/mdast-util-to-markdown/lib/util/encode-info.js +82 -0
- package/vendor/mdast-util-to-markdown/lib/util/format-code-as-indented.js +27 -0
- package/vendor/mdast-util-to-markdown/lib/util/format-heading-as-setext.js +39 -0
- package/vendor/mdast-util-to-markdown/lib/util/format-link-as-autolink.js +39 -0
- package/vendor/mdast-util-to-markdown/lib/util/html-kind.js +63 -0
- package/vendor/mdast-util-to-markdown/lib/util/indent-lines.js +40 -0
- package/vendor/mdast-util-to-markdown/lib/util/pattern-in-scope.js +52 -0
- package/vendor/mdast-util-to-markdown/lib/util/safe.js +263 -0
- package/vendor/mdast-util-to-markdown/lib/util/track.js +55 -0
- package/vendor/mdast-util-to-markdown/license +22 -0
- package/vendor/mdast-util-to-markdown/package.json +88 -0
- package/vendor/mdast-util-to-string/index.js +5 -0
- package/vendor/mdast-util-to-string/lib/index.js +108 -0
- package/vendor/mdast-util-to-string/license +22 -0
- package/vendor/mdast-util-to-string/package.json +78 -0
- package/vendor/micromark/index.js +60 -0
- package/vendor/micromark/lib/compile.js +1068 -0
- package/vendor/micromark/lib/constructs.js +85 -0
- package/vendor/micromark/lib/create-tokenizer.js +615 -0
- package/vendor/micromark/lib/initialize/content.js +79 -0
- package/vendor/micromark/lib/initialize/document.js +370 -0
- package/vendor/micromark/lib/initialize/flow.js +58 -0
- package/vendor/micromark/lib/initialize/text.js +216 -0
- package/vendor/micromark/lib/parse.js +56 -0
- package/vendor/micromark/lib/postprocess.js +18 -0
- package/vendor/micromark/lib/preprocess.js +112 -0
- package/vendor/micromark/license +22 -0
- package/vendor/micromark/package.json +87 -0
- package/vendor/micromark-core-commonmark/index.js +22 -0
- package/vendor/micromark-core-commonmark/lib/attention.js +231 -0
- package/vendor/micromark-core-commonmark/lib/autolink.js +233 -0
- package/vendor/micromark-core-commonmark/lib/blank-line.js +61 -0
- package/vendor/micromark-core-commonmark/lib/block-quote.js +143 -0
- package/vendor/micromark-core-commonmark/lib/character-escape.js +64 -0
- package/vendor/micromark-core-commonmark/lib/character-reference.js +149 -0
- package/vendor/micromark-core-commonmark/lib/code-fenced.js +422 -0
- package/vendor/micromark-core-commonmark/lib/code-indented.js +159 -0
- package/vendor/micromark-core-commonmark/lib/code-text.js +225 -0
- package/vendor/micromark-core-commonmark/lib/content.js +163 -0
- package/vendor/micromark-core-commonmark/lib/definition.js +254 -0
- package/vendor/micromark-core-commonmark/lib/hard-break-escape.js +60 -0
- package/vendor/micromark-core-commonmark/lib/heading-atx.js +191 -0
- package/vendor/micromark-core-commonmark/lib/html-flow.js +827 -0
- package/vendor/micromark-core-commonmark/lib/html-text.js +678 -0
- package/vendor/micromark-core-commonmark/lib/label-end.js +561 -0
- package/vendor/micromark-core-commonmark/lib/label-start-image.js +110 -0
- package/vendor/micromark-core-commonmark/lib/label-start-link.js +63 -0
- package/vendor/micromark-core-commonmark/lib/line-ending.js +33 -0
- package/vendor/micromark-core-commonmark/lib/list.js +213 -0
- package/vendor/micromark-core-commonmark/lib/partial-non-lazy-continuation.js +61 -0
- package/vendor/micromark-core-commonmark/lib/setext-underline.js +187 -0
- package/vendor/micromark-core-commonmark/lib/thematic-break.js +102 -0
- package/vendor/micromark-core-commonmark/license +22 -0
- package/vendor/micromark-core-commonmark/package.json +62 -0
- package/vendor/micromark-extension-gfm-strikethrough/index.js +3 -0
- package/vendor/micromark-extension-gfm-strikethrough/lib/html.js +26 -0
- package/vendor/micromark-extension-gfm-strikethrough/lib/syntax.js +142 -0
- package/vendor/micromark-extension-gfm-strikethrough/license +22 -0
- package/vendor/micromark-extension-gfm-strikethrough/package.json +129 -0
- package/vendor/micromark-extension-gfm-table/index.js +2 -0
- package/vendor/micromark-extension-gfm-table/lib/edit-map.js +222 -0
- package/vendor/micromark-extension-gfm-table/lib/html.js +135 -0
- package/vendor/micromark-extension-gfm-table/lib/infer.js +52 -0
- package/vendor/micromark-extension-gfm-table/lib/syntax.js +846 -0
- package/vendor/micromark-extension-gfm-table/license +22 -0
- package/vendor/micromark-extension-gfm-table/package.json +86 -0
- package/vendor/micromark-extension-gfm-task-list-item/index.js +2 -0
- package/vendor/micromark-extension-gfm-task-list-item/lib/html.js +29 -0
- package/vendor/micromark-extension-gfm-task-list-item/lib/syntax.js +158 -0
- package/vendor/micromark-extension-gfm-task-list-item/license +22 -0
- package/vendor/micromark-extension-gfm-task-list-item/package.json +131 -0
- package/vendor/micromark-factory-destination/index.js +206 -0
- package/vendor/micromark-factory-destination/license +22 -0
- package/vendor/micromark-factory-destination/package.json +57 -0
- package/vendor/micromark-factory-label/index.js +148 -0
- package/vendor/micromark-factory-label/license +22 -0
- package/vendor/micromark-factory-label/package.json +60 -0
- package/vendor/micromark-factory-space/index.js +116 -0
- package/vendor/micromark-factory-space/license +22 -0
- package/vendor/micromark-factory-space/package.json +46 -0
- package/vendor/micromark-factory-title/index.js +158 -0
- package/vendor/micromark-factory-title/license +22 -0
- package/vendor/micromark-factory-title/package.json +58 -0
- package/vendor/micromark-factory-whitespace/index.js +44 -0
- package/vendor/micromark-factory-whitespace/license +22 -0
- package/vendor/micromark-factory-whitespace/package.json +57 -0
- package/vendor/micromark-util-character/index.js +246 -0
- package/vendor/micromark-util-character/license +22 -0
- package/vendor/micromark-util-character/package.json +57 -0
- package/vendor/micromark-util-chunked/index.js +81 -0
- package/vendor/micromark-util-chunked/license +22 -0
- package/vendor/micromark-util-chunked/package.json +57 -0
- package/vendor/micromark-util-classify-character/index.js +27 -0
- package/vendor/micromark-util-classify-character/license +22 -0
- package/vendor/micromark-util-classify-character/package.json +59 -0
- package/vendor/micromark-util-combine-extensions/index.js +143 -0
- package/vendor/micromark-util-combine-extensions/license +22 -0
- package/vendor/micromark-util-combine-extensions/package.json +52 -0
- package/vendor/micromark-util-decode-numeric-character-reference/index.js +32 -0
- package/vendor/micromark-util-decode-numeric-character-reference/license +22 -0
- package/vendor/micromark-util-decode-numeric-character-reference/package.json +59 -0
- package/vendor/micromark-util-decode-string/index.js +45 -0
- package/vendor/micromark-util-decode-string/license +22 -0
- package/vendor/micromark-util-decode-string/package.json +63 -0
- package/vendor/micromark-util-edit-map/index.js +225 -0
- package/vendor/micromark-util-edit-map/license +22 -0
- package/vendor/micromark-util-edit-map/package.json +48 -0
- package/vendor/micromark-util-encode/index.js +33 -0
- package/vendor/micromark-util-encode/license +22 -0
- package/vendor/micromark-util-encode/package.json +47 -0
- package/vendor/micromark-util-html-tag-name/index.js +93 -0
- package/vendor/micromark-util-html-tag-name/license +22 -0
- package/vendor/micromark-util-html-tag-name/package.json +47 -0
- package/vendor/micromark-util-normalize-identifier/index.js +33 -0
- package/vendor/micromark-util-normalize-identifier/license +22 -0
- package/vendor/micromark-util-normalize-identifier/package.json +58 -0
- package/vendor/micromark-util-resolve-all/index.js +32 -0
- package/vendor/micromark-util-resolve-all/license +22 -0
- package/vendor/micromark-util-resolve-all/package.json +48 -0
- package/vendor/micromark-util-sanitize-uri/index.js +107 -0
- package/vendor/micromark-util-sanitize-uri/license +22 -0
- package/vendor/micromark-util-sanitize-uri/package.json +59 -0
- package/vendor/micromark-util-subtokenize/index.js +228 -0
- package/vendor/micromark-util-subtokenize/lib/splice-buffer.js +251 -0
- package/vendor/micromark-util-subtokenize/license +22 -0
- package/vendor/micromark-util-subtokenize/package.json +60 -0
- package/vendor/unist-util-is/index.js +7 -0
- package/vendor/unist-util-is/lib/index.js +296 -0
- package/vendor/unist-util-is/license +22 -0
- package/vendor/unist-util-is/package.json +103 -0
- package/vendor/unist-util-stringify-position/index.js +1 -0
- package/vendor/unist-util-stringify-position/lib/index.js +84 -0
- package/vendor/unist-util-stringify-position/license +22 -0
- package/vendor/unist-util-stringify-position/package.json +80 -0
- package/vendor/unist-util-visit/index.js +2 -0
- package/vendor/unist-util-visit/lib/index.js +312 -0
- package/vendor/unist-util-visit/license +22 -0
- package/vendor/unist-util-visit/package.json +108 -0
- package/vendor/unist-util-visit-parents/index.js +2 -0
- package/vendor/unist-util-visit-parents/lib/color.js +7 -0
- package/vendor/unist-util-visit-parents/lib/index.js +399 -0
- package/vendor/unist-util-visit-parents/license +22 -0
- package/vendor/unist-util-visit-parents/package.json +106 -0
- package/vendor/zwitch/index.js +118 -0
- package/vendor/zwitch/license +22 -0
- package/vendor/zwitch/package.json +72 -0
- package/README.md +0 -3
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "micromark-factory-destination",
|
|
3
|
+
"version": "2.0.1",
|
|
4
|
+
"description": "micromark factory to parse destinations (found in resources, definitions)",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"keywords": [
|
|
7
|
+
"micromark",
|
|
8
|
+
"factory",
|
|
9
|
+
"destination"
|
|
10
|
+
],
|
|
11
|
+
"repository": "https://github.com/micromark/micromark/tree/main/packages/micromark-factory-destination",
|
|
12
|
+
"bugs": "https://github.com/micromark/micromark/issues",
|
|
13
|
+
"funding": [
|
|
14
|
+
{
|
|
15
|
+
"type": "GitHub Sponsors",
|
|
16
|
+
"url": "https://github.com/sponsors/unifiedjs"
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
"type": "OpenCollective",
|
|
20
|
+
"url": "https://opencollective.com/unified"
|
|
21
|
+
}
|
|
22
|
+
],
|
|
23
|
+
"author": "Titus Wormer <tituswormer@gmail.com> (https://wooorm.com)",
|
|
24
|
+
"contributors": [
|
|
25
|
+
"Titus Wormer <tituswormer@gmail.com> (https://wooorm.com)"
|
|
26
|
+
],
|
|
27
|
+
"sideEffects": false,
|
|
28
|
+
"type": "module",
|
|
29
|
+
"files": [
|
|
30
|
+
"dev/",
|
|
31
|
+
"index.d.ts.map",
|
|
32
|
+
"index.d.ts",
|
|
33
|
+
"index.js"
|
|
34
|
+
],
|
|
35
|
+
"exports": {
|
|
36
|
+
"development": "./dev/index.js",
|
|
37
|
+
"default": "./index.js"
|
|
38
|
+
},
|
|
39
|
+
"dependencies": {
|
|
40
|
+
"micromark-util-character": "^2.0.0",
|
|
41
|
+
"micromark-util-symbol": "^2.0.0",
|
|
42
|
+
"micromark-util-types": "^2.0.0"
|
|
43
|
+
},
|
|
44
|
+
"scripts": {
|
|
45
|
+
"build": "micromark-build"
|
|
46
|
+
},
|
|
47
|
+
"xo": {
|
|
48
|
+
"envs": [
|
|
49
|
+
"shared-node-browser"
|
|
50
|
+
],
|
|
51
|
+
"prettier": true,
|
|
52
|
+
"rules": {
|
|
53
|
+
"max-params": "off",
|
|
54
|
+
"unicorn/prefer-code-point": "off"
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @import {
|
|
3
|
+
* Effects,
|
|
4
|
+
* State,
|
|
5
|
+
* TokenizeContext,
|
|
6
|
+
* TokenType
|
|
7
|
+
* } from 'micromark-util-types'
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
import { markdownLineEnding, markdownSpace } from 'micromark-util-character';
|
|
11
|
+
/**
|
|
12
|
+
* Parse labels.
|
|
13
|
+
*
|
|
14
|
+
* > 👉 **Note**: labels in markdown are capped at 999 characters in the string.
|
|
15
|
+
*
|
|
16
|
+
* ###### Examples
|
|
17
|
+
*
|
|
18
|
+
* ```markdown
|
|
19
|
+
* [a]
|
|
20
|
+
* [a
|
|
21
|
+
* b]
|
|
22
|
+
* [a\]b]
|
|
23
|
+
* ```
|
|
24
|
+
*
|
|
25
|
+
* @this {TokenizeContext}
|
|
26
|
+
* Tokenize context.
|
|
27
|
+
* @param {Effects} effects
|
|
28
|
+
* Context.
|
|
29
|
+
* @param {State} ok
|
|
30
|
+
* State switched to when successful.
|
|
31
|
+
* @param {State} nok
|
|
32
|
+
* State switched to when unsuccessful.
|
|
33
|
+
* @param {TokenType} type
|
|
34
|
+
* Type of the whole label (`[a]`).
|
|
35
|
+
* @param {TokenType} markerType
|
|
36
|
+
* Type for the markers (`[` and `]`).
|
|
37
|
+
* @param {TokenType} stringType
|
|
38
|
+
* Type for the identifier (`a`).
|
|
39
|
+
* @returns {State}
|
|
40
|
+
* Start state.
|
|
41
|
+
*/
|
|
42
|
+
export function factoryLabel(effects, ok, nok, type, markerType, stringType) {
|
|
43
|
+
const self = this;
|
|
44
|
+
let size = 0;
|
|
45
|
+
/** @type {boolean} */
|
|
46
|
+
let seen;
|
|
47
|
+
return start;
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Start of label.
|
|
51
|
+
*
|
|
52
|
+
* ```markdown
|
|
53
|
+
* > | [a]
|
|
54
|
+
* ^
|
|
55
|
+
* ```
|
|
56
|
+
*
|
|
57
|
+
* @type {State}
|
|
58
|
+
*/
|
|
59
|
+
function start(code) {
|
|
60
|
+
effects.enter(type);
|
|
61
|
+
effects.enter(markerType);
|
|
62
|
+
effects.consume(code);
|
|
63
|
+
effects.exit(markerType);
|
|
64
|
+
effects.enter(stringType);
|
|
65
|
+
return atBreak;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* In label, at something, before something else.
|
|
70
|
+
*
|
|
71
|
+
* ```markdown
|
|
72
|
+
* > | [a]
|
|
73
|
+
* ^
|
|
74
|
+
* ```
|
|
75
|
+
*
|
|
76
|
+
* @type {State}
|
|
77
|
+
*/
|
|
78
|
+
function atBreak(code) {
|
|
79
|
+
if (size > 999 || code === null || code === 91 || code === 93 && !seen ||
|
|
80
|
+
// To do: remove in the future once we’ve switched from
|
|
81
|
+
// `micromark-extension-footnote` to `micromark-extension-gfm-footnote`,
|
|
82
|
+
// which doesn’t need this.
|
|
83
|
+
// Hidden footnotes hook.
|
|
84
|
+
/* c8 ignore next 3 */
|
|
85
|
+
code === 94 && !size && '_hiddenFootnoteSupport' in self.parser.constructs) {
|
|
86
|
+
return nok(code);
|
|
87
|
+
}
|
|
88
|
+
if (code === 93) {
|
|
89
|
+
effects.exit(stringType);
|
|
90
|
+
effects.enter(markerType);
|
|
91
|
+
effects.consume(code);
|
|
92
|
+
effects.exit(markerType);
|
|
93
|
+
effects.exit(type);
|
|
94
|
+
return ok;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
// To do: indent? Link chunks and EOLs together?
|
|
98
|
+
if (markdownLineEnding(code)) {
|
|
99
|
+
effects.enter("lineEnding");
|
|
100
|
+
effects.consume(code);
|
|
101
|
+
effects.exit("lineEnding");
|
|
102
|
+
return atBreak;
|
|
103
|
+
}
|
|
104
|
+
effects.enter("chunkString", {
|
|
105
|
+
contentType: "string"
|
|
106
|
+
});
|
|
107
|
+
return labelInside(code);
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* In label, in text.
|
|
112
|
+
*
|
|
113
|
+
* ```markdown
|
|
114
|
+
* > | [a]
|
|
115
|
+
* ^
|
|
116
|
+
* ```
|
|
117
|
+
*
|
|
118
|
+
* @type {State}
|
|
119
|
+
*/
|
|
120
|
+
function labelInside(code) {
|
|
121
|
+
if (code === null || code === 91 || code === 93 || markdownLineEnding(code) || size++ > 999) {
|
|
122
|
+
effects.exit("chunkString");
|
|
123
|
+
return atBreak(code);
|
|
124
|
+
}
|
|
125
|
+
effects.consume(code);
|
|
126
|
+
if (!seen) seen = !markdownSpace(code);
|
|
127
|
+
return code === 92 ? labelEscape : labelInside;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
/**
|
|
131
|
+
* After `\`, at a special character.
|
|
132
|
+
*
|
|
133
|
+
* ```markdown
|
|
134
|
+
* > | [a\*a]
|
|
135
|
+
* ^
|
|
136
|
+
* ```
|
|
137
|
+
*
|
|
138
|
+
* @type {State}
|
|
139
|
+
*/
|
|
140
|
+
function labelEscape(code) {
|
|
141
|
+
if (code === 91 || code === 92 || code === 93) {
|
|
142
|
+
effects.consume(code);
|
|
143
|
+
size++;
|
|
144
|
+
return labelInside;
|
|
145
|
+
}
|
|
146
|
+
return labelInside(code);
|
|
147
|
+
}
|
|
148
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
(The MIT License)
|
|
2
|
+
|
|
3
|
+
Copyright (c) Titus Wormer <tituswormer@gmail.com>
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
|
6
|
+
a copy of this software and associated documentation files (the
|
|
7
|
+
'Software'), to deal in the Software without restriction, including
|
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
|
11
|
+
the following conditions:
|
|
12
|
+
|
|
13
|
+
The above copyright notice and this permission notice shall be
|
|
14
|
+
included in all copies or substantial portions of the Software.
|
|
15
|
+
|
|
16
|
+
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
|
19
|
+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
|
20
|
+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
|
21
|
+
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
|
22
|
+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "micromark-factory-label",
|
|
3
|
+
"version": "2.0.1",
|
|
4
|
+
"description": "micromark factory to parse labels (found in media, definitions)",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"keywords": [
|
|
7
|
+
"micromark",
|
|
8
|
+
"factory",
|
|
9
|
+
"label"
|
|
10
|
+
],
|
|
11
|
+
"repository": "https://github.com/micromark/micromark/tree/main/packages/micromark-factory-label",
|
|
12
|
+
"bugs": "https://github.com/micromark/micromark/issues",
|
|
13
|
+
"funding": [
|
|
14
|
+
{
|
|
15
|
+
"type": "GitHub Sponsors",
|
|
16
|
+
"url": "https://github.com/sponsors/unifiedjs"
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
"type": "OpenCollective",
|
|
20
|
+
"url": "https://opencollective.com/unified"
|
|
21
|
+
}
|
|
22
|
+
],
|
|
23
|
+
"author": "Titus Wormer <tituswormer@gmail.com> (https://wooorm.com)",
|
|
24
|
+
"contributors": [
|
|
25
|
+
"Titus Wormer <tituswormer@gmail.com> (https://wooorm.com)"
|
|
26
|
+
],
|
|
27
|
+
"sideEffects": false,
|
|
28
|
+
"type": "module",
|
|
29
|
+
"files": [
|
|
30
|
+
"dev/",
|
|
31
|
+
"index.d.ts.map",
|
|
32
|
+
"index.d.ts",
|
|
33
|
+
"index.js"
|
|
34
|
+
],
|
|
35
|
+
"exports": {
|
|
36
|
+
"development": "./dev/index.js",
|
|
37
|
+
"default": "./index.js"
|
|
38
|
+
},
|
|
39
|
+
"dependencies": {
|
|
40
|
+
"devlop": "^1.0.0",
|
|
41
|
+
"micromark-util-character": "^2.0.0",
|
|
42
|
+
"micromark-util-symbol": "^2.0.0",
|
|
43
|
+
"micromark-util-types": "^2.0.0"
|
|
44
|
+
},
|
|
45
|
+
"scripts": {
|
|
46
|
+
"build": "micromark-build"
|
|
47
|
+
},
|
|
48
|
+
"xo": {
|
|
49
|
+
"envs": [
|
|
50
|
+
"shared-node-browser"
|
|
51
|
+
],
|
|
52
|
+
"prettier": true,
|
|
53
|
+
"rules": {
|
|
54
|
+
"logical-assignment-operators": "off",
|
|
55
|
+
"max-params": "off",
|
|
56
|
+
"unicorn/no-this-assignment": "off",
|
|
57
|
+
"unicorn/prefer-code-point": "off"
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @import {Effects, State, TokenType} from 'micromark-util-types'
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import { markdownSpace } from 'micromark-util-character';
|
|
6
|
+
|
|
7
|
+
// To do: implement `spaceOrTabWithOptions` (`connect`, `content`).
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Parse spaces and tabs.
|
|
11
|
+
*
|
|
12
|
+
* There is no `nok` parameter:
|
|
13
|
+
*
|
|
14
|
+
* * spaces in markdown are often optional, in which case this factory can be
|
|
15
|
+
* used and `ok` will be switched to whether spaces were found or not
|
|
16
|
+
* * one line ending or space can be detected with `markdownSpace(code)` right
|
|
17
|
+
* before using `factorySpace`
|
|
18
|
+
*
|
|
19
|
+
* ###### Examples
|
|
20
|
+
*
|
|
21
|
+
* Where `␉` represents a tab (plus how much it expands) and `␠` represents a
|
|
22
|
+
* single space.
|
|
23
|
+
*
|
|
24
|
+
* ```markdown
|
|
25
|
+
* ␉
|
|
26
|
+
* ␠␠␠␠
|
|
27
|
+
* ␉␠
|
|
28
|
+
* ```
|
|
29
|
+
*
|
|
30
|
+
* @param {Effects} effects
|
|
31
|
+
* Context.
|
|
32
|
+
* @param {State} ok
|
|
33
|
+
* State switched to when successful.
|
|
34
|
+
* @param {TokenType} type
|
|
35
|
+
* Type of the whole whitespace.
|
|
36
|
+
* @param {number | undefined} [max=Infinity]
|
|
37
|
+
* Max (exclusive).
|
|
38
|
+
* @returns {State}
|
|
39
|
+
* Start state.
|
|
40
|
+
*/
|
|
41
|
+
export function factorySpace(effects, ok, type, max) {
|
|
42
|
+
const limit = max ? max - 1 : Infinity;
|
|
43
|
+
let size = 0;
|
|
44
|
+
return start;
|
|
45
|
+
|
|
46
|
+
/** @type {State} */
|
|
47
|
+
function start(code) {
|
|
48
|
+
if (markdownSpace(code)) {
|
|
49
|
+
effects.enter(type);
|
|
50
|
+
return prefix(code);
|
|
51
|
+
}
|
|
52
|
+
return ok(code);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/** @type {State} */
|
|
56
|
+
function prefix(code) {
|
|
57
|
+
if (markdownSpace(code) && size++ < limit) {
|
|
58
|
+
effects.consume(code);
|
|
59
|
+
return prefix;
|
|
60
|
+
}
|
|
61
|
+
effects.exit(type);
|
|
62
|
+
return ok(code);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Parse spaces and tabs, with a required minimum and maximum, matching
|
|
68
|
+
* `markdown-rs`’s `space_or_tab_min_max`.
|
|
69
|
+
*
|
|
70
|
+
* Unlike `factorySpace`, this can fail: `nok` is used when fewer than
|
|
71
|
+
* `min` spaces or tabs are found.
|
|
72
|
+
*
|
|
73
|
+
* @param {Effects} effects
|
|
74
|
+
* Context.
|
|
75
|
+
* @param {State} ok
|
|
76
|
+
* State switched to when successful.
|
|
77
|
+
* @param {State} nok
|
|
78
|
+
* State switched to when unsuccessful.
|
|
79
|
+
* @param {TokenType} type
|
|
80
|
+
* Type of the whole whitespace.
|
|
81
|
+
* @param {number} min
|
|
82
|
+
* Minimum allowed characters (inclusive).
|
|
83
|
+
* @param {number} max
|
|
84
|
+
* Maximum allowed characters (inclusive).
|
|
85
|
+
* @returns {State}
|
|
86
|
+
* Start state.
|
|
87
|
+
*/
|
|
88
|
+
export function factorySpaceMinMax(effects, ok, nok, type, min, max) {
|
|
89
|
+
let size = 0;
|
|
90
|
+
return start;
|
|
91
|
+
|
|
92
|
+
/** @type {State} */
|
|
93
|
+
function start(code) {
|
|
94
|
+
if (max > 0 && markdownSpace(code)) {
|
|
95
|
+
effects.enter(type);
|
|
96
|
+
return prefix(code);
|
|
97
|
+
}
|
|
98
|
+
return after(code);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
/** @type {State} */
|
|
102
|
+
function prefix(code) {
|
|
103
|
+
if (markdownSpace(code) && size < max) {
|
|
104
|
+
effects.consume(code);
|
|
105
|
+
size++;
|
|
106
|
+
return prefix;
|
|
107
|
+
}
|
|
108
|
+
effects.exit(type);
|
|
109
|
+
return after(code);
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
/** @type {State} */
|
|
113
|
+
function after(code) {
|
|
114
|
+
return size >= min ? ok(code) : nok(code);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
(The MIT License)
|
|
2
|
+
|
|
3
|
+
Copyright (c) Titus Wormer <tituswormer@gmail.com>
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
|
6
|
+
a copy of this software and associated documentation files (the
|
|
7
|
+
'Software'), to deal in the Software without restriction, including
|
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
|
11
|
+
the following conditions:
|
|
12
|
+
|
|
13
|
+
The above copyright notice and this permission notice shall be
|
|
14
|
+
included in all copies or substantial portions of the Software.
|
|
15
|
+
|
|
16
|
+
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
|
19
|
+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
|
20
|
+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
|
21
|
+
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
|
22
|
+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "micromark-factory-space",
|
|
3
|
+
"version": "2.1.0",
|
|
4
|
+
"description": "micromark factory to parse markdown space (found in lots of places)",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"keywords": [
|
|
7
|
+
"micromark",
|
|
8
|
+
"factory",
|
|
9
|
+
"space"
|
|
10
|
+
],
|
|
11
|
+
"repository": "https://github.com/micromark/micromark/tree/main/packages/micromark-factory-space",
|
|
12
|
+
"bugs": "https://github.com/micromark/micromark/issues",
|
|
13
|
+
"funding": [
|
|
14
|
+
{
|
|
15
|
+
"type": "GitHub Sponsors",
|
|
16
|
+
"url": "https://github.com/sponsors/unifiedjs"
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
"type": "OpenCollective",
|
|
20
|
+
"url": "https://opencollective.com/unified"
|
|
21
|
+
}
|
|
22
|
+
],
|
|
23
|
+
"author": "Titus Wormer <tituswormer@gmail.com> (https://wooorm.com)",
|
|
24
|
+
"contributors": [
|
|
25
|
+
"Titus Wormer <tituswormer@gmail.com> (https://wooorm.com)"
|
|
26
|
+
],
|
|
27
|
+
"sideEffects": false,
|
|
28
|
+
"type": "module",
|
|
29
|
+
"files": [
|
|
30
|
+
"dev/",
|
|
31
|
+
"index.d.ts.map",
|
|
32
|
+
"index.d.ts",
|
|
33
|
+
"index.js"
|
|
34
|
+
],
|
|
35
|
+
"exports": {
|
|
36
|
+
"development": "./dev/index.js",
|
|
37
|
+
"default": "./index.js"
|
|
38
|
+
},
|
|
39
|
+
"dependencies": {
|
|
40
|
+
"micromark-util-character": "^2.0.0",
|
|
41
|
+
"micromark-util-types": "^2.0.0"
|
|
42
|
+
},
|
|
43
|
+
"scripts": {
|
|
44
|
+
"build": "micromark-build"
|
|
45
|
+
}
|
|
46
|
+
}
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @import {
|
|
3
|
+
* Code,
|
|
4
|
+
* Effects,
|
|
5
|
+
* State,
|
|
6
|
+
* TokenType
|
|
7
|
+
* } from 'micromark-util-types'
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
import { factorySpace } from 'micromark-factory-space';
|
|
11
|
+
import { markdownLineEnding } from 'micromark-util-character';
|
|
12
|
+
/**
|
|
13
|
+
* Parse titles.
|
|
14
|
+
*
|
|
15
|
+
* ###### Examples
|
|
16
|
+
*
|
|
17
|
+
* ```markdown
|
|
18
|
+
* "a"
|
|
19
|
+
* 'b'
|
|
20
|
+
* (c)
|
|
21
|
+
* "a
|
|
22
|
+
* b"
|
|
23
|
+
* 'a
|
|
24
|
+
* b'
|
|
25
|
+
* (a\)b)
|
|
26
|
+
* ```
|
|
27
|
+
*
|
|
28
|
+
* @param {Effects} effects
|
|
29
|
+
* Context.
|
|
30
|
+
* @param {State} ok
|
|
31
|
+
* State switched to when successful.
|
|
32
|
+
* @param {State} nok
|
|
33
|
+
* State switched to when unsuccessful.
|
|
34
|
+
* @param {TokenType} type
|
|
35
|
+
* Type of the whole title (`"a"`, `'b'`, `(c)`).
|
|
36
|
+
* @param {TokenType} markerType
|
|
37
|
+
* Type for the markers (`"`, `'`, `(`, and `)`).
|
|
38
|
+
* @param {TokenType} stringType
|
|
39
|
+
* Type for the value (`a`).
|
|
40
|
+
* @returns {State}
|
|
41
|
+
* Start state.
|
|
42
|
+
*/
|
|
43
|
+
export function factoryTitle(effects, ok, nok, type, markerType, stringType) {
|
|
44
|
+
/** @type {NonNullable<Code>} */
|
|
45
|
+
let marker;
|
|
46
|
+
return start;
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Start of title.
|
|
50
|
+
*
|
|
51
|
+
* ```markdown
|
|
52
|
+
* > | "a"
|
|
53
|
+
* ^
|
|
54
|
+
* ```
|
|
55
|
+
*
|
|
56
|
+
* @type {State}
|
|
57
|
+
*/
|
|
58
|
+
function start(code) {
|
|
59
|
+
if (code === 34 || code === 39 || code === 40) {
|
|
60
|
+
effects.enter(type);
|
|
61
|
+
effects.enter(markerType);
|
|
62
|
+
effects.consume(code);
|
|
63
|
+
effects.exit(markerType);
|
|
64
|
+
marker = code === 40 ? 41 : code;
|
|
65
|
+
return begin;
|
|
66
|
+
}
|
|
67
|
+
return nok(code);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* After opening marker.
|
|
72
|
+
*
|
|
73
|
+
* This is also used at the closing marker.
|
|
74
|
+
*
|
|
75
|
+
* ```markdown
|
|
76
|
+
* > | "a"
|
|
77
|
+
* ^
|
|
78
|
+
* ```
|
|
79
|
+
*
|
|
80
|
+
* @type {State}
|
|
81
|
+
*/
|
|
82
|
+
function begin(code) {
|
|
83
|
+
if (code === marker) {
|
|
84
|
+
effects.enter(markerType);
|
|
85
|
+
effects.consume(code);
|
|
86
|
+
effects.exit(markerType);
|
|
87
|
+
effects.exit(type);
|
|
88
|
+
return ok;
|
|
89
|
+
}
|
|
90
|
+
effects.enter(stringType);
|
|
91
|
+
return atBreak(code);
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* At something, before something else.
|
|
96
|
+
*
|
|
97
|
+
* ```markdown
|
|
98
|
+
* > | "a"
|
|
99
|
+
* ^
|
|
100
|
+
* ```
|
|
101
|
+
*
|
|
102
|
+
* @type {State}
|
|
103
|
+
*/
|
|
104
|
+
function atBreak(code) {
|
|
105
|
+
if (code === marker) {
|
|
106
|
+
effects.exit(stringType);
|
|
107
|
+
return begin(marker);
|
|
108
|
+
}
|
|
109
|
+
if (code === null) {
|
|
110
|
+
return nok(code);
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
// Note: blank lines can’t exist in content.
|
|
114
|
+
if (markdownLineEnding(code)) {
|
|
115
|
+
// To do: use `space_or_tab_eol_with_options`, connect.
|
|
116
|
+
effects.enter("lineEnding");
|
|
117
|
+
effects.consume(code);
|
|
118
|
+
effects.exit("lineEnding");
|
|
119
|
+
return factorySpace(effects, atBreak, "linePrefix");
|
|
120
|
+
}
|
|
121
|
+
effects.enter("chunkString", {
|
|
122
|
+
contentType: "string"
|
|
123
|
+
});
|
|
124
|
+
return inside(code);
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
/**
|
|
128
|
+
*
|
|
129
|
+
*
|
|
130
|
+
* @type {State}
|
|
131
|
+
*/
|
|
132
|
+
function inside(code) {
|
|
133
|
+
if (code === marker || code === null || markdownLineEnding(code)) {
|
|
134
|
+
effects.exit("chunkString");
|
|
135
|
+
return atBreak(code);
|
|
136
|
+
}
|
|
137
|
+
effects.consume(code);
|
|
138
|
+
return code === 92 ? escape : inside;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
/**
|
|
142
|
+
* After `\`, at a special character.
|
|
143
|
+
*
|
|
144
|
+
* ```markdown
|
|
145
|
+
* > | "a\*b"
|
|
146
|
+
* ^
|
|
147
|
+
* ```
|
|
148
|
+
*
|
|
149
|
+
* @type {State}
|
|
150
|
+
*/
|
|
151
|
+
function escape(code) {
|
|
152
|
+
if (code === marker || code === 92) {
|
|
153
|
+
effects.consume(code);
|
|
154
|
+
return inside;
|
|
155
|
+
}
|
|
156
|
+
return inside(code);
|
|
157
|
+
}
|
|
158
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
(The MIT License)
|
|
2
|
+
|
|
3
|
+
Copyright (c) Titus Wormer <tituswormer@gmail.com>
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
|
6
|
+
a copy of this software and associated documentation files (the
|
|
7
|
+
'Software'), to deal in the Software without restriction, including
|
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
|
11
|
+
the following conditions:
|
|
12
|
+
|
|
13
|
+
The above copyright notice and this permission notice shall be
|
|
14
|
+
included in all copies or substantial portions of the Software.
|
|
15
|
+
|
|
16
|
+
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
|
19
|
+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
|
20
|
+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
|
21
|
+
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
|
22
|
+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|