highmark-markdown 1.0.173 → 1.0.174
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/README.md +1 -1
- package/example.js +14061 -13787
- package/lib/example/importer.js +5 -5
- package/lib/example/view/div/container/markdown.js +3 -3
- package/lib/example/view/div/preview.js +5 -1
- package/lib/example/view/textarea/parseTree/{markdown/outer.js → html.js} +17 -17
- package/lib/example/view/textarea/parseTree/markdown.js +49 -2
- package/lib/example/view/textarea/plainText.js +7 -2
- package/lib/example/view/xmp.js +7 -2
- package/lib/example/view.js +67 -104
- package/lib/index/match.js +6 -6
- package/lib/index.js +27 -15
- package/lib/map/className.js +60 -0
- package/lib/map/node/html.js +85 -0
- package/lib/map/node/markdown.js +73 -0
- package/lib/map/tagName.js +60 -0
- package/lib/markdown/bnf.js +2 -2
- package/lib/markdown/parser.js +10 -9
- package/lib/markdownStyle/entries.js +3 -3
- package/lib/mixins/node.js +24 -23
- package/lib/node/html/anchor.js +55 -11
- package/lib/node/html/blockLine.js +75 -9
- package/lib/node/html/division.js +135 -0
- package/lib/node/html/error.js +195 -0
- package/lib/node/html/{blockListingEnd.js → footnote.js} +20 -14
- package/lib/node/html/heading/index.js +128 -0
- package/lib/node/html/heading/primary.js +129 -0
- package/lib/node/{markdown/directive.js → html/heading/quaternary.js} +21 -21
- package/lib/node/html/heading/secondary.js +129 -0
- package/lib/node/html/heading/tertiary.js +129 -0
- package/lib/node/html/image.js +214 -0
- package/lib/node/html/indexList.js +128 -0
- package/lib/node/html/item/contents.js +128 -0
- package/lib/node/html/item/footnotes.js +128 -0
- package/lib/node/{markdown/indexItem.js → html/item/index.js} +36 -15
- package/lib/node/html/item/ordered.js +17 -2
- package/lib/node/html/item/unordered.js +128 -0
- package/lib/node/html/line.js +174 -0
- package/lib/node/html/{contentsLink.js → link/contents.js} +19 -4
- package/lib/node/html/link/email.js +229 -0
- package/lib/node/html/link/footnote.js +137 -0
- package/lib/node/html/link/hyper.js +229 -0
- package/lib/node/html/link/index.js +202 -0
- package/lib/node/html/list/contents.js +128 -0
- package/lib/node/html/list/footnotes.js +144 -0
- package/lib/node/html/list/ordered.js +128 -0
- package/lib/node/html/list/unordered.js +128 -0
- package/lib/node/html/{blockListing.js → listing/block.js} +18 -9
- package/lib/node/html/listing/inline.js +189 -0
- package/lib/node/html/pageNumber.js +170 -0
- package/lib/node/html/{className.js → paragraph.js} +26 -18
- package/lib/node/{markdown/nonsense.js → html/table.js} +22 -15
- package/lib/node/{markdown/blockListingEnd.js → html/tableBody.js} +22 -15
- package/lib/node/html/tableBodyCell.js +128 -0
- package/lib/node/html/tableBodyRow.js +128 -0
- package/lib/node/html/{blockListingStart.js → tableHead.js} +26 -18
- package/lib/node/html/tableHeadCell.js +128 -0
- package/lib/node/html/tableHeadRow.js +128 -0
- package/lib/node/html/text/block.js +128 -0
- package/lib/node/html/text/emphasised.js +128 -0
- package/lib/node/html/text/inline.js +196 -0
- package/lib/node/html/text/plain.js +128 -0
- package/lib/node/html/text/strong.js +128 -0
- package/lib/node/html/text/stronglyEmphasised.js +212 -0
- package/lib/node/html/text.js +141 -0
- package/lib/node/html/topmost.js +57 -10
- package/lib/node/html.js +130 -40
- package/lib/node/markdown/anchor.js +6 -22
- package/lib/node/markdown/{table.js → blockEnd.js} +10 -10
- package/lib/node/markdown/blockListing.js +4 -31
- package/lib/node/markdown/{blockListingStart.js → blockStart.js} +10 -24
- package/lib/node/markdown/className.js +2 -2
- package/lib/node/markdown/contentsItem.js +4 -4
- package/lib/node/markdown/contentsList.js +2 -10
- package/lib/node/markdown/directive/embee.js +13 -13
- package/lib/node/markdown/directive/include.js +13 -13
- package/lib/node/markdown/directive/pageNumber.js +13 -29
- package/lib/node/markdown/division.js +205 -254
- package/lib/node/markdown/emailLink.js +36 -98
- package/lib/node/markdown/emphasisedText.js +3 -54
- package/lib/node/markdown/error.js +9 -53
- package/lib/node/markdown/footnote.js +1 -15
- package/lib/node/markdown/footnoteLink.js +9 -32
- package/lib/node/markdown/footnotesList.js +1 -16
- package/lib/node/markdown/heading/primary.js +1 -2
- package/lib/node/markdown/heading/quaternary.js +1 -2
- package/lib/node/markdown/heading/secondary.js +1 -2
- package/lib/node/markdown/heading/tertiary.js +1 -2
- package/lib/node/markdown/heading.js +1 -13
- package/lib/node/markdown/hyperlink.js +44 -108
- package/lib/node/markdown/image.js +2 -63
- package/lib/node/markdown/indexLink.js +13 -87
- package/lib/node/markdown/indexList.js +2 -10
- package/lib/node/markdown/inlineListing.js +22 -56
- package/lib/node/markdown/inlineText.js +3 -21
- package/lib/node/markdown/item/ordered.js +6 -6
- package/lib/node/markdown/line.js +1 -74
- package/lib/node/markdown/path.js +7 -7
- package/lib/node/markdown/strongText.js +3 -54
- package/lib/node/markdown/stronglyEmphasisedText.js +3 -78
- package/lib/node/markdown/{tableCellDivider.js → text/block.js} +12 -12
- package/lib/node/markdown/{tableBody.js → text/plain.js} +12 -12
- package/lib/node/markdown/text.js +154 -0
- package/lib/node/markdown/topmost.js +191 -0
- package/lib/node/markdown.js +6 -229
- package/lib/queries.js +4 -45
- package/lib/ruleNames.js +34 -21
- package/lib/style/selector.js +11 -7
- package/lib/transform/contentsItem.js +134 -0
- package/lib/transform/contentsLink.js +115 -0
- package/lib/transform/contentsList.js +194 -0
- package/lib/{replacement/subDivision.js → transform/division.js} +33 -38
- package/lib/{replacement → transform}/embedDirective.js +14 -19
- package/lib/{replacement → transform}/footnote.js +18 -23
- package/lib/transform/footnotesItem.js +123 -0
- package/lib/transform/footnotesList.js +173 -0
- package/lib/{replacement → transform}/includeDirective.js +13 -18
- package/lib/transform/index.js +166 -0
- package/lib/{replacement → transform}/indexAnchor.js +13 -13
- package/lib/{replacement → transform}/indexHeading.js +13 -18
- package/lib/{replacement → transform}/indexItem.js +13 -18
- package/lib/transform/indexList.js +121 -0
- package/lib/{replacement → transform}/line.js +13 -18
- package/lib/{replacement → transform}/subDivision/contentsDirective.js +14 -14
- package/lib/transform/subDivision/embedDirectives.js +147 -0
- package/lib/{replacement → transform}/subDivision/footnote.js +14 -14
- package/lib/{replacement → transform}/subDivision/footnotesDirective.js +14 -14
- package/lib/transform/subDivision/includeDirectives.js +142 -0
- package/lib/{replacement → transform}/subDivision/indexDirective.js +14 -14
- package/lib/{replacement → transform}/subDivision/pageNumberDirective.js +14 -14
- package/lib/utilities/content.js +1 -61
- package/lib/utilities/entities.js +17 -0
- package/lib/utilities/entries.js +6 -6
- package/lib/utilities/html.js +67 -9
- package/lib/utilities/markdown.js +45 -0
- package/lib/utilities/parser.js +8 -2
- package/lib/utilities/query.js +2 -22
- package/package.json +2 -2
- package/src/example/importer.js +2 -4
- package/src/example/view/div/container/markdown.js +2 -2
- package/src/example/view/div/preview.js +6 -0
- package/src/example/view/textarea/parseTree/html.js +28 -0
- package/src/example/view/textarea/parseTree/markdown.js +19 -1
- package/src/example/view/textarea/plainText.js +9 -1
- package/src/example/view/xmp.js +9 -1
- package/src/example/view.js +84 -91
- package/src/index/match.js +6 -6
- package/src/index.js +6 -3
- package/src/map/className.js +16 -0
- package/src/map/node/html.js +136 -0
- package/src/map/node/markdown.js +125 -0
- package/src/map/tagName.js +16 -0
- package/src/markdown/bnf.js +85 -64
- package/src/markdown/parser.js +3 -1
- package/src/markdownStyle/entries.js +3 -3
- package/src/mixins/node.js +29 -34
- package/src/node/html/anchor.js +26 -5
- package/src/node/html/blockLine.js +58 -7
- package/src/node/html/division.js +15 -0
- package/src/node/html/error.js +64 -0
- package/src/node/html/footnote.js +17 -0
- package/src/node/html/heading/index.js +13 -0
- package/src/node/html/heading/primary.js +15 -0
- package/src/node/html/heading/quaternary.js +15 -0
- package/src/node/html/heading/secondary.js +15 -0
- package/src/node/html/heading/tertiary.js +15 -0
- package/src/node/html/image.js +107 -0
- package/src/node/html/indexList.js +13 -0
- package/src/node/html/item/contents.js +13 -0
- package/src/node/html/item/footnotes.js +13 -0
- package/src/node/{markdown/indexItem.js → html/item/index.js} +9 -3
- package/src/node/html/item/ordered.js +5 -1
- package/src/node/html/item/unordered.js +13 -0
- package/src/node/html/line.js +64 -0
- package/src/node/html/{contentsLink.js → link/contents.js} +7 -3
- package/src/node/html/link/email.js +96 -0
- package/src/node/html/link/footnote.js +33 -0
- package/src/node/html/link/hyper.js +96 -0
- package/src/node/html/link/index.js +72 -0
- package/src/node/html/list/contents.js +13 -0
- package/src/node/html/list/footnotes.js +27 -0
- package/src/node/html/list/ordered.js +13 -0
- package/src/node/html/list/unordered.js +13 -0
- package/src/node/html/{blockListing.js → listing/block.js} +5 -8
- package/src/node/html/listing/inline.js +61 -0
- package/src/node/html/pageNumber.js +46 -0
- package/src/node/html/paragraph.js +13 -0
- package/src/node/html/table.js +13 -0
- package/src/node/html/tableBody.js +13 -0
- package/src/node/html/tableBodyCell.js +13 -0
- package/src/node/html/tableBodyRow.js +13 -0
- package/src/node/html/tableHead.js +13 -0
- package/src/node/html/tableHeadCell.js +13 -0
- package/src/node/html/tableHeadRow.js +13 -0
- package/src/node/html/text/block.js +13 -0
- package/src/node/html/text/emphasised.js +13 -0
- package/src/node/html/text/inline.js +57 -0
- package/src/node/html/text/plain.js +13 -0
- package/src/node/html/text/strong.js +13 -0
- package/src/node/html/text/stronglyEmphasised.js +98 -0
- package/src/node/html/text.js +34 -0
- package/src/node/html/topmost.js +57 -8
- package/src/node/html.js +136 -53
- package/src/node/markdown/anchor.js +5 -25
- package/src/node/markdown/{table.js → blockEnd.js} +2 -2
- package/src/node/markdown/blockListing.js +4 -10
- package/src/node/markdown/{blockListingStart.js → blockStart.js} +4 -6
- package/src/node/markdown/className.js +2 -2
- package/src/node/markdown/contentsItem.js +4 -4
- package/src/node/markdown/contentsList.js +0 -6
- package/src/node/markdown/directive/embee.js +10 -10
- package/src/node/markdown/directive/include.js +10 -10
- package/src/node/markdown/directive/pageNumber.js +10 -29
- package/src/node/markdown/division.js +203 -260
- package/src/node/markdown/emailLink.js +41 -87
- package/src/node/markdown/emphasisedText.js +1 -40
- package/src/node/markdown/error.js +9 -40
- package/src/node/markdown/footnote.js +0 -12
- package/src/node/markdown/footnoteLink.js +8 -31
- package/src/node/markdown/footnotesList.js +0 -13
- package/src/node/markdown/heading/primary.js +0 -2
- package/src/node/markdown/heading/quaternary.js +0 -2
- package/src/node/markdown/heading/secondary.js +0 -2
- package/src/node/markdown/heading/tertiary.js +0 -2
- package/src/node/markdown/heading.js +0 -14
- package/src/node/markdown/hyperlink.js +41 -91
- package/src/node/markdown/image.js +1 -82
- package/src/node/markdown/indexLink.js +10 -69
- package/src/node/markdown/indexList.js +0 -6
- package/src/node/markdown/inlineListing.js +20 -40
- package/src/node/markdown/inlineText.js +1 -21
- package/src/node/markdown/item/ordered.js +3 -3
- package/src/node/markdown/line.js +0 -61
- package/src/node/markdown/path.js +5 -5
- package/src/node/markdown/strongText.js +1 -40
- package/src/node/markdown/stronglyEmphasisedText.js +1 -74
- package/src/node/markdown/text/block.js +7 -0
- package/src/node/markdown/text/plain.js +7 -0
- package/src/node/markdown/text.js +80 -0
- package/src/node/markdown/topmost.js +91 -0
- package/src/node/markdown.js +1 -200
- package/src/queries.js +6 -86
- package/src/ruleNames.js +16 -12
- package/src/style/selector.js +16 -10
- package/src/transform/contentsItem.js +55 -0
- package/src/{replacement → transform}/contentsLink.js +10 -9
- package/src/{replacement → transform}/contentsList.js +26 -26
- package/src/transform/division.js +41 -0
- package/src/{replacement → transform}/embedDirective.js +4 -4
- package/src/{replacement → transform}/footnote.js +7 -7
- package/src/transform/footnotesItem.js +25 -0
- package/src/transform/footnotesList.js +79 -0
- package/src/{replacement → transform}/includeDirective.js +4 -4
- package/src/transform/index.js +90 -0
- package/src/{replacement → transform}/indexAnchor.js +5 -4
- package/src/{replacement → transform}/indexHeading.js +4 -4
- package/src/{replacement → transform}/indexItem.js +4 -4
- package/src/transform/indexList.js +33 -0
- package/src/{replacement → transform}/line.js +4 -4
- package/src/transform/subDivision/contentsDirective.js +20 -0
- package/src/transform/subDivision/embedDirectives.js +52 -0
- package/src/{replacement → transform}/subDivision/footnote.js +5 -5
- package/src/transform/subDivision/footnotesDirective.js +20 -0
- package/src/transform/subDivision/includeDirectives.js +48 -0
- package/src/transform/subDivision/indexDirective.js +20 -0
- package/src/transform/subDivision/pageNumberDirective.js +20 -0
- package/src/utilities/content.js +0 -95
- package/src/utilities/entities.js +11 -0
- package/src/utilities/entries.js +3 -3
- package/src/utilities/html.js +69 -6
- package/src/utilities/markdown.js +32 -0
- package/src/utilities/parser.js +3 -2
- package/src/utilities/query.js +8 -28
- package/lib/classFromOuterNode.js +0 -30
- package/lib/elementMap.js +0 -218
- package/lib/example/view/textarea/parseTree/markdown/inner.js +0 -179
- package/lib/mixins/content.js +0 -21
- package/lib/mixins/element.js +0 -32
- package/lib/node/html/comma.js +0 -127
- package/lib/node/html/directive/pageNumber.js +0 -178
- package/lib/node/markdown/blockLine.js +0 -207
- package/lib/node/markdown/comma.js +0 -123
- package/lib/node/markdown/directive/contents.js +0 -107
- package/lib/node/markdown/directive/footnotes.js +0 -107
- package/lib/node/markdown/directive/ignore.js +0 -107
- package/lib/node/markdown/directive/index.js +0 -107
- package/lib/node/markdown/directives.js +0 -125
- package/lib/node/markdown/emptyTableCell.js +0 -122
- package/lib/node/markdown/endOfLine.js +0 -151
- package/lib/node/markdown/indexHeading.js +0 -107
- package/lib/node/markdown/item/unordered.js +0 -107
- package/lib/node/markdown/item.js +0 -107
- package/lib/node/markdown/orderedList.js +0 -107
- package/lib/node/markdown/plainText.js +0 -115
- package/lib/node/markdown/subDivision.js +0 -161
- package/lib/node/markdown/tableBodyCell.js +0 -128
- package/lib/node/markdown/tableBodyRow.js +0 -107
- package/lib/node/markdown/tableCell.js +0 -118
- package/lib/node/markdown/tableDivider.js +0 -107
- package/lib/node/markdown/tableHead.js +0 -107
- package/lib/node/markdown/tableHeadCell.js +0 -128
- package/lib/node/markdown/tableHeadRow.js +0 -107
- package/lib/node/markdown/unorderedList.js +0 -107
- package/lib/node/markdown/verticalSpace.js +0 -151
- package/lib/nodeMap.js +0 -98
- package/lib/replacement/contentsItem.js +0 -134
- package/lib/replacement/contentsLink.js +0 -115
- package/lib/replacement/contentsList.js +0 -194
- package/lib/replacement/footnotesItem.js +0 -123
- package/lib/replacement/footnotesList.js +0 -173
- package/lib/replacement/index.js +0 -166
- package/lib/replacement/indexList.js +0 -121
- package/lib/replacement/subDivision/embedDirectives.js +0 -143
- package/lib/replacement/subDivision/includeDirectives.js +0 -175
- package/lib/replacement.js +0 -262
- package/lib/ruleNameToClassMap.js +0 -44
- package/lib/utilities/childNodes.js +0 -127
- package/lib/utilities/processing.js +0 -106
- package/lib/utilities/replacement.js +0 -195
- package/src/classFromOuterNode.js +0 -20
- package/src/elementMap.js +0 -322
- package/src/example/view/textarea/parseTree/markdown/inner.js +0 -36
- package/src/example/view/textarea/parseTree/markdown/outer.js +0 -27
- package/src/mixins/content.js +0 -16
- package/src/mixins/element.js +0 -29
- package/src/node/html/blockListingEnd.js +0 -11
- package/src/node/html/blockListingStart.js +0 -11
- package/src/node/html/className.js +0 -11
- package/src/node/html/comma.js +0 -18
- package/src/node/html/directive/pageNumber.js +0 -55
- package/src/node/markdown/blockLine.js +0 -90
- package/src/node/markdown/blockListingEnd.js +0 -9
- package/src/node/markdown/comma.js +0 -23
- package/src/node/markdown/directive/contents.js +0 -7
- package/src/node/markdown/directive/footnotes.js +0 -7
- package/src/node/markdown/directive/ignore.js +0 -7
- package/src/node/markdown/directive/index.js +0 -7
- package/src/node/markdown/directive.js +0 -15
- package/src/node/markdown/directives.js +0 -25
- package/src/node/markdown/emptyTableCell.js +0 -19
- package/src/node/markdown/endOfLine.js +0 -39
- package/src/node/markdown/indexHeading.js +0 -7
- package/src/node/markdown/item/unordered.js +0 -7
- package/src/node/markdown/item.js +0 -7
- package/src/node/markdown/nonsense.js +0 -9
- package/src/node/markdown/orderedList.js +0 -7
- package/src/node/markdown/plainText.js +0 -13
- package/src/node/markdown/subDivision.js +0 -64
- package/src/node/markdown/tableBody.js +0 -7
- package/src/node/markdown/tableBodyCell.js +0 -29
- package/src/node/markdown/tableBodyRow.js +0 -7
- package/src/node/markdown/tableCell.js +0 -19
- package/src/node/markdown/tableCellDivider.js +0 -7
- package/src/node/markdown/tableDivider.js +0 -7
- package/src/node/markdown/tableHead.js +0 -7
- package/src/node/markdown/tableHeadCell.js +0 -29
- package/src/node/markdown/tableHeadRow.js +0 -7
- package/src/node/markdown/unorderedList.js +0 -7
- package/src/node/markdown/verticalSpace.js +0 -39
- package/src/nodeMap.js +0 -200
- package/src/replacement/contentsItem.js +0 -54
- package/src/replacement/footnotesItem.js +0 -24
- package/src/replacement/footnotesList.js +0 -78
- package/src/replacement/index.js +0 -89
- package/src/replacement/indexList.js +0 -32
- package/src/replacement/subDivision/contentsDirective.js +0 -20
- package/src/replacement/subDivision/embedDirectives.js +0 -52
- package/src/replacement/subDivision/footnotesDirective.js +0 -20
- package/src/replacement/subDivision/includeDirectives.js +0 -58
- package/src/replacement/subDivision/indexDirective.js +0 -20
- package/src/replacement/subDivision/pageNumberDirective.js +0 -20
- package/src/replacement/subDivision.js +0 -41
- package/src/replacement.js +0 -185
- package/src/ruleNameToClassMap.js +0 -38
- package/src/utilities/childNodes.js +0 -178
- package/src/utilities/processing.js +0 -122
- package/src/utilities/replacement.js +0 -169
|
@@ -2,27 +2,12 @@
|
|
|
2
2
|
|
|
3
3
|
import MarkdownNode from "../../node/markdown";
|
|
4
4
|
|
|
5
|
-
import { ALT_ATTRIBUTE_NAME, SRC_ATTRIBUTE_NAME} from "../../attributeNames";
|
|
6
|
-
|
|
7
5
|
export default class ImageMarkdownNode extends MarkdownNode {
|
|
8
|
-
alt(context) {
|
|
9
|
-
const alt = this.fromSecondChildNode((secondChildNode) => {
|
|
10
|
-
const inlineTextMarkdownNode = secondChildNode, ///
|
|
11
|
-
inlineTextMarkdownNodeContent = inlineTextMarkdownNode.content(context),
|
|
12
|
-
alt = inlineTextMarkdownNodeContent; ///
|
|
13
|
-
|
|
14
|
-
return alt;
|
|
15
|
-
});
|
|
16
|
-
|
|
17
|
-
return alt;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
6
|
src(context) {
|
|
21
7
|
const { pathToURL = null } = context,
|
|
22
8
|
src = this.fromSecondLastChildNode((secondLastChildNode) => {
|
|
23
9
|
const pathMarkdownNode = secondLastChildNode, ///
|
|
24
|
-
|
|
25
|
-
path = pathMarkdownNodeContent, ///
|
|
10
|
+
path = pathMarkdownNode.path(context), ///
|
|
26
11
|
src = (pathToURL === null) ?
|
|
27
12
|
path : ///
|
|
28
13
|
pathToURL(path);
|
|
@@ -33,71 +18,5 @@ export default class ImageMarkdownNode extends MarkdownNode {
|
|
|
33
18
|
return src;
|
|
34
19
|
}
|
|
35
20
|
|
|
36
|
-
asHTML(indent, context) {
|
|
37
|
-
indent = this.adjustIndent(indent);
|
|
38
|
-
|
|
39
|
-
const selfClosingTag = this.selfClosingTag(context),
|
|
40
|
-
html = (indent === null) ?
|
|
41
|
-
selfClosingTag : ///
|
|
42
|
-
`${indent}${selfClosingTag}
|
|
43
|
-
`;
|
|
44
|
-
|
|
45
|
-
return html;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
createDOMElement(context) {
|
|
49
|
-
const tagName = this.tagName(context),
|
|
50
|
-
domElement = document.createElement(tagName),
|
|
51
|
-
attributeNames = this.attributeNames(context),
|
|
52
|
-
attributeValues = this.attributeValues(context);
|
|
53
|
-
|
|
54
|
-
attributeNames.forEach((attributeName, index) => {
|
|
55
|
-
const attributeValue = attributeValues[index];
|
|
56
|
-
|
|
57
|
-
domElement.setAttribute(attributeName, attributeValue);
|
|
58
|
-
});
|
|
59
|
-
|
|
60
|
-
return domElement;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
selfClosingTag(context) {
|
|
64
|
-
const tagName = this.tagName(context),
|
|
65
|
-
attributeNames = this.attributeNames(context),
|
|
66
|
-
attributeValues = this.attributeValues(context),
|
|
67
|
-
attributesHTML = attributeNames.reduce((attributesHML, attributeName, index) => {
|
|
68
|
-
const attributeValue = attributeValues[index];
|
|
69
|
-
|
|
70
|
-
attributesHML = (attributesHML === null) ?
|
|
71
|
-
`${attributeName}="${attributeValue}"` :
|
|
72
|
-
`${attributesHML} ${attributeName}="${attributeValue}"`;
|
|
73
|
-
|
|
74
|
-
return attributesHML;
|
|
75
|
-
|
|
76
|
-
}, null),
|
|
77
|
-
selfClosingTag = `<${tagName} ${attributesHTML}/>`;
|
|
78
|
-
|
|
79
|
-
return selfClosingTag;
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
attributeNames(context) {
|
|
83
|
-
const attributeNames = [
|
|
84
|
-
ALT_ATTRIBUTE_NAME,
|
|
85
|
-
SRC_ATTRIBUTE_NAME
|
|
86
|
-
];
|
|
87
|
-
|
|
88
|
-
return attributeNames;
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
attributeValues(context) {
|
|
92
|
-
const alt = this.alt(context),
|
|
93
|
-
src = this.src(context),
|
|
94
|
-
attributeValues = [
|
|
95
|
-
alt,
|
|
96
|
-
src
|
|
97
|
-
];
|
|
98
|
-
|
|
99
|
-
return attributeValues;
|
|
100
|
-
}
|
|
101
|
-
|
|
102
21
|
static fromRuleNameChildNodesAndOpacity(ruleName, childNodes, opacity) { return MarkdownNode.fromRuleNameChildNodesAndOpacity(ImageMarkdownNode, ruleName, childNodes, opacity); }
|
|
103
22
|
}
|
|
@@ -2,76 +2,17 @@
|
|
|
2
2
|
|
|
3
3
|
import MarkdownNode from "../../node/markdown";
|
|
4
4
|
|
|
5
|
-
import { INDEX_PREPEND } from "../../prepends";
|
|
6
|
-
import { HREF_ATTRIBUTE_NAME } from "../../attributeNames";
|
|
7
|
-
|
|
8
5
|
export default class IndexLinkMarkdownNode extends MarkdownNode {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
return attributeValue;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
createDOMElement(context) {
|
|
23
|
-
let domElement;
|
|
24
|
-
|
|
25
|
-
const content = this.content(context),
|
|
26
|
-
textNode = document.createTextNode(content);
|
|
27
|
-
|
|
28
|
-
domElement = super.createDOMElement(context);
|
|
29
|
-
|
|
30
|
-
const parentDOMElement = domElement; ///
|
|
31
|
-
|
|
32
|
-
domElement = textNode; ///
|
|
33
|
-
|
|
34
|
-
parentDOMElement.appendChild(domElement);
|
|
35
|
-
|
|
36
|
-
domElement = parentDOMElement; ///
|
|
37
|
-
|
|
38
|
-
return domElement;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
asHTML(indent, context) {
|
|
42
|
-
const childNodesHTML = this.childNodesAsHTML(indent, context),
|
|
43
|
-
startingTag = this.startingTag(context),
|
|
44
|
-
closingTag = this.closingTag(context),
|
|
45
|
-
html = `${startingTag}${childNodesHTML}${closingTag}`;
|
|
46
|
-
|
|
47
|
-
return html;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
childNodesAsHTML(indent, context) {
|
|
51
|
-
const content = this.content(context),
|
|
52
|
-
childNodesHTML = content; ///
|
|
53
|
-
|
|
54
|
-
return childNodesHTML;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
createChildNodeDOMElements(context) {
|
|
58
|
-
const content = this.content(context),
|
|
59
|
-
textNode = document.createTextNode(content),
|
|
60
|
-
domElement = textNode; ///
|
|
61
|
-
|
|
62
|
-
this.addDOMElement(domElement);
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
content(context) {
|
|
66
|
-
const content = this.fromFirstChildNode((firstChildNode) => {
|
|
67
|
-
const terminalNode = firstChildNode, ///
|
|
68
|
-
content = terminalNode.getContent();
|
|
69
|
-
|
|
70
|
-
return content;
|
|
71
|
-
});
|
|
72
|
-
|
|
73
|
-
return content;
|
|
74
|
-
}
|
|
6
|
+
// content(context) {
|
|
7
|
+
// const content = this.fromFirstChildNode((firstChildNode) => {
|
|
8
|
+
// const terminalNode = firstChildNode, ///
|
|
9
|
+
// content = terminalNode.getContent();
|
|
10
|
+
//
|
|
11
|
+
// return content;
|
|
12
|
+
// });
|
|
13
|
+
//
|
|
14
|
+
// return content;
|
|
15
|
+
// }
|
|
75
16
|
|
|
76
17
|
static fromRuleNameChildNodesAndOpacity(ruleName, childNodes, opacity) { return MarkdownNode.fromRuleNameChildNodesAndOpacity(IndexLinkMarkdownNode, ruleName, childNodes, opacity); }
|
|
77
18
|
}
|
|
@@ -5,12 +5,6 @@ import MarkdownNode from "../../node/markdown";
|
|
|
5
5
|
import { INDEX_LIST_RULE_NAME } from "../../ruleNames";
|
|
6
6
|
|
|
7
7
|
export default class IndexListMarkdownNode extends MarkdownNode {
|
|
8
|
-
asPlainText(context) {
|
|
9
|
-
const plainText = null;
|
|
10
|
-
|
|
11
|
-
return plainText;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
8
|
static fromIndexItemReplacements(indexItemReplacements) {
|
|
15
9
|
const ruleName = INDEX_LIST_RULE_NAME,
|
|
16
10
|
childNodes = indexItemReplacements.map((indexItemReplacement) => {
|
|
@@ -1,48 +1,28 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
import MarkdownNode from "../../node/markdown";
|
|
4
|
-
import contentMixins from "../../mixins/content";
|
|
5
4
|
|
|
6
|
-
import { replaceEntities } from "../../utilities/html";
|
|
7
5
|
import { removeBackticks } from "../../utilities/string";
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
domElement = parentDOMElement; ///
|
|
29
|
-
|
|
30
|
-
return domElement;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
childNodesAsHTML(indent, context) {
|
|
34
|
-
let content = this.content(context);
|
|
35
|
-
|
|
36
|
-
content = removeBackticks(content); ///
|
|
37
|
-
|
|
38
|
-
const childNodesHTML = content; ///
|
|
39
|
-
|
|
40
|
-
return childNodesHTML;
|
|
41
|
-
}
|
|
6
|
+
import { replaceEntities } from "../../utilities/entities";
|
|
7
|
+
|
|
8
|
+
export default class InlineListingMarkdownNode extends MarkdownNode {
|
|
9
|
+
// content(context) {
|
|
10
|
+
// const content = this.fromFirstChildNode((firstChildNode) => {
|
|
11
|
+
// let content;
|
|
12
|
+
//
|
|
13
|
+
// const backtickedLiteralTerminalNode = firstChildNode; ///
|
|
14
|
+
//
|
|
15
|
+
// content = backtickedLiteralTerminalNode.getContent();
|
|
16
|
+
//
|
|
17
|
+
// content = removeBackticks(content); ///
|
|
18
|
+
//
|
|
19
|
+
// content = replaceEntities(content); ///
|
|
20
|
+
//
|
|
21
|
+
// return content;
|
|
22
|
+
// });
|
|
23
|
+
//
|
|
24
|
+
// return content;
|
|
25
|
+
// }
|
|
42
26
|
|
|
43
27
|
static fromRuleNameChildNodesAndOpacity(ruleName, childNodes, opacity) { return MarkdownNode.fromRuleNameChildNodesAndOpacity(InlineListingMarkdownNode, ruleName, childNodes, opacity); }
|
|
44
28
|
}
|
|
45
|
-
|
|
46
|
-
Object.assign(InlineListingMarkdownNode.prototype, contentMixins);
|
|
47
|
-
|
|
48
|
-
export default InlineListingMarkdownNode;
|
|
@@ -1,27 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
import MarkdownNode from "../../node/markdown";
|
|
4
|
-
import contentMixins from "../../mixins/content";
|
|
5
|
-
|
|
6
|
-
class InlineTextMarkdownNode extends MarkdownNode {
|
|
7
|
-
asHTML(indent, context) {
|
|
8
|
-
const content = this.content(context),
|
|
9
|
-
html = content; ///
|
|
10
|
-
|
|
11
|
-
return html;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
createDOMElement(context) {
|
|
15
|
-
const content = this.content(context),
|
|
16
|
-
textNode = document.createTextNode(content),
|
|
17
|
-
domElement = textNode; ///
|
|
18
|
-
|
|
19
|
-
return domElement;
|
|
20
|
-
}
|
|
21
4
|
|
|
5
|
+
export default class InlineTextMarkdownNode extends MarkdownNode {
|
|
22
6
|
static fromRuleNameChildNodesAndOpacity(ruleName, childNodes, opacity) { return MarkdownNode.fromRuleNameChildNodesAndOpacity(InlineTextMarkdownNode, ruleName, childNodes, opacity); }
|
|
23
7
|
}
|
|
24
|
-
|
|
25
|
-
Object.assign(InlineTextMarkdownNode.prototype, contentMixins);
|
|
26
|
-
|
|
27
|
-
export default InlineTextMarkdownNode;
|
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
|
|
3
3
|
import { arrayUtilities } from "necessary";
|
|
4
4
|
|
|
5
|
-
import
|
|
5
|
+
import MarkdownNode from "../../../node/markdown";
|
|
6
6
|
|
|
7
7
|
const { second } = arrayUtilities;
|
|
8
8
|
|
|
9
|
-
export default class OrderedItemMarkdownNode extends
|
|
9
|
+
export default class OrderedItemMarkdownNode extends MarkdownNode {
|
|
10
10
|
value(context) {
|
|
11
11
|
const value = this.fromFirstChildNode((firstChildNode) => {
|
|
12
12
|
const markerTerminalNode = firstChildNode, ///
|
|
@@ -18,7 +18,7 @@ export default class OrderedItemMarkdownNode extends ItemNode {
|
|
|
18
18
|
return value;
|
|
19
19
|
}
|
|
20
20
|
|
|
21
|
-
static fromRuleNameChildNodesAndOpacity(ruleName, childNodes, opacity) { return
|
|
21
|
+
static fromRuleNameChildNodesAndOpacity(ruleName, childNodes, opacity) { return MarkdownNode.fromRuleNameChildNodesAndOpacity(OrderedItemMarkdownNode, ruleName, childNodes, opacity); }
|
|
22
22
|
}
|
|
23
23
|
|
|
24
24
|
function valueFromMarkerTerminalNode(markerTerminalNode) {
|
|
@@ -2,8 +2,6 @@
|
|
|
2
2
|
|
|
3
3
|
import MarkdownNode from "../../node/markdown";
|
|
4
4
|
|
|
5
|
-
import { htmlFromMarkdownNode, plainTextFromMarkdownNode, domElementsFromMarkdownNode } from "../../utilities/childNodes";
|
|
6
|
-
|
|
7
5
|
export default class LineMarkdownNode extends MarkdownNode {
|
|
8
6
|
lines(context) {
|
|
9
7
|
const { charactersPerLine } = context,
|
|
@@ -15,64 +13,5 @@ export default class LineMarkdownNode extends MarkdownNode {
|
|
|
15
13
|
return lines;
|
|
16
14
|
}
|
|
17
15
|
|
|
18
|
-
mount(parentDOMElement, siblingDOMElement, context) {
|
|
19
|
-
this.domElement = this.createDOMElement(context);
|
|
20
|
-
|
|
21
|
-
parentDOMElement.insertBefore(this.domElement, siblingDOMElement);
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
unmount(parentDOMElement, context) {
|
|
25
|
-
if (this.domElement !== null) {
|
|
26
|
-
parentDOMElement.removeChild(this.domElement);
|
|
27
|
-
|
|
28
|
-
this.domElement = null;
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
createDOMElement(context) {
|
|
33
|
-
const markdownNode = this,
|
|
34
|
-
domElement = super.createDOMElement(context),
|
|
35
|
-
domElements = domElementsFromMarkdownNode(markdownNode, context),
|
|
36
|
-
parentDOMElement = domElement, ///
|
|
37
|
-
childNodeDOMElements = domElements; ///
|
|
38
|
-
|
|
39
|
-
childNodeDOMElements.forEach((childNodeDOMElement) => {
|
|
40
|
-
const domElement = childNodeDOMElement; ///
|
|
41
|
-
|
|
42
|
-
parentDOMElement.appendChild(domElement);
|
|
43
|
-
});
|
|
44
|
-
|
|
45
|
-
return domElement;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
asHTML(indent, context) {
|
|
49
|
-
indent = this.adjustIndent(indent);
|
|
50
|
-
|
|
51
|
-
const childNodesHTML = this.childNodesAsHTML(indent, context),
|
|
52
|
-
startingTag = this.startingTag(context),
|
|
53
|
-
closingTag = this.closingTag(context),
|
|
54
|
-
html = (indent !== null) ?
|
|
55
|
-
`${indent}${startingTag}${childNodesHTML}${closingTag}
|
|
56
|
-
`: `${startingTag}${childNodesHTML}${closingTag}`;
|
|
57
|
-
|
|
58
|
-
return html;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
childNodesAsHTML(indent, context) {
|
|
62
|
-
const markdownNode = this,
|
|
63
|
-
html = htmlFromMarkdownNode(markdownNode, context),
|
|
64
|
-
childNodesHTML = html; ///
|
|
65
|
-
|
|
66
|
-
return childNodesHTML;
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
childNodesAsPlainText(context) {
|
|
70
|
-
const markdownNode = this, ///
|
|
71
|
-
plainText = plainTextFromMarkdownNode(markdownNode, context),
|
|
72
|
-
childNodesPlainText = plainText; ///
|
|
73
|
-
|
|
74
|
-
return childNodesPlainText;
|
|
75
|
-
}
|
|
76
|
-
|
|
77
16
|
static fromRuleNameChildNodesAndOpacity(ruleName, childNodes, opacity) { return MarkdownNode.fromRuleNameChildNodesAndOpacity(LineMarkdownNode, ruleName, childNodes, opacity); }
|
|
78
17
|
}
|
|
@@ -3,16 +3,16 @@
|
|
|
3
3
|
import MarkdownNode from "../../node/markdown";
|
|
4
4
|
|
|
5
5
|
export default class PathMarkdownNode extends MarkdownNode {
|
|
6
|
-
|
|
7
|
-
const
|
|
6
|
+
path(context) {
|
|
7
|
+
const path = this.fromFirstChildNode((firstChildNode) => {
|
|
8
8
|
const pathTerminalNode = firstChildNode, ///
|
|
9
9
|
pathTerminalNodeContent = pathTerminalNode.getContent(),
|
|
10
|
-
|
|
10
|
+
path = pathTerminalNodeContent; ///
|
|
11
11
|
|
|
12
|
-
return
|
|
12
|
+
return path;
|
|
13
13
|
});
|
|
14
14
|
|
|
15
|
-
return
|
|
15
|
+
return path;
|
|
16
16
|
}
|
|
17
17
|
|
|
18
18
|
static fromRuleNameChildNodesAndOpacity(ruleName, childNodes, opacity) { return MarkdownNode.fromRuleNameChildNodesAndOpacity(PathMarkdownNode, ruleName, childNodes, opacity); }
|
|
@@ -1,46 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
import MarkdownNode from "../../node/markdown";
|
|
4
|
-
import contentMixins from "../../mixins/content";
|
|
5
|
-
|
|
6
|
-
class StrongTextMarkdownNode extends MarkdownNode {
|
|
7
|
-
inlineText(context) {
|
|
8
|
-
const inlineText = this.fromSecondChildNode((secondChildNode) => {
|
|
9
|
-
const indent = null,
|
|
10
|
-
inlineTextMarkdownNode = secondChildNode, ///
|
|
11
|
-
inlineTextMarkdownNodeHTML = inlineTextMarkdownNode.asHTML(indent, context),
|
|
12
|
-
inlineText = inlineTextMarkdownNodeHTML; ///
|
|
13
|
-
|
|
14
|
-
return inlineText;
|
|
15
|
-
});
|
|
16
|
-
|
|
17
|
-
return inlineText;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
createDOMElement(context) {
|
|
21
|
-
const inlineText = this.inlineText(context),
|
|
22
|
-
content = inlineText; ///
|
|
23
|
-
|
|
24
|
-
let domElement;
|
|
25
|
-
|
|
26
|
-
const textNode = document.createTextNode(content);
|
|
27
|
-
|
|
28
|
-
domElement = super.createDOMElement(context);
|
|
29
|
-
|
|
30
|
-
const parentDOMElement = domElement; ///
|
|
31
|
-
|
|
32
|
-
domElement = textNode; ///
|
|
33
|
-
|
|
34
|
-
parentDOMElement.appendChild(domElement);
|
|
35
|
-
|
|
36
|
-
domElement = parentDOMElement; ///
|
|
37
|
-
|
|
38
|
-
return domElement;
|
|
39
|
-
}
|
|
40
4
|
|
|
5
|
+
export default class StrongTextMarkdownNode extends MarkdownNode {
|
|
41
6
|
static fromRuleNameChildNodesAndOpacity(ruleName, childNodes, opacity) { return MarkdownNode.fromRuleNameChildNodesAndOpacity(StrongTextMarkdownNode, ruleName, childNodes, opacity); }
|
|
42
7
|
}
|
|
43
|
-
|
|
44
|
-
Object.assign(StrongTextMarkdownNode.prototype, contentMixins);
|
|
45
|
-
|
|
46
|
-
export default StrongTextMarkdownNode;
|
|
@@ -1,80 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
import elementMap from "../../elementMap";
|
|
4
3
|
import MarkdownNode from "../../node/markdown";
|
|
5
|
-
import contentMixins from "../../mixins/content";
|
|
6
|
-
|
|
7
|
-
import { STRONG_TEXT_RULE_NAME } from "../../ruleNames";
|
|
8
|
-
|
|
9
|
-
const { tagName } = elementMap[STRONG_TEXT_RULE_NAME];
|
|
10
|
-
|
|
11
|
-
class StronglyEmphasisedTextMarkdownNode extends MarkdownNode {
|
|
12
|
-
inlineText(context) {
|
|
13
|
-
const inlineText = this.fromSecondChildNode((secondChildNode) => {
|
|
14
|
-
const indent = null,
|
|
15
|
-
inlineTextMarkdownNode = secondChildNode, ///
|
|
16
|
-
inlineTextMarkdownNodeHTML = inlineTextMarkdownNode.asHTML(indent, context),
|
|
17
|
-
inlineText = inlineTextMarkdownNodeHTML; ///
|
|
18
|
-
|
|
19
|
-
return inlineText;
|
|
20
|
-
});
|
|
21
|
-
|
|
22
|
-
return inlineText;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
createDOMElement(context) {
|
|
26
|
-
let domElement;
|
|
27
|
-
|
|
28
|
-
domElement = document.createElement(tagName);
|
|
29
|
-
|
|
30
|
-
const parentDOMElement = domElement, ///
|
|
31
|
-
childDOMElement = this.createChildDOMElement(context);
|
|
32
|
-
|
|
33
|
-
domElement = childDOMElement; ///
|
|
34
|
-
|
|
35
|
-
parentDOMElement.appendChild(domElement);
|
|
36
|
-
|
|
37
|
-
domElement = parentDOMElement; ///
|
|
38
|
-
|
|
39
|
-
return domElement;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
createChildDOMElement(context) {
|
|
43
|
-
const inlineText = this.inlineText(context),
|
|
44
|
-
content = inlineText; ///
|
|
45
|
-
|
|
46
|
-
let domElement;
|
|
47
|
-
|
|
48
|
-
const textNode = document.createTextNode(content);
|
|
49
|
-
|
|
50
|
-
domElement = super.createDOMElement(context);
|
|
51
|
-
|
|
52
|
-
const parentDOMElement = domElement; ///
|
|
53
|
-
|
|
54
|
-
domElement = textNode; ///
|
|
55
|
-
|
|
56
|
-
parentDOMElement.appendChild(domElement);
|
|
57
|
-
|
|
58
|
-
domElement = parentDOMElement; ///
|
|
59
|
-
|
|
60
|
-
return domElement;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
asHTML(indent, context) {
|
|
64
|
-
let html = super.asHTML(indent, context);
|
|
65
|
-
|
|
66
|
-
const childNodesHTML = html, ///
|
|
67
|
-
startingTag = `<${tagName}>`,
|
|
68
|
-
closingTag = `</${tagName}>`;
|
|
69
|
-
|
|
70
|
-
html = `${startingTag}${childNodesHTML}${closingTag}`;
|
|
71
|
-
|
|
72
|
-
return html;
|
|
73
|
-
}
|
|
74
4
|
|
|
5
|
+
export default class StronglyEmphasisedTextMarkdownNode extends MarkdownNode {
|
|
75
6
|
static fromRuleNameChildNodesAndOpacity(ruleName, childNodes, opacity) { return MarkdownNode.fromRuleNameChildNodesAndOpacity(StronglyEmphasisedTextMarkdownNode, ruleName, childNodes, opacity); }
|
|
76
7
|
}
|
|
77
|
-
|
|
78
|
-
Object.assign(StronglyEmphasisedTextMarkdownNode.prototype, contentMixins);
|
|
79
|
-
|
|
80
|
-
export default StronglyEmphasisedTextMarkdownNode;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import TextMarkdownNode from "../../../node/markdown/text";
|
|
4
|
+
|
|
5
|
+
export default class BlockTextMarkdownNode extends TextMarkdownNode {
|
|
6
|
+
static fromRuleNameChildNodesAndOpacity(ruleName, childNodes, opacity) { return TextMarkdownNode.fromRuleNameChildNodesAndOpacity(BlockTextMarkdownNode, ruleName, childNodes, opacity); }
|
|
7
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import TextMarkdownNode from "../../../node/markdown/text";
|
|
4
|
+
|
|
5
|
+
export default class PlainTextMarkdownNode extends TextMarkdownNode {
|
|
6
|
+
static fromRuleNameChildNodesAndOpacity(ruleName, childNodes, opacity) { return TextMarkdownNode.fromRuleNameChildNodesAndOpacity(PlainTextMarkdownNode, ruleName, childNodes, opacity); }
|
|
7
|
+
}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import MarkdownNode from "../../node/markdown";
|
|
4
|
+
|
|
5
|
+
import { EMPTY_STRING } from "../../constants";
|
|
6
|
+
import { ESCAPED_TOKEN_TYPE } from "../../tokenTypes";
|
|
7
|
+
|
|
8
|
+
export default class TextMarkdownNode extends MarkdownNode {
|
|
9
|
+
text(context) {
|
|
10
|
+
const { tokens } = context;
|
|
11
|
+
|
|
12
|
+
let { whitespaceTokenIndex } = context;
|
|
13
|
+
|
|
14
|
+
const text = this.fromFirstChildNode((firstChildNode) => {
|
|
15
|
+
let text = EMPTY_STRING;
|
|
16
|
+
|
|
17
|
+
const terminalNode = firstChildNode, ///
|
|
18
|
+
significantToken = terminalNode.getSignificantToken(),
|
|
19
|
+
significantTokenIndex = tokens.indexOf(significantToken),
|
|
20
|
+
previousTokenIndex = significantTokenIndex - 1;
|
|
21
|
+
|
|
22
|
+
if (previousTokenIndex > -1) {
|
|
23
|
+
const previousToken = tokens[previousTokenIndex],
|
|
24
|
+
previousTokenWhitespaceToken = previousToken.isWhitespaceToken();
|
|
25
|
+
|
|
26
|
+
if (previousTokenWhitespaceToken) {
|
|
27
|
+
if (previousTokenIndex > whitespaceTokenIndex) {
|
|
28
|
+
const whitespaceToken = previousToken, ///
|
|
29
|
+
whitespaceTokenContent = whitespaceToken.getContent();
|
|
30
|
+
|
|
31
|
+
text = `${text}${whitespaceTokenContent}`;
|
|
32
|
+
|
|
33
|
+
whitespaceTokenIndex = previousTokenIndex; ///
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
let significantTokenContent = significantToken.getContent();
|
|
39
|
+
|
|
40
|
+
const significantTokenType = significantToken.getType();
|
|
41
|
+
|
|
42
|
+
if (significantTokenType === ESCAPED_TOKEN_TYPE) {
|
|
43
|
+
const start = 1;
|
|
44
|
+
|
|
45
|
+
significantTokenContent = significantTokenContent.substring(start);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
text = `${text}${significantTokenContent}`;
|
|
49
|
+
|
|
50
|
+
const tokensLength = tokens.length,
|
|
51
|
+
nextTokenIndex = significantTokenIndex + 1;
|
|
52
|
+
|
|
53
|
+
if (nextTokenIndex < tokensLength) {
|
|
54
|
+
const nextToken = tokens[nextTokenIndex],
|
|
55
|
+
nextTokenWhitespaceToken = nextToken.isWhitespaceToken();
|
|
56
|
+
|
|
57
|
+
if (nextTokenWhitespaceToken) {
|
|
58
|
+
if (nextTokenIndex > whitespaceTokenIndex) {
|
|
59
|
+
const whitespaceToken = nextToken, ///
|
|
60
|
+
whitespaceTokenContent = whitespaceToken.getContent();
|
|
61
|
+
|
|
62
|
+
text = `${text}${whitespaceTokenContent}`;
|
|
63
|
+
|
|
64
|
+
whitespaceTokenIndex = nextTokenIndex; ///
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
return text;
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
Object.assign(context, {
|
|
73
|
+
whitespaceTokenIndex
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
return text;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
static fromRuleNameChildNodesAndOpacity(Class, ruleName, childNodes, opacity) { return MarkdownNode.fromRuleNameChildNodesAndOpacity(Class, ruleName, childNodes, opacity); }
|
|
80
|
+
}
|