@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,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @import {HtmlExtension} from 'micromark-util-types'
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Create an HTML extension for `micromark` to support GFM strikethrough when
|
|
7
|
+
* serializing to HTML.
|
|
8
|
+
*
|
|
9
|
+
* @returns {HtmlExtension}
|
|
10
|
+
* Extension for `micromark` that can be passed in `htmlExtensions`, to
|
|
11
|
+
* support GFM strikethrough when serializing to HTML.
|
|
12
|
+
*/
|
|
13
|
+
export function gfmStrikethroughHtml() {
|
|
14
|
+
return {
|
|
15
|
+
enter: {
|
|
16
|
+
strikethrough() {
|
|
17
|
+
this.tag('<del>');
|
|
18
|
+
}
|
|
19
|
+
},
|
|
20
|
+
exit: {
|
|
21
|
+
strikethrough() {
|
|
22
|
+
this.tag('</del>');
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
}
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @import {Options} from 'micromark-extension-gfm-strikethrough'
|
|
3
|
+
* @import {Event, Extension, Resolver, State, Token, TokenizeContext, Tokenizer} from 'micromark-util-types'
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { splice } from 'micromark-util-chunked';
|
|
7
|
+
import { classifyCharacter } from 'micromark-util-classify-character';
|
|
8
|
+
import { resolveAll } from 'micromark-util-resolve-all';
|
|
9
|
+
/**
|
|
10
|
+
* Create an extension for `micromark` to enable GFM strikethrough syntax.
|
|
11
|
+
*
|
|
12
|
+
* @param {Options | null | undefined} [options={}]
|
|
13
|
+
* Configuration.
|
|
14
|
+
* @returns {Extension}
|
|
15
|
+
* Extension for `micromark` that can be passed in `extensions`, to
|
|
16
|
+
* enable GFM strikethrough syntax.
|
|
17
|
+
*/
|
|
18
|
+
export function gfmStrikethrough(options) {
|
|
19
|
+
const options_ = options || {};
|
|
20
|
+
let single = options_.singleTilde;
|
|
21
|
+
const tokenizer = {
|
|
22
|
+
name: 'strikethrough',
|
|
23
|
+
tokenize: tokenizeStrikethrough,
|
|
24
|
+
resolveAll: resolveAllStrikethrough
|
|
25
|
+
};
|
|
26
|
+
if (single === null || single === undefined) {
|
|
27
|
+
single = true;
|
|
28
|
+
}
|
|
29
|
+
return {
|
|
30
|
+
text: {
|
|
31
|
+
[126]: tokenizer
|
|
32
|
+
},
|
|
33
|
+
insideSpan: {
|
|
34
|
+
null: [tokenizer]
|
|
35
|
+
},
|
|
36
|
+
attentionMarkers: {
|
|
37
|
+
null: [126]
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Take events and resolve strikethrough.
|
|
43
|
+
*
|
|
44
|
+
* @type {Resolver}
|
|
45
|
+
*/
|
|
46
|
+
function resolveAllStrikethrough(events, context) {
|
|
47
|
+
let index = -1;
|
|
48
|
+
|
|
49
|
+
// Walk through all events.
|
|
50
|
+
while (++index < events.length) {
|
|
51
|
+
// Find a token that can close.
|
|
52
|
+
if (events[index][0] === 'enter' && events[index][1].type === 'strikethroughSequenceTemporary' && events[index][1]._close) {
|
|
53
|
+
let open = index;
|
|
54
|
+
|
|
55
|
+
// Now walk back to find an opener.
|
|
56
|
+
while (open--) {
|
|
57
|
+
// Find a token that can open the closer.
|
|
58
|
+
if (events[open][0] === 'exit' && events[open][1].type === 'strikethroughSequenceTemporary' && events[open][1]._open &&
|
|
59
|
+
// If the sizes are the same:
|
|
60
|
+
events[index][1].end.offset - events[index][1].start.offset === events[open][1].end.offset - events[open][1].start.offset) {
|
|
61
|
+
events[index][1].type = 'strikethroughSequence';
|
|
62
|
+
events[open][1].type = 'strikethroughSequence';
|
|
63
|
+
|
|
64
|
+
/** @type {Token} */
|
|
65
|
+
const strikethrough = {
|
|
66
|
+
type: 'strikethrough',
|
|
67
|
+
start: Object.assign({}, events[open][1].start),
|
|
68
|
+
end: Object.assign({}, events[index][1].end)
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
/** @type {Token} */
|
|
72
|
+
const text = {
|
|
73
|
+
type: 'strikethroughText',
|
|
74
|
+
start: Object.assign({}, events[open][1].end),
|
|
75
|
+
end: Object.assign({}, events[index][1].start)
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
// Opening.
|
|
79
|
+
/** @type {Array<Event>} */
|
|
80
|
+
const nextEvents = [['enter', strikethrough, context], ['enter', events[open][1], context], ['exit', events[open][1], context], ['enter', text, context]];
|
|
81
|
+
const insideSpan = context.parser.constructs.insideSpan.null;
|
|
82
|
+
if (insideSpan) {
|
|
83
|
+
// Between.
|
|
84
|
+
splice(nextEvents, nextEvents.length, 0, resolveAll(insideSpan, events.slice(open + 1, index), context));
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
// Closing.
|
|
88
|
+
splice(nextEvents, nextEvents.length, 0, [['exit', text, context], ['enter', events[index][1], context], ['exit', events[index][1], context], ['exit', strikethrough, context]]);
|
|
89
|
+
splice(events, open - 1, index - open + 3, nextEvents);
|
|
90
|
+
index = open + nextEvents.length - 2;
|
|
91
|
+
break;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
index = -1;
|
|
97
|
+
while (++index < events.length) {
|
|
98
|
+
if (events[index][1].type === 'strikethroughSequenceTemporary') {
|
|
99
|
+
events[index][1].type = "data";
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
return events;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* @this {TokenizeContext}
|
|
107
|
+
* @type {Tokenizer}
|
|
108
|
+
*/
|
|
109
|
+
function tokenizeStrikethrough(effects, ok, nok) {
|
|
110
|
+
const previous = this.previous;
|
|
111
|
+
const events = this.events;
|
|
112
|
+
let size = 0;
|
|
113
|
+
return start;
|
|
114
|
+
|
|
115
|
+
/** @type {State} */
|
|
116
|
+
function start(code) {
|
|
117
|
+
if (previous === 126 && events[events.length - 1][1].type !== "characterEscape") {
|
|
118
|
+
return nok(code);
|
|
119
|
+
}
|
|
120
|
+
effects.enter('strikethroughSequenceTemporary');
|
|
121
|
+
return more(code);
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
/** @type {State} */
|
|
125
|
+
function more(code) {
|
|
126
|
+
const before = classifyCharacter(previous);
|
|
127
|
+
if (code === 126) {
|
|
128
|
+
// If this is the third marker, exit.
|
|
129
|
+
if (size > 1) return nok(code);
|
|
130
|
+
effects.consume(code);
|
|
131
|
+
size++;
|
|
132
|
+
return more;
|
|
133
|
+
}
|
|
134
|
+
if (size < 2 && !single) return nok(code);
|
|
135
|
+
const token = effects.exit('strikethroughSequenceTemporary');
|
|
136
|
+
const after = classifyCharacter(code);
|
|
137
|
+
token._open = !after || after === 2 && Boolean(before);
|
|
138
|
+
token._close = !before || before === 2 && Boolean(after);
|
|
139
|
+
return ok(code);
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
(The MIT License)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2020 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,129 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "micromark-extension-gfm-strikethrough",
|
|
3
|
+
"version": "2.1.0",
|
|
4
|
+
"description": "micromark extension to support GFM strikethrough",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"keywords": [
|
|
7
|
+
"micromark",
|
|
8
|
+
"micromark-extension",
|
|
9
|
+
"strikethrough",
|
|
10
|
+
"strike",
|
|
11
|
+
"through",
|
|
12
|
+
"del",
|
|
13
|
+
"delete",
|
|
14
|
+
"deletion",
|
|
15
|
+
"gfm",
|
|
16
|
+
"markdown",
|
|
17
|
+
"unified"
|
|
18
|
+
],
|
|
19
|
+
"repository": "micromark/micromark-extension-gfm-strikethrough",
|
|
20
|
+
"bugs": "https://github.com/micromark/micromark-extension-gfm-strikethrough/issues",
|
|
21
|
+
"funding": {
|
|
22
|
+
"type": "opencollective",
|
|
23
|
+
"url": "https://opencollective.com/unified"
|
|
24
|
+
},
|
|
25
|
+
"author": "Titus Wormer <tituswormer@gmail.com> (https://wooorm.com)",
|
|
26
|
+
"contributors": [
|
|
27
|
+
"Titus Wormer <tituswormer@gmail.com> (https://wooorm.com)"
|
|
28
|
+
],
|
|
29
|
+
"sideEffects": false,
|
|
30
|
+
"type": "module",
|
|
31
|
+
"files": [
|
|
32
|
+
"dev/",
|
|
33
|
+
"lib/",
|
|
34
|
+
"index.d.ts",
|
|
35
|
+
"index.js"
|
|
36
|
+
],
|
|
37
|
+
"exports": {
|
|
38
|
+
"development": "./dev/index.js",
|
|
39
|
+
"default": "./index.js"
|
|
40
|
+
},
|
|
41
|
+
"dependencies": {
|
|
42
|
+
"devlop": "^1.0.0",
|
|
43
|
+
"micromark-util-chunked": "^2.0.0",
|
|
44
|
+
"micromark-util-classify-character": "^2.0.0",
|
|
45
|
+
"micromark-util-resolve-all": "^2.0.0",
|
|
46
|
+
"micromark-util-symbol": "^2.0.0",
|
|
47
|
+
"micromark-util-types": "^2.0.0"
|
|
48
|
+
},
|
|
49
|
+
"devDependencies": {
|
|
50
|
+
"@types/node": "^20.0.0",
|
|
51
|
+
"c8": "^10.0.0",
|
|
52
|
+
"create-gfm-fixtures": "^1.0.0",
|
|
53
|
+
"micromark": "^4.0.0",
|
|
54
|
+
"micromark-build": "^2.0.0",
|
|
55
|
+
"prettier": "^3.0.0",
|
|
56
|
+
"remark-cli": "^12.0.0",
|
|
57
|
+
"remark-preset-wooorm": "^10.0.0",
|
|
58
|
+
"tape": "^5.0.0",
|
|
59
|
+
"type-coverage": "^2.0.0",
|
|
60
|
+
"typescript": "^5.0.0",
|
|
61
|
+
"xo": "^0.58.0"
|
|
62
|
+
},
|
|
63
|
+
"scripts": {
|
|
64
|
+
"prepack": "npm run build && npm run format",
|
|
65
|
+
"build": "tsc --build --clean && tsc --build && type-coverage && micromark-build",
|
|
66
|
+
"format": "remark . -qfo && prettier . -w --log-level warn && xo --fix",
|
|
67
|
+
"test-api-prod": "node --conditions production test/index.js",
|
|
68
|
+
"test-api-dev": "node --conditions development test/index.js",
|
|
69
|
+
"test-api": "npm run test-api-dev && npm run test-api-prod",
|
|
70
|
+
"test-coverage": "c8 --100 --reporter lcov npm run test-api",
|
|
71
|
+
"test": "npm run build && npm run format && npm run test-coverage"
|
|
72
|
+
},
|
|
73
|
+
"prettier": {
|
|
74
|
+
"bracketSpacing": false,
|
|
75
|
+
"semi": false,
|
|
76
|
+
"singleQuote": true,
|
|
77
|
+
"tabWidth": 2,
|
|
78
|
+
"trailingComma": "none",
|
|
79
|
+
"useTabs": false
|
|
80
|
+
},
|
|
81
|
+
"remarkConfig": {
|
|
82
|
+
"plugins": [
|
|
83
|
+
"remark-preset-wooorm"
|
|
84
|
+
]
|
|
85
|
+
},
|
|
86
|
+
"typeCoverage": {
|
|
87
|
+
"atLeast": 100,
|
|
88
|
+
"detail": true,
|
|
89
|
+
"ignoreCatch": true,
|
|
90
|
+
"strict": true
|
|
91
|
+
},
|
|
92
|
+
"xo": {
|
|
93
|
+
"prettier": true,
|
|
94
|
+
"rules": {
|
|
95
|
+
"logical-assignment-operators": "off",
|
|
96
|
+
"max-depth": "off",
|
|
97
|
+
"unicorn/prefer-at": "off"
|
|
98
|
+
},
|
|
99
|
+
"overrides": [
|
|
100
|
+
{
|
|
101
|
+
"files": "**/*.ts",
|
|
102
|
+
"rules": {
|
|
103
|
+
"@typescript-eslint/array-type": [
|
|
104
|
+
"error",
|
|
105
|
+
{
|
|
106
|
+
"default": "generic"
|
|
107
|
+
}
|
|
108
|
+
],
|
|
109
|
+
"@typescript-eslint/ban-types": [
|
|
110
|
+
"error",
|
|
111
|
+
{
|
|
112
|
+
"extendDefaults": true
|
|
113
|
+
}
|
|
114
|
+
],
|
|
115
|
+
"@typescript-eslint/consistent-type-definitions": [
|
|
116
|
+
"error",
|
|
117
|
+
"interface"
|
|
118
|
+
]
|
|
119
|
+
}
|
|
120
|
+
},
|
|
121
|
+
{
|
|
122
|
+
"files": "test/**/*.js",
|
|
123
|
+
"rules": {
|
|
124
|
+
"no-await-in-loop": 0
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
]
|
|
128
|
+
}
|
|
129
|
+
}
|
|
@@ -0,0 +1,222 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @import {Event} from 'micromark-util-types'
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
// Port of `edit_map.rs` from `markdown-rs`.
|
|
6
|
+
// This should move to `markdown-js` later.
|
|
7
|
+
|
|
8
|
+
// Deal with several changes in events, batching them together.
|
|
9
|
+
//
|
|
10
|
+
// Preferably, changes should be kept to a minimum.
|
|
11
|
+
// Sometimes, it’s needed to change the list of events, because parsing can be
|
|
12
|
+
// messy, and it helps to expose a cleaner interface of events to the compiler
|
|
13
|
+
// and other users.
|
|
14
|
+
// It can also help to merge many adjacent similar events.
|
|
15
|
+
// And, in other cases, it’s needed to parse subcontent: pass some events
|
|
16
|
+
// through another tokenizer and inject the result.
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* @typedef {[number, number, Array<Event>]} Change
|
|
20
|
+
* @typedef {[number, number, number]} Jump
|
|
21
|
+
*/
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Tracks a bunch of edits.
|
|
25
|
+
*/
|
|
26
|
+
export class EditMap {
|
|
27
|
+
/**
|
|
28
|
+
* Create a new edit map.
|
|
29
|
+
*/
|
|
30
|
+
constructor() {
|
|
31
|
+
/**
|
|
32
|
+
* Record of changes.
|
|
33
|
+
*
|
|
34
|
+
* @type {Array<Change>}
|
|
35
|
+
*/
|
|
36
|
+
this.map = [];
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Changes by index, so `add` does not scan `map` (quadratic on
|
|
40
|
+
* table-heavy documents).
|
|
41
|
+
*
|
|
42
|
+
* @type {Map<number, Change>}
|
|
43
|
+
*/
|
|
44
|
+
this.index = new Map();
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Create an edit: a remove and/or add at a certain place.
|
|
49
|
+
*
|
|
50
|
+
* @param {number} index
|
|
51
|
+
* Index at which to apply the edit.
|
|
52
|
+
* @param {number} remove
|
|
53
|
+
* Count of items to remove at the index.
|
|
54
|
+
* @param {Array<Event>} add
|
|
55
|
+
* Items to add at the index.
|
|
56
|
+
* @returns {undefined}
|
|
57
|
+
* Nothing.
|
|
58
|
+
*/
|
|
59
|
+
add(index, remove, add) {
|
|
60
|
+
addImplementation(this, index, remove, add);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
// To do: add this when moving to `micromark`.
|
|
64
|
+
// /**
|
|
65
|
+
// * Create an edit: but insert `add` before existing additions.
|
|
66
|
+
// *
|
|
67
|
+
// * @param {number} index
|
|
68
|
+
// * @param {number} remove
|
|
69
|
+
// * @param {Array<Event>} add
|
|
70
|
+
// * @returns {undefined}
|
|
71
|
+
// */
|
|
72
|
+
// addBefore(index, remove, add) {
|
|
73
|
+
// addImplementation(this, index, remove, add, true)
|
|
74
|
+
// }
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* Done, change the events.
|
|
78
|
+
*
|
|
79
|
+
* @param {Array<Event>} events
|
|
80
|
+
* List of events to apply the edits to.
|
|
81
|
+
* @returns {undefined}
|
|
82
|
+
* Nothing.
|
|
83
|
+
*/
|
|
84
|
+
consume(events) {
|
|
85
|
+
this.map.sort(function (a, b) {
|
|
86
|
+
return a[0] - b[0];
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
/* c8 ignore next 3 -- `resolve` is never called without tables, so without edits. */
|
|
90
|
+
if (this.map.length === 0) {
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
// To do: if links are added in events, like they are in `markdown-rs`,
|
|
95
|
+
// this is needed.
|
|
96
|
+
// // Calculate jumps: where items in the current list move to.
|
|
97
|
+
// /** @type {Array<Jump>} */
|
|
98
|
+
// const jumps = []
|
|
99
|
+
// let index = 0
|
|
100
|
+
// let addAcc = 0
|
|
101
|
+
// let removeAcc = 0
|
|
102
|
+
// while (index < this.map.length) {
|
|
103
|
+
// const [at, remove, add] = this.map[index]
|
|
104
|
+
// removeAcc += remove
|
|
105
|
+
// addAcc += add.length
|
|
106
|
+
// jumps.push([at, removeAcc, addAcc])
|
|
107
|
+
// index += 1
|
|
108
|
+
// }
|
|
109
|
+
//
|
|
110
|
+
// . shiftLinks(events, jumps)
|
|
111
|
+
|
|
112
|
+
let index = this.map.length;
|
|
113
|
+
/** @type {Array<Array<Event>>} */
|
|
114
|
+
const vecs = [];
|
|
115
|
+
while (index > 0) {
|
|
116
|
+
index -= 1;
|
|
117
|
+
vecs.push(events.slice(this.map[index][0] + this.map[index][1]), this.map[index][2]);
|
|
118
|
+
|
|
119
|
+
// Truncate rest.
|
|
120
|
+
events.length = this.map[index][0];
|
|
121
|
+
}
|
|
122
|
+
vecs.push(events.slice());
|
|
123
|
+
events.length = 0;
|
|
124
|
+
let slice = vecs.pop();
|
|
125
|
+
while (slice) {
|
|
126
|
+
for (const element of slice) {
|
|
127
|
+
events.push(element);
|
|
128
|
+
}
|
|
129
|
+
slice = vecs.pop();
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
// Truncate everything.
|
|
133
|
+
this.map.length = 0;
|
|
134
|
+
this.index.clear();
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
/**
|
|
139
|
+
* Create an edit.
|
|
140
|
+
*
|
|
141
|
+
* @param {EditMap} editMap
|
|
142
|
+
* Edit map to apply to.
|
|
143
|
+
* @param {number} at
|
|
144
|
+
* Index at which to apply the edit.
|
|
145
|
+
* @param {number} remove
|
|
146
|
+
* Count of items to remove at the index.
|
|
147
|
+
* @param {Array<Event>} add
|
|
148
|
+
* Items to add at the index.
|
|
149
|
+
* @returns {undefined}
|
|
150
|
+
* Nothing.
|
|
151
|
+
*/
|
|
152
|
+
function addImplementation(editMap, at, remove, add) {
|
|
153
|
+
/* c8 ignore next 3 -- `resolve` is never called without tables, so without edits. */
|
|
154
|
+
if (remove === 0 && add.length === 0) {
|
|
155
|
+
return;
|
|
156
|
+
}
|
|
157
|
+
const existing = editMap.index.get(at);
|
|
158
|
+
if (existing) {
|
|
159
|
+
existing[1] += remove;
|
|
160
|
+
|
|
161
|
+
// To do: before not used by tables, use when moving to micromark.
|
|
162
|
+
// if (before) {
|
|
163
|
+
// add.push(...existing[2])
|
|
164
|
+
// existing[2] = add
|
|
165
|
+
// } else {
|
|
166
|
+
existing[2].push(...add);
|
|
167
|
+
// }
|
|
168
|
+
|
|
169
|
+
return;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
/** @type {Change} */
|
|
173
|
+
const change = [at, remove, add];
|
|
174
|
+
editMap.map.push(change);
|
|
175
|
+
editMap.index.set(at, change);
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
// /**
|
|
179
|
+
// * Shift `previous` and `next` links according to `jumps`.
|
|
180
|
+
// *
|
|
181
|
+
// * This fixes links in case there are events removed or added between them.
|
|
182
|
+
// *
|
|
183
|
+
// * @param {Array<Event>} events
|
|
184
|
+
// * @param {Array<Jump>} jumps
|
|
185
|
+
// */
|
|
186
|
+
// function shiftLinks(events, jumps) {
|
|
187
|
+
// let jumpIndex = 0
|
|
188
|
+
// let index = 0
|
|
189
|
+
// let add = 0
|
|
190
|
+
// let rm = 0
|
|
191
|
+
|
|
192
|
+
// while (index < events.length) {
|
|
193
|
+
// const rmCurr = rm
|
|
194
|
+
|
|
195
|
+
// while (jumpIndex < jumps.length && jumps[jumpIndex][0] <= index) {
|
|
196
|
+
// add = jumps[jumpIndex][2]
|
|
197
|
+
// rm = jumps[jumpIndex][1]
|
|
198
|
+
// jumpIndex += 1
|
|
199
|
+
// }
|
|
200
|
+
|
|
201
|
+
// // Ignore items that will be removed.
|
|
202
|
+
// if (rm > rmCurr) {
|
|
203
|
+
// index += rm - rmCurr
|
|
204
|
+
// } else {
|
|
205
|
+
// // ?
|
|
206
|
+
// // if let Some(link) = &events[index].link {
|
|
207
|
+
// // if let Some(next) = link.next {
|
|
208
|
+
// // events[next].link.as_mut().unwrap().previous = Some(index + add - rm);
|
|
209
|
+
// // while jumpIndex < jumps.len() && jumps[jumpIndex].0 <= next {
|
|
210
|
+
// // add = jumps[jumpIndex].2;
|
|
211
|
+
// // rm = jumps[jumpIndex].1;
|
|
212
|
+
// // jumpIndex += 1;
|
|
213
|
+
// // }
|
|
214
|
+
// // events[index].link.as_mut().unwrap().next = Some(next + add - rm);
|
|
215
|
+
// // index = next;
|
|
216
|
+
// // continue;
|
|
217
|
+
// // }
|
|
218
|
+
// // }
|
|
219
|
+
// index += 1
|
|
220
|
+
// }
|
|
221
|
+
// }
|
|
222
|
+
// }
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @import {HtmlExtension} from 'micromark-util-types'
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
const alignment = {
|
|
6
|
+
none: '',
|
|
7
|
+
left: ' align="left"',
|
|
8
|
+
right: ' align="right"',
|
|
9
|
+
center: ' align="center"'
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
// To do: micromark@5: use `infer` here, when all events are exposed.
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Create an HTML extension for `micromark` to support GitHub tables when
|
|
16
|
+
* serializing to HTML.
|
|
17
|
+
*
|
|
18
|
+
* @returns {HtmlExtension}
|
|
19
|
+
* Extension for `micromark` that can be passed in `htmlExtensions` to
|
|
20
|
+
* support GitHub tables when serializing to HTML.
|
|
21
|
+
*/
|
|
22
|
+
export function gfmTableHtml() {
|
|
23
|
+
return {
|
|
24
|
+
enter: {
|
|
25
|
+
table(token) {
|
|
26
|
+
const tableAlign = token._align;
|
|
27
|
+
this.lineEndingIfNeeded();
|
|
28
|
+
this.tag('<table>');
|
|
29
|
+
this.setData('tableAlign', tableAlign);
|
|
30
|
+
},
|
|
31
|
+
tableBody() {
|
|
32
|
+
this.tag('<tbody>');
|
|
33
|
+
},
|
|
34
|
+
tableData() {
|
|
35
|
+
const tableAlign = this.getData('tableAlign');
|
|
36
|
+
const tableColumn = this.getData('tableColumn');
|
|
37
|
+
const align = alignment[tableAlign[tableColumn]];
|
|
38
|
+
if (align === undefined) {
|
|
39
|
+
// Capture results to ignore them.
|
|
40
|
+
this.buffer();
|
|
41
|
+
} else {
|
|
42
|
+
this.lineEndingIfNeeded();
|
|
43
|
+
this.tag('<td' + align + '>');
|
|
44
|
+
}
|
|
45
|
+
},
|
|
46
|
+
tableHead() {
|
|
47
|
+
this.lineEndingIfNeeded();
|
|
48
|
+
this.tag('<thead>');
|
|
49
|
+
},
|
|
50
|
+
tableHeader() {
|
|
51
|
+
const tableAlign = this.getData('tableAlign');
|
|
52
|
+
const tableColumn = this.getData('tableColumn');
|
|
53
|
+
const align = alignment[tableAlign[tableColumn]];
|
|
54
|
+
this.lineEndingIfNeeded();
|
|
55
|
+
this.tag('<th' + align + '>');
|
|
56
|
+
},
|
|
57
|
+
tableRow() {
|
|
58
|
+
this.setData('tableColumn', 0);
|
|
59
|
+
this.lineEndingIfNeeded();
|
|
60
|
+
this.tag('<tr>');
|
|
61
|
+
}
|
|
62
|
+
},
|
|
63
|
+
exit: {
|
|
64
|
+
// Overwrite the default code text data handler to unescape escaped pipes when
|
|
65
|
+
// they are in tables.
|
|
66
|
+
codeTextData(token) {
|
|
67
|
+
let value = this.sliceSerialize(token);
|
|
68
|
+
if (this.getData('tableAlign')) {
|
|
69
|
+
value = value.replace(/\\([\\|])/g, replace);
|
|
70
|
+
}
|
|
71
|
+
this.raw(this.encode(value));
|
|
72
|
+
},
|
|
73
|
+
table() {
|
|
74
|
+
this.setData('tableAlign');
|
|
75
|
+
// Note: we don’t set `slurpAllLineEndings` anymore, in delimiter rows,
|
|
76
|
+
// but we do need to reset it to match a funky newline GH generates for
|
|
77
|
+
// list items combined with tables.
|
|
78
|
+
this.setData('slurpAllLineEndings');
|
|
79
|
+
this.lineEndingIfNeeded();
|
|
80
|
+
this.tag('</table>');
|
|
81
|
+
},
|
|
82
|
+
tableBody() {
|
|
83
|
+
this.lineEndingIfNeeded();
|
|
84
|
+
this.tag('</tbody>');
|
|
85
|
+
},
|
|
86
|
+
tableData() {
|
|
87
|
+
const tableAlign = this.getData('tableAlign');
|
|
88
|
+
const tableColumn = this.getData('tableColumn');
|
|
89
|
+
if (tableColumn in tableAlign) {
|
|
90
|
+
this.tag('</td>');
|
|
91
|
+
this.setData('tableColumn', tableColumn + 1);
|
|
92
|
+
} else {
|
|
93
|
+
// Stop capturing.
|
|
94
|
+
this.resume();
|
|
95
|
+
}
|
|
96
|
+
},
|
|
97
|
+
tableHead() {
|
|
98
|
+
this.lineEndingIfNeeded();
|
|
99
|
+
this.tag('</thead>');
|
|
100
|
+
},
|
|
101
|
+
tableHeader() {
|
|
102
|
+
const tableColumn = this.getData('tableColumn');
|
|
103
|
+
this.tag('</th>');
|
|
104
|
+
this.setData('tableColumn', tableColumn + 1);
|
|
105
|
+
},
|
|
106
|
+
tableRow() {
|
|
107
|
+
const tableAlign = this.getData('tableAlign');
|
|
108
|
+
let tableColumn = this.getData('tableColumn');
|
|
109
|
+
while (tableColumn < tableAlign.length) {
|
|
110
|
+
this.lineEndingIfNeeded();
|
|
111
|
+
this.tag('<td' + alignment[tableAlign[tableColumn]] + '></td>');
|
|
112
|
+
tableColumn++;
|
|
113
|
+
}
|
|
114
|
+
this.setData('tableColumn', tableColumn);
|
|
115
|
+
this.lineEndingIfNeeded();
|
|
116
|
+
this.tag('</tr>');
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
* Replace escaped characters in table cells.
|
|
124
|
+
*
|
|
125
|
+
* @param {string} $0
|
|
126
|
+
* Whole.
|
|
127
|
+
* @param {string} $1
|
|
128
|
+
* Escaped character (either a backslash or a pipe).
|
|
129
|
+
* @returns {string}
|
|
130
|
+
* Replacement for the escaped character.
|
|
131
|
+
*/
|
|
132
|
+
function replace($0, $1) {
|
|
133
|
+
// Pipes work, backslashes don’t (but can’t escape pipes).
|
|
134
|
+
return $1 === '|' ? $1 : $0;
|
|
135
|
+
}
|