highmark-markdown 0.0.1
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/.swcrc +11 -0
- package/README.md +18 -0
- package/bin/main.js +15 -0
- package/example.js +43721 -0
- package/index.html +48 -0
- package/lib/attributeNames.js +30 -0
- package/lib/constants.js +22 -0
- package/lib/example/constants.js +13 -0
- package/lib/example/view/div/previewPane.js +256 -0
- package/lib/example/view/div/sizeable/left.js +135 -0
- package/lib/example/view/div/sizeable/right.js +135 -0
- package/lib/example/view/heading.js +39 -0
- package/lib/example/view/subHeading.js +39 -0
- package/lib/example/view/textarea/bnf.js +176 -0
- package/lib/example/view/textarea/lexicalEntries.js +183 -0
- package/lib/example/view/textarea/markdown.js +176 -0
- package/lib/example/view/textarea/parseTree.js +183 -0
- package/lib/example/view/textarea.js +39 -0
- package/lib/example/view.js +262 -0
- package/lib/example.js +19 -0
- package/lib/index.js +63 -0
- package/lib/markdown/bnf.js +14 -0
- package/lib/markdown/entries.js +93 -0
- package/lib/markdown/lexer.js +157 -0
- package/lib/markdown/parser.js +155 -0
- package/lib/mixins/content.js +23 -0
- package/lib/mixins/element.js +47 -0
- package/lib/mixins/node.js +30 -0
- package/lib/node/markdown/anchor.js +164 -0
- package/lib/node/markdown/blockListing.js +137 -0
- package/lib/node/markdown/blockListingEnd.js +120 -0
- package/lib/node/markdown/blockListingStart.js +143 -0
- package/lib/node/markdown/blockText.js +132 -0
- package/lib/node/markdown/className.js +130 -0
- package/lib/node/markdown/document.js +158 -0
- package/lib/node/markdown/emphasisedText.js +123 -0
- package/lib/node/markdown/endOfLine.js +136 -0
- package/lib/node/markdown/error.js +169 -0
- package/lib/node/markdown/footnote.js +130 -0
- package/lib/node/markdown/footnoteItem.js +136 -0
- package/lib/node/markdown/footnotesList.js +154 -0
- package/lib/node/markdown/hyperlink.js +170 -0
- package/lib/node/markdown/image.js +170 -0
- package/lib/node/markdown/inlineListing.js +130 -0
- package/lib/node/markdown/inlineText.js +132 -0
- package/lib/node/markdown/line.js +131 -0
- package/lib/node/markdown/lineBreak.js +120 -0
- package/lib/node/markdown/link.js +184 -0
- package/lib/node/markdown/orderedList.js +162 -0
- package/lib/node/markdown/orderedListItem.js +130 -0
- package/lib/node/markdown/paragraph.js +120 -0
- package/lib/node/markdown/primaryHeading.js +120 -0
- package/lib/node/markdown/quaternaryHeading.js +120 -0
- package/lib/node/markdown/reference.js +130 -0
- package/lib/node/markdown/secondaryHeading.js +120 -0
- package/lib/node/markdown/strongText.js +123 -0
- package/lib/node/markdown/stronglyEmphasisedText.js +163 -0
- package/lib/node/markdown/table.js +120 -0
- package/lib/node/markdown/tableBody.js +120 -0
- package/lib/node/markdown/tableBodyCell.js +130 -0
- package/lib/node/markdown/tableBodyRow.js +120 -0
- package/lib/node/markdown/tableCell.js +152 -0
- package/lib/node/markdown/tableHead.js +120 -0
- package/lib/node/markdown/tableHeadCell.js +130 -0
- package/lib/node/markdown/tableHeadRow.js +120 -0
- package/lib/node/markdown/tableSeparator.js +120 -0
- package/lib/node/markdown/tertiaryHeading.js +120 -0
- package/lib/node/markdown/text.js +130 -0
- package/lib/node/markdown/unorderedList.js +120 -0
- package/lib/node/markdown/unorderedListItem.js +120 -0
- package/lib/node/markdown/url.js +122 -0
- package/lib/node/markdown/verticalSpace.js +132 -0
- package/lib/node/markdown.js +246 -0
- package/lib/nodeMap.js +78 -0
- package/lib/ruleNameToHTMLMap.js +161 -0
- package/lib/ruleNames.js +240 -0
- package/lib/tokenTypes.js +150 -0
- package/lib/utilities/childNodes.js +67 -0
- package/lib/utilities/content.js +52 -0
- package/lib/utilities/link.js +37 -0
- package/lib/utilities/node.js +32 -0
- package/lib/utilities/query.js +55 -0
- package/license.txt +48 -0
- package/package.json +43 -0
- package/src/attributeNames.js +6 -0
- package/src/constants.js +4 -0
- package/src/example/constants.js +4 -0
- package/src/example/view/div/previewPane.js +82 -0
- package/src/example/view/div/sizeable/left.js +19 -0
- package/src/example/view/div/sizeable/right.js +19 -0
- package/src/example/view/heading.js +14 -0
- package/src/example/view/subHeading.js +16 -0
- package/src/example/view/textarea/bnf.js +41 -0
- package/src/example/view/textarea/lexicalEntries.js +52 -0
- package/src/example/view/textarea/markdown.js +41 -0
- package/src/example/view/textarea/parseTree.js +50 -0
- package/src/example/view/textarea.js +17 -0
- package/src/example/view.js +139 -0
- package/src/example.js +21 -0
- package/src/index.js +13 -0
- package/src/markdown/bnf.js +143 -0
- package/src/markdown/entries.js +84 -0
- package/src/markdown/lexer.js +36 -0
- package/src/markdown/parser.js +36 -0
- package/src/mixins/content.js +19 -0
- package/src/mixins/element.js +47 -0
- package/src/mixins/node.js +27 -0
- package/src/node/markdown/anchor.js +37 -0
- package/src/node/markdown/blockListing.js +29 -0
- package/src/node/markdown/blockListingEnd.js +7 -0
- package/src/node/markdown/blockListingStart.js +28 -0
- package/src/node/markdown/blockText.js +22 -0
- package/src/node/markdown/className.js +21 -0
- package/src/node/markdown/document.js +26 -0
- package/src/node/markdown/emphasisedText.js +13 -0
- package/src/node/markdown/endOfLine.js +24 -0
- package/src/node/markdown/error.js +36 -0
- package/src/node/markdown/footnote.js +21 -0
- package/src/node/markdown/footnoteItem.js +37 -0
- package/src/node/markdown/footnotesList.js +64 -0
- package/src/node/markdown/hyperlink.js +47 -0
- package/src/node/markdown/image.js +47 -0
- package/src/node/markdown/inlineListing.js +20 -0
- package/src/node/markdown/inlineText.js +22 -0
- package/src/node/markdown/line.js +21 -0
- package/src/node/markdown/lineBreak.js +7 -0
- package/src/node/markdown/link.js +54 -0
- package/src/node/markdown/orderedList.js +33 -0
- package/src/node/markdown/orderedListItem.js +21 -0
- package/src/node/markdown/paragraph.js +7 -0
- package/src/node/markdown/primaryHeading.js +7 -0
- package/src/node/markdown/quaternaryHeading.js +7 -0
- package/src/node/markdown/reference.js +21 -0
- package/src/node/markdown/secondaryHeading.js +7 -0
- package/src/node/markdown/strongText.js +13 -0
- package/src/node/markdown/stronglyEmphasisedText.js +39 -0
- package/src/node/markdown/table.js +7 -0
- package/src/node/markdown/tableBody.js +7 -0
- package/src/node/markdown/tableBodyCell.js +20 -0
- package/src/node/markdown/tableBodyRow.js +7 -0
- package/src/node/markdown/tableCell.js +42 -0
- package/src/node/markdown/tableHead.js +7 -0
- package/src/node/markdown/tableHeadCell.js +20 -0
- package/src/node/markdown/tableHeadRow.js +7 -0
- package/src/node/markdown/tableSeparator.js +7 -0
- package/src/node/markdown/tertiaryHeading.js +7 -0
- package/src/node/markdown/text.js +20 -0
- package/src/node/markdown/unorderedList.js +7 -0
- package/src/node/markdown/unorderedListItem.js +7 -0
- package/src/node/markdown/url.js +10 -0
- package/src/node/markdown/verticalSpace.js +22 -0
- package/src/node/markdown.js +100 -0
- package/src/nodeMap.js +140 -0
- package/src/ruleNameToHTMLMap.js +227 -0
- package/src/ruleNames.js +95 -0
- package/src/tokenTypes.js +59 -0
- package/src/utilities/childNodes.js +70 -0
- package/src/utilities/content.js +77 -0
- package/src/utilities/link.js +27 -0
- package/src/utilities/node.js +23 -0
- package/src/utilities/query.js +42 -0
package/src/index.js
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
export { default as nodeMap } from "./nodeMap";
|
|
4
|
+
export { default as ruleNames } from "./ruleNames";
|
|
5
|
+
export { default as tokenTypes } from "./tokenTypes";
|
|
6
|
+
export { default as MarkdownNode } from "./node/markdown";
|
|
7
|
+
export { default as nodeUtilities } from "./utilities/node";
|
|
8
|
+
export { default as MarkdownLexer } from "./markdown/lexer";
|
|
9
|
+
export { default as linkUtilities } from "./utilities/link";
|
|
10
|
+
export { default as MarkdownParser } from "./markdown/parser";
|
|
11
|
+
export { default as queryUtilities } from "./utilities/query";
|
|
12
|
+
export { default as ruleNameToHTMLMap } from "./ruleNameToHTMLMap";
|
|
13
|
+
export { default as FootnotesListMarkdownNode } from "./node/markdown/footnotesList";
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
const bnf = `
|
|
4
|
+
|
|
5
|
+
document ::= ( blockListing | orderedList | unorderedList | table | footnote | primaryHeading | secondaryHeading | tertiaryHeading | quaternaryHeading | lineBreak | paragraph | verticalSpace | error )+ ;
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
blockListing ::= blockListingStart blockText blockListingEnd ;
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
orderedList ::= orderedListItem+ ;
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
unorderedList ::= unorderedListItem+ ;
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
footnotesList ::= footnoteItem+ ;
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
table ::= tableHead tableSeparator tableBody ;
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
footnote ::= reference paragraph ;
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
primaryHeading ::= [single-hash] line ;
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
secondaryHeading ::= [double-hash] line ;
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
tertiaryHeading ::= [triple-hash] line ;
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
quaternaryHeading ::= [quadruple-hash] line ;
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
lineBreak! ::= [dashes] endOfLine ;
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
paragraph ::= line+ ;
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
verticalSpace! ::= endOfLine+ ;
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
error! ::= . ;
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
blockListingStart ::= [backticks] className? endOfLine ;
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
blockListingEnd ::= [backticks] endOfLine ;
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
footnoteItem ::= anchor paragraph ;
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
orderedListItem ::= [number]<NO_WHITESPACE>"." line ;
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
unorderedListItem ::= [single-asterisk] line ;
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
tableHead ::= tableHeadRow ;
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
tableBody ::= tableBodyRow+ ;
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
tableSeparator! ::= [many-dashes] endOfLine ;
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
tableHeadRow ::= [vertical-bar] tableHeadCell+ endOfLine ;
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
tableBodyRow ::= [vertical-bar] tableBodyCell+ endOfLine ;
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
tableHeadCell! ::= tableCell ;
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
tableBodyCell! ::= tableCell ;
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
tableCell ::= ( link | hyperlink | inlineListing | stronglyEmphasisedText | emphasisedText | strongText | text )+ [vertical-bar] ;
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
line! ::= ( link | image | hyperlink | inlineListing | stronglyEmphasisedText | emphasisedText | strongText | text )+ endOfLine ;
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
link! ::= [open-square-bracket-caret] [identifier] [close-square-bracket] ;
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
image ::= [exclamation-mark-open-square-bracket] inlineText... [close-square-bracket]<NO_WHITESPACE>"(" url ")" ;
|
|
96
|
+
|
|
97
|
+
|
|
98
|
+
hyperlink ::= [open-square-bracket] inlineText... [close-square-bracket]<NO_WHITESPACE>"(" url ")" ;
|
|
99
|
+
|
|
100
|
+
|
|
101
|
+
reference! ::= [open-square-bracket-caret] [identifier] [close-square-bracket-colon] ;
|
|
102
|
+
|
|
103
|
+
|
|
104
|
+
inlineListing ::= [backtick] inlineText... [backtick] ;
|
|
105
|
+
|
|
106
|
+
|
|
107
|
+
stronglyEmphasisedText ::= [triple-asterisk] inlineText... [triple-asterisk] ;
|
|
108
|
+
|
|
109
|
+
|
|
110
|
+
emphasisedText ::= [single-asterisk] inlineText... [single-asterisk] ;
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
strongText ::= [double-asterisk] inlineText... [double-asterisk] ;
|
|
114
|
+
|
|
115
|
+
|
|
116
|
+
blockText! ::= ( text | endOfLine )+ ;
|
|
117
|
+
|
|
118
|
+
|
|
119
|
+
inlineText ::= text+ ;
|
|
120
|
+
|
|
121
|
+
|
|
122
|
+
anchor ::= [number] ;
|
|
123
|
+
|
|
124
|
+
|
|
125
|
+
text ::= [escaped] | [number] | [path] | [domain] | [protocol] | [identifier] | [word] | [special] | [unassigned] ;
|
|
126
|
+
|
|
127
|
+
|
|
128
|
+
url ::= ( [protocol] [domain] )? [path]
|
|
129
|
+
|
|
130
|
+
| [protocol] [domain]
|
|
131
|
+
|
|
132
|
+
;
|
|
133
|
+
|
|
134
|
+
|
|
135
|
+
className ::= <NO_WHITESPACE>[identifier] ;
|
|
136
|
+
|
|
137
|
+
|
|
138
|
+
endOfLine ::= <END_OF_LINE> ;
|
|
139
|
+
|
|
140
|
+
`;
|
|
141
|
+
|
|
142
|
+
export default bnf;
|
|
143
|
+
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
const entries = [
|
|
4
|
+
{
|
|
5
|
+
"escaped": "^\\\\[^\\s]"
|
|
6
|
+
},
|
|
7
|
+
{
|
|
8
|
+
"exclamation-mark-open-square-bracket": "^!\\["
|
|
9
|
+
},
|
|
10
|
+
{
|
|
11
|
+
"close-square-bracket-colon": "^\\]:"
|
|
12
|
+
},
|
|
13
|
+
{
|
|
14
|
+
"open-square-bracket-caret": "^\\[\\^"
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
"close-square-bracket": "^\\]"
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
"open-square-bracket": "^\\["
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
"triple-asterisk": "^\\*\\*\\*"
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
"double-asterisk": "^\\*\\*"
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
"single-asterisk": "^\\*"
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
"quadruple-hash": "^####"
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
"triple-hash": "^###"
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
"double-hash": "^##"
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
"single-hash": "^#"
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
"vertical-bar": "^\\|"
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
"many-dashes": "^-{4,}"
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
"dashes": "^-{2,3}"
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
"backticks": "^```"
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
"backtick": "^`"
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
"number": "^[1-9][0-9]*"
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
"path": "^\\/(?:[a-z]+\\/)*(?:[a-z\\-]+(?:\\.[a-z]+)?)?"
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
"domain": "^[a-z\\-]+(?:\\.[a-z\\-]+)+"
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
"protocol": "^[a-z]+:\\/\\/"
|
|
69
|
+
},
|
|
70
|
+
{
|
|
71
|
+
"identifier": "^[a-z]+(?:-[a-z]+)*"
|
|
72
|
+
},
|
|
73
|
+
{
|
|
74
|
+
"word": "^\\w+"
|
|
75
|
+
},
|
|
76
|
+
{
|
|
77
|
+
"special": "^\\.\\.\\.|\\.|\\?|\\(|\\)|\\^|\\/|-|@|,|!|;|:|`|'|\""
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
"unassigned": "^[^\\s]+"
|
|
81
|
+
}
|
|
82
|
+
];
|
|
83
|
+
|
|
84
|
+
export default entries;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { CommonLexer } from "occam-lexers";
|
|
4
|
+
import { WhitespaceToken, EndOfLineSignificantToken } from "occam-lexers";
|
|
5
|
+
|
|
6
|
+
import entries from "./entries";
|
|
7
|
+
|
|
8
|
+
export default class MarkdownLexer extends CommonLexer {
|
|
9
|
+
static entries = entries;
|
|
10
|
+
|
|
11
|
+
static EndOfLineToken = EndOfLineSignificantToken;
|
|
12
|
+
|
|
13
|
+
static WhitespaceToken = WhitespaceToken;
|
|
14
|
+
|
|
15
|
+
static EndOfLineCommentToken = null;
|
|
16
|
+
|
|
17
|
+
static SingleLineCommentToken = null;
|
|
18
|
+
|
|
19
|
+
static RegularExpressionToken = null;
|
|
20
|
+
|
|
21
|
+
static EndOfMultiLineCommentToken = null;
|
|
22
|
+
|
|
23
|
+
static StartOfMultiLineCommentToken = null;
|
|
24
|
+
|
|
25
|
+
static MiddleOfMultiLineCommentToken = null;
|
|
26
|
+
|
|
27
|
+
static SinglyQuotedStringLiteralToken = null;
|
|
28
|
+
|
|
29
|
+
static DoublyQuotedStringLiteralToken = null;
|
|
30
|
+
|
|
31
|
+
static fromNothing() { return CommonLexer.fromNothing(MarkdownLexer); }
|
|
32
|
+
|
|
33
|
+
static fromRules(rules) { return CommonLexer.fromRules(MarkdownLexer, rules); }
|
|
34
|
+
|
|
35
|
+
static fromEntries(entries) { return CommonLexer.fromEntries(MarkdownLexer, entries); }
|
|
36
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { CommonParser } from "occam-parsers";
|
|
4
|
+
|
|
5
|
+
import bnf from "./bnf";
|
|
6
|
+
import nodeMap from "../nodeMap";
|
|
7
|
+
|
|
8
|
+
import { setNonTerminalNodes } from "../utilities/node";
|
|
9
|
+
|
|
10
|
+
export default class MarkdownParser extends CommonParser {
|
|
11
|
+
static bnf = bnf;
|
|
12
|
+
|
|
13
|
+
static fromNothing() {
|
|
14
|
+
const markdownParser = CommonParser.fromNothing(MarkdownParser);
|
|
15
|
+
|
|
16
|
+
setNonTerminalNodes(markdownParser, nodeMap);
|
|
17
|
+
|
|
18
|
+
return markdownParser;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
static fromBNF(bnf) {
|
|
22
|
+
const markdownParser = CommonParser.fromBNF(MarkdownParser, bnf);
|
|
23
|
+
|
|
24
|
+
setNonTerminalNodes(markdownParser, nodeMap);
|
|
25
|
+
|
|
26
|
+
return markdownParser;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
static fromRules(rules) {
|
|
30
|
+
const markdownParser = CommonParser.fromRules(MarkdownParser, rules);
|
|
31
|
+
|
|
32
|
+
setNonTerminalNodes(markdownParser, nodeMap);
|
|
33
|
+
|
|
34
|
+
return markdownParser;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { contentFromMarkdownNodes } from "../utilities/content";
|
|
4
|
+
|
|
5
|
+
function getContent(context) {
|
|
6
|
+
const markdownNode = this, ///
|
|
7
|
+
markdownNodes = [
|
|
8
|
+
markdownNode
|
|
9
|
+
],
|
|
10
|
+
content = contentFromMarkdownNodes(markdownNodes, context);
|
|
11
|
+
|
|
12
|
+
return content;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
const contentMixins = {
|
|
16
|
+
getContent
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
export default contentMixins;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
function addDOMElement(parentDOMElement, siblingDOMElement = null) {
|
|
4
|
+
if ((parentDOMElement !== null ) && (this.domElement !== null)) {
|
|
5
|
+
parentDOMElement.insertBefore(this.domElement, siblingDOMElement);
|
|
6
|
+
}
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
function removeDOMElement(parentDOMElement) {
|
|
10
|
+
if ((parentDOMElement !== null ) && (this.domElement !== null)) {
|
|
11
|
+
parentDOMElement.removeChild(this.domElement);
|
|
12
|
+
|
|
13
|
+
this.domElement = null;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
function getDescendantElements(descendantElements = []) {
|
|
18
|
+
const domElement = this.getDOMElement();
|
|
19
|
+
|
|
20
|
+
if (domElement !== null) {
|
|
21
|
+
const descendantElement = this; ///
|
|
22
|
+
|
|
23
|
+
descendantElements.push(descendantElement);
|
|
24
|
+
|
|
25
|
+
const childNodes = this.getChildNodes();
|
|
26
|
+
|
|
27
|
+
childNodes.forEach((childNode) => {
|
|
28
|
+
const childNodeNonTerminalNode = childNode.isNonTerminalNode();
|
|
29
|
+
|
|
30
|
+
if (childNodeNonTerminalNode) {
|
|
31
|
+
const nonTerminalNode = childNode; ///
|
|
32
|
+
|
|
33
|
+
nonTerminalNode.getDescendantElements(descendantElements);
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
return descendantElements;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
const elementMixins = {
|
|
42
|
+
addDOMElement,
|
|
43
|
+
removeDOMElement,
|
|
44
|
+
getDescendantElements
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
export default elementMixins;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
function getDescendantNodes(descendantNodes = []) {
|
|
4
|
+
const descendantNode = this; ///
|
|
5
|
+
|
|
6
|
+
descendantNodes.push(descendantNode);
|
|
7
|
+
|
|
8
|
+
const childNodes = this.getChildNodes();
|
|
9
|
+
|
|
10
|
+
childNodes.forEach((childNode) => {
|
|
11
|
+
const childNodeNonTerminalNode = childNode.isNonTerminalNode();
|
|
12
|
+
|
|
13
|
+
if (childNodeNonTerminalNode) {
|
|
14
|
+
const nonTerminalNode = childNode; ///
|
|
15
|
+
|
|
16
|
+
nonTerminalNode.getDescendantNodes(descendantNodes);
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
return descendantNodes;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
const nodeMixins = {
|
|
24
|
+
getDescendantNodes
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
export default nodeMixins;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import MarkdownNode from "../../node/markdown";
|
|
4
|
+
|
|
5
|
+
import { ID_ATTRIBUTE_NAME } from "../../attributeNames";
|
|
6
|
+
import { ANCHOR_RULE_NAME } from "../../ruleNames";
|
|
7
|
+
|
|
8
|
+
export default class AnchorMarkdownNode extends MarkdownNode {
|
|
9
|
+
constructor(ruleName, childNodes, ambiguous, precedence, domElement, identifier) {
|
|
10
|
+
super(ruleName, childNodes, ambiguous, precedence, domElement);
|
|
11
|
+
|
|
12
|
+
this.identifier = identifier;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
getIdentifier() {
|
|
16
|
+
return this.identifier;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
createDOMElement(context) {
|
|
20
|
+
const domElement = super.createDOMElement(context),
|
|
21
|
+
name = ID_ATTRIBUTE_NAME,
|
|
22
|
+
value = this.identifier;
|
|
23
|
+
|
|
24
|
+
this.setAttribute(name, value);
|
|
25
|
+
|
|
26
|
+
return domElement;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
static fromIdentifier(identifier) {
|
|
30
|
+
const ruleName = ANCHOR_RULE_NAME,
|
|
31
|
+
childNodes = [],
|
|
32
|
+
ambiguous = false,
|
|
33
|
+
anchorMarkdownNode = MarkdownNode.fromRuleNameChildNodesAndAmbiguous(AnchorMarkdownNode, ruleName, childNodes, ambiguous, identifier);
|
|
34
|
+
|
|
35
|
+
return anchorMarkdownNode;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { arrayUtilities } from "necessary";
|
|
4
|
+
|
|
5
|
+
import MarkdownNode from "../../node/markdown";
|
|
6
|
+
|
|
7
|
+
const { first, second } = arrayUtilities;
|
|
8
|
+
|
|
9
|
+
export default class BlockListingMarkdownNode extends MarkdownNode {
|
|
10
|
+
getContent() {
|
|
11
|
+
const childNodes = this.getChildNodes(),
|
|
12
|
+
secondChildNode = second(childNodes),
|
|
13
|
+
blockTextMarkdownNode = secondChildNode, ///
|
|
14
|
+
content = blockTextMarkdownNode; ///
|
|
15
|
+
|
|
16
|
+
return content;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
getClassName() {
|
|
20
|
+
const childNodes = this.getChildNodes(),
|
|
21
|
+
firstChildNode = first(childNodes),
|
|
22
|
+
blockListingStartMarkdownNode = firstChildNode, ///
|
|
23
|
+
className = blockListingStartMarkdownNode.getClassName(); ///
|
|
24
|
+
|
|
25
|
+
return className;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
static fromRuleNameChildNodesAndAmbiguous(ruleName, childNodes, ambiguous) { return MarkdownNode.fromRuleNameChildNodesAndAmbiguous(BlockListingMarkdownNode, ruleName, childNodes, ambiguous); }
|
|
29
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import MarkdownNode from "../../node/markdown";
|
|
4
|
+
|
|
5
|
+
export default class BlockListingEndMarkdownNode extends MarkdownNode {
|
|
6
|
+
static fromRuleNameChildNodesAndAmbiguous(ruleName, childNodes, ambiguous) { return MarkdownNode.fromRuleNameChildNodesAndAmbiguous(BlockListingEndMarkdownNode, ruleName, childNodes, ambiguous); }
|
|
7
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { arrayUtilities } from "necessary";
|
|
4
|
+
|
|
5
|
+
import MarkdownNode from "../../node/markdown";
|
|
6
|
+
import ClassNameMarkdownNode from "./className";
|
|
7
|
+
|
|
8
|
+
const { second } = arrayUtilities;
|
|
9
|
+
|
|
10
|
+
export default class BlockListingStartMarkdownNode extends MarkdownNode {
|
|
11
|
+
getClassName() {
|
|
12
|
+
let className = null;
|
|
13
|
+
|
|
14
|
+
const childNodes = this.getChildNodes(),
|
|
15
|
+
secondChildNode = second(childNodes),
|
|
16
|
+
secondChildNodeClassNameMarkdownNode = (secondChildNode instanceof ClassNameMarkdownNode)
|
|
17
|
+
|
|
18
|
+
if (secondChildNodeClassNameMarkdownNode) {
|
|
19
|
+
const classNameMarkdownNode = secondChildNode; ///
|
|
20
|
+
|
|
21
|
+
className = classNameMarkdownNode.getClassName();
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
return className;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
static fromRuleNameChildNodesAndAmbiguous(ruleName, childNodes, ambiguous) { return MarkdownNode.fromRuleNameChildNodesAndAmbiguous(BlockListingStartMarkdownNode, ruleName, childNodes, ambiguous); }
|
|
28
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import contentMixins from "../../mixins/content";
|
|
4
|
+
|
|
5
|
+
import MarkdownNode from "../markdown";
|
|
6
|
+
|
|
7
|
+
class BlockTextMarkdownNode extends MarkdownNode {
|
|
8
|
+
createDOMElement(context) {
|
|
9
|
+
const content = this.getContent(context),
|
|
10
|
+
domElement = document.createTextNode(content);
|
|
11
|
+
|
|
12
|
+
this.setDOMElement(domElement);
|
|
13
|
+
|
|
14
|
+
return domElement;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
static fromRuleNameChildNodesAndAmbiguous(ruleName, childNodes, ambiguous) { return MarkdownNode.fromRuleNameChildNodesAndAmbiguous(BlockTextMarkdownNode, ruleName, childNodes, ambiguous); }
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
Object.assign(BlockTextMarkdownNode.prototype, contentMixins);
|
|
21
|
+
|
|
22
|
+
export default BlockTextMarkdownNode;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { arrayUtilities } from "necessary";
|
|
4
|
+
|
|
5
|
+
import MarkdownNode from "../../node/markdown";
|
|
6
|
+
|
|
7
|
+
const { second } = arrayUtilities;
|
|
8
|
+
|
|
9
|
+
export default class ClassNameMarkdownNode extends MarkdownNode {
|
|
10
|
+
getClassName() {
|
|
11
|
+
const childNodes = this.getChildNodes(),
|
|
12
|
+
secondChildNode = second(childNodes),
|
|
13
|
+
identifierTerminalNode = secondChildNode, ///
|
|
14
|
+
identifierTerminalNodeContent = identifierTerminalNode.getContent(),
|
|
15
|
+
className = identifierTerminalNodeContent; ///
|
|
16
|
+
|
|
17
|
+
return className;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
static fromRuleNameChildNodesAndAmbiguous(ruleName, childNodes, ambiguous) { return MarkdownNode.fromRuleNameChildNodesAndAmbiguous(ClassNameMarkdownNode, ruleName, childNodes, ambiguous); }
|
|
21
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import MarkdownNode from "../../node/markdown";
|
|
4
|
+
import FootnotesListMarkdownNode from "../../node/markdown/footnotesList";
|
|
5
|
+
|
|
6
|
+
import { renumberLinkMarkdownNodes } from "../../utilities/link";
|
|
7
|
+
|
|
8
|
+
export default class DocumentMarkdownNode extends MarkdownNode {
|
|
9
|
+
createChildNodeDOMElements(context) {
|
|
10
|
+
const documentMarkdownNode = this, ///
|
|
11
|
+
footnotesListMarkdownNode = FootnotesListMarkdownNode.fromDocumentMarkdownNode(documentMarkdownNode);
|
|
12
|
+
|
|
13
|
+
super.createChildNodeDOMElements(context);
|
|
14
|
+
|
|
15
|
+
if (footnotesListMarkdownNode !== null) {
|
|
16
|
+
const domElement = footnotesListMarkdownNode.createDOMElement(context);
|
|
17
|
+
|
|
18
|
+
this.insertDOMElement(domElement);
|
|
19
|
+
|
|
20
|
+
renumberLinkMarkdownNodes(documentMarkdownNode, footnotesListMarkdownNode);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
static fromRuleNameChildNodesAndAmbiguous(ruleName, childNodes, ambiguous) { return MarkdownNode.fromRuleNameChildNodesAndAmbiguous(DocumentMarkdownNode, ruleName, childNodes, ambiguous); }
|
|
25
|
+
}
|
|
26
|
+
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import contentMixins from "../../mixins/content";
|
|
4
|
+
|
|
5
|
+
import MarkdownNode from "../markdown";
|
|
6
|
+
|
|
7
|
+
class EmphasisedTextMarkdownNode extends MarkdownNode {
|
|
8
|
+
static fromRuleNameChildNodesAndAmbiguous(ruleName, childNodes, ambiguous) { return MarkdownNode.fromRuleNameChildNodesAndAmbiguous(EmphasisedTextMarkdownNode, ruleName, childNodes, ambiguous); }
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
Object.assign(EmphasisedTextMarkdownNode.prototype, contentMixins);
|
|
12
|
+
|
|
13
|
+
export default EmphasisedTextMarkdownNode;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import MarkdownNode from "../../node/markdown";
|
|
4
|
+
|
|
5
|
+
export default class EndOfLineMarkdownNode extends MarkdownNode {
|
|
6
|
+
createDOMElement(context) {
|
|
7
|
+
const content = this.getContent(context),
|
|
8
|
+
domElement = document.createTextNode(content);
|
|
9
|
+
|
|
10
|
+
this.setDOMElement(domElement);
|
|
11
|
+
|
|
12
|
+
return domElement;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
getContent() {
|
|
16
|
+
const firstSignificantToken = this.getFirstSignificantToken(),
|
|
17
|
+
endOfLineToken = firstSignificantToken, ///
|
|
18
|
+
content = endOfLineToken.getContent();
|
|
19
|
+
|
|
20
|
+
return content;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
static fromRuleNameChildNodesAndAmbiguous(ruleName, childNodes, ambiguous) { return MarkdownNode.fromRuleNameChildNodesAndAmbiguous(EndOfLineMarkdownNode, ruleName, childNodes, ambiguous); }
|
|
24
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { arrayUtilities } from "necessary";
|
|
4
|
+
|
|
5
|
+
import MarkdownNode from "../../node/markdown";
|
|
6
|
+
|
|
7
|
+
const { first } = arrayUtilities;
|
|
8
|
+
|
|
9
|
+
export default class ErrorMarkdownNode extends MarkdownNode {
|
|
10
|
+
createDOMElement(context) {
|
|
11
|
+
const domElement = super.createDOMElement(context),
|
|
12
|
+
content = this.getContent(context),
|
|
13
|
+
textContent = content; ///
|
|
14
|
+
|
|
15
|
+
Object.assign(domElement, {
|
|
16
|
+
textContent
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
return domElement;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
createChildNodeDOMElements(context) {
|
|
23
|
+
///
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
getContent() {
|
|
27
|
+
const childNodes = this.getChildNodes(),
|
|
28
|
+
firstChildNode = first(childNodes),
|
|
29
|
+
terminalNode = firstChildNode, ///
|
|
30
|
+
content = terminalNode.getContent();
|
|
31
|
+
|
|
32
|
+
return content;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
static fromRuleNameChildNodesAndAmbiguous(ruleName, childNodes, ambiguous) { return MarkdownNode.fromRuleNameChildNodesAndAmbiguous(ErrorMarkdownNode, ruleName, childNodes, ambiguous); }
|
|
36
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { arrayUtilities } from "necessary";
|
|
4
|
+
|
|
5
|
+
import MarkdownNode from "../../node/markdown";
|
|
6
|
+
|
|
7
|
+
const { first } = arrayUtilities;
|
|
8
|
+
|
|
9
|
+
export default class FootnoteMarkdownNode extends MarkdownNode {
|
|
10
|
+
getIdentifier() {
|
|
11
|
+
const childNodes = this.getChildNodes(),
|
|
12
|
+
firstChildNode = first(childNodes),
|
|
13
|
+
referenceMarkdownNode = firstChildNode, ///
|
|
14
|
+
referenceMarkdownNodeIdentifier = referenceMarkdownNode.getIdentifier(),
|
|
15
|
+
identifier = referenceMarkdownNodeIdentifier; ///
|
|
16
|
+
|
|
17
|
+
return identifier;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
static fromRuleNameChildNodesAndAmbiguous(ruleName, childNodes, ambiguous) { return MarkdownNode.fromRuleNameChildNodesAndAmbiguous(FootnoteMarkdownNode, ruleName, childNodes, ambiguous); }
|
|
21
|
+
}
|