highmark-markdown 1.0.183 → 1.0.185
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/example.js +10243 -6411
- package/lib/constants.js +9 -1
- package/lib/defaultMarkdownStyle.js +2 -2
- package/lib/example/importer.js +3 -3
- package/lib/example/indexOptions.js +1 -98
- package/lib/example/view/div/container/markdown.js +2 -2
- package/lib/example/view/div/container/markdownStyle.js +2 -2
- package/lib/example/view/div/container.js +2 -2
- package/lib/example/view/div/pageButtons.js +7 -4
- package/lib/example/view/div/preview.js +1 -5
- package/lib/example/view/div/sizeable/left.js +2 -2
- package/lib/example/view/div/tabButtons/right.js +5 -5
- package/lib/example/view/textarea/markdown.js +2 -2
- package/lib/example/view/textarea/markdownStyle.js +2 -2
- package/lib/example/view/textarea/parseTree/html.js +2 -2
- package/lib/example/view/textarea/plainText.js +1 -5
- package/lib/example/view/xmp.js +1 -5
- package/lib/example/view.js +51 -48
- package/lib/index/list.js +4 -4
- package/lib/index.js +2 -2
- package/lib/map/node/html.js +13 -7
- package/lib/map/node/markdown.js +5 -24
- package/lib/markdown/bnf.js +2 -2
- package/lib/node/html/anchor.js +49 -64
- package/lib/node/html/blockLine.js +23 -4
- package/lib/node/{markdown/paragraph.js → html/directive/contents.js} +20 -14
- package/lib/node/{markdown/strongText.js → html/directive/footnotes.js} +20 -14
- package/lib/node/{markdown/emphasisedText.js → html/directive/index.js} +20 -14
- package/lib/node/{markdown/inlineText.js → html/directive/pageNumber.js} +20 -14
- package/lib/node/html/division.js +118 -7
- package/lib/node/html/footnote.js +4 -10
- package/lib/node/html/heading/index.js +71 -10
- package/lib/node/html/heading/primary.js +8 -7
- package/lib/node/html/heading/quaternary.js +8 -7
- package/lib/node/html/heading/secondary.js +8 -7
- package/lib/node/html/heading/tertiary.js +8 -7
- package/lib/node/html/heading.js +165 -0
- package/lib/node/html/image.js +7 -6
- package/lib/node/html/item/contents.js +22 -8
- package/lib/node/html/item/footnote.js +144 -0
- package/lib/node/html/item/index.js +27 -43
- package/lib/node/html/line.js +55 -2
- package/lib/node/html/link/contents.js +34 -14
- package/lib/node/html/link/email.js +32 -8
- package/lib/node/html/link/footnote.js +95 -5
- package/lib/node/html/link/hyper.js +32 -8
- package/lib/node/html/link/index.js +66 -35
- package/lib/node/html/list/contents.js +22 -8
- package/lib/node/html/list/footnotes.js +39 -12
- package/lib/node/html/list/index.js +22 -8
- package/lib/node/html/pageNumber.js +70 -23
- package/lib/node/html/{item/footnotes.js → reference.js} +14 -14
- package/lib/node/{markdown/heading/primary.js → html/text/comma.js} +38 -28
- package/lib/node/html/text/index.js +146 -0
- package/lib/node/html/text/stronglyEmphasised.js +15 -8
- package/lib/node/html/text.js +43 -5
- package/lib/node/html/topmost.js +67 -1
- package/lib/node/html.js +77 -4
- package/lib/node/markdown/directive/{embee.js → embed.js} +1 -1
- package/lib/node/markdown/division.js +13 -22
- package/lib/node/markdown/link/footnote.js +5 -102
- package/lib/node/markdown/subDivision.js +2 -2
- package/lib/node/markdown/text/block.js +1 -1
- package/lib/node/markdown/text.js +25 -29
- package/lib/ruleNames.js +87 -81
- package/lib/style/selector.js +4 -4
- package/lib/{node/markdown/heading/tertiary.js → transform/html/directive/contents.js} +23 -28
- package/lib/{node/markdown/stronglyEmphasisedText.js → transform/html/directive/footnotes.js} +15 -14
- package/lib/{node/markdown/line.js → transform/html/directive/index.js} +19 -18
- package/lib/transform/html/directive/pageNumber.js +108 -0
- package/lib/transform/html/division.js +130 -0
- package/lib/transform/html/footnote.js +159 -0
- package/lib/transform/html/heading/index.js +109 -0
- package/lib/transform/html/index.js +159 -0
- package/lib/transform/{indexAnchor.js → html/indexAnchor.js} +20 -20
- package/lib/transform/html/item/contents.js +130 -0
- package/lib/transform/html/item/footnote.js +117 -0
- package/lib/transform/html/item/index.js +117 -0
- package/lib/transform/html/line.js +123 -0
- package/lib/transform/html/link/contents.js +130 -0
- package/lib/transform/html/link/footnote.js +158 -0
- package/lib/transform/html/link/nestedFootnote.js +108 -0
- package/lib/transform/html/list/contents.js +180 -0
- package/lib/transform/html/list/footnotes.js +117 -0
- package/lib/transform/html/list/index.js +118 -0
- package/lib/transform/html/pageNumber.js +117 -0
- package/lib/transform/html.js +168 -0
- package/lib/transform/markdown/directive/embed.js +14 -9
- package/lib/transform/markdown/directive/ignore.js +12 -38
- package/lib/transform/markdown/directive/include.js +11 -6
- package/lib/transform/markdown/subDivision.js +18 -50
- package/lib/transform/markdown.js +148 -0
- package/lib/utilities/contents.js +16 -16
- package/lib/utilities/division.js +247 -0
- package/lib/utilities/footnotes.js +8 -8
- package/lib/utilities/html.js +37 -79
- package/lib/utilities/index.js +23 -16
- package/lib/utilities/markdown.js +2 -10
- package/lib/utilities/string.js +16 -10
- package/lib/utilities/whitespace.js +33 -0
- package/package.json +6 -6
- package/src/constants.js +2 -0
- package/src/defaultMarkdownStyle.js +6 -9
- package/src/example/importer.js +11 -5
- package/src/example/indexOptions.js +0 -97
- package/src/example/view/div/container/markdown.js +1 -1
- package/src/example/view/div/container/markdownStyle.js +1 -1
- package/src/example/view/div/container.js +1 -1
- package/src/example/view/div/pageButtons.js +8 -2
- package/src/example/view/div/preview.js +0 -6
- package/src/example/view/div/sizeable/left.js +1 -1
- package/src/example/view/div/tabButtons/right.js +3 -3
- package/src/example/view/textarea/markdown.js +1 -0
- package/src/example/view/textarea/markdownStyle.js +1 -0
- package/src/example/view/textarea/parseTree/html.js +1 -1
- package/src/example/view/textarea/plainText.js +0 -6
- package/src/example/view/xmp.js +0 -6
- package/src/example/view.js +75 -74
- package/src/index/list.js +3 -3
- package/src/index.js +1 -1
- package/src/map/node/html.js +29 -11
- package/src/map/node/markdown.js +8 -65
- package/src/markdown/bnf.js +112 -149
- package/src/node/html/anchor.js +34 -43
- package/src/node/html/blockLine.js +33 -4
- package/src/node/html/directive/contents.js +9 -0
- package/src/node/html/directive/footnotes.js +9 -0
- package/src/node/html/directive/index.js +9 -0
- package/src/node/html/directive/pageNumber.js +9 -0
- package/src/node/html/division.js +154 -4
- package/src/node/html/footnote.js +1 -7
- package/src/node/html/heading/index.js +78 -2
- package/src/node/html/heading/primary.js +6 -4
- package/src/node/html/heading/quaternary.js +6 -4
- package/src/node/html/heading/secondary.js +6 -4
- package/src/node/html/heading/tertiary.js +6 -4
- package/src/node/html/heading.js +59 -0
- package/src/node/html/image.js +8 -5
- package/src/node/html/item/contents.js +25 -2
- package/src/node/html/item/footnote.js +39 -0
- package/src/node/html/item/index.js +35 -16
- package/src/node/html/line.js +41 -2
- package/src/node/html/link/contents.js +32 -5
- package/src/node/html/link/email.js +51 -17
- package/src/node/html/link/footnote.js +98 -2
- package/src/node/html/link/hyper.js +51 -17
- package/src/node/html/link/index.js +63 -30
- package/src/node/html/list/contents.js +25 -2
- package/src/node/html/list/footnotes.js +34 -2
- package/src/node/html/list/index.js +25 -2
- package/src/node/html/pageNumber.js +60 -16
- package/src/node/html/reference.js +13 -0
- package/src/node/html/text/comma.js +29 -0
- package/src/node/html/text/index.js +43 -0
- package/src/node/html/text/stronglyEmphasised.js +22 -11
- package/src/node/html/text.js +3 -3
- package/src/node/html/topmost.js +93 -1
- package/src/node/html.js +34 -6
- package/src/node/markdown/division.js +11 -227
- package/src/node/markdown/link/footnote.js +6 -82
- package/src/node/markdown/subDivision.js +1 -1
- package/src/node/markdown/text/block.js +1 -1
- package/src/node/markdown/text.js +38 -39
- package/src/ruleNames.js +11 -8
- package/src/style/selector.js +3 -4
- package/src/transform/html/directive/contents.js +19 -0
- package/src/transform/html/directive/footnotes.js +12 -0
- package/src/transform/html/directive/index.js +19 -0
- package/src/transform/html/directive/pageNumber.js +12 -0
- package/src/transform/html/division.js +33 -0
- package/src/transform/html/footnote.js +66 -0
- package/src/transform/html/heading/index.js +14 -0
- package/src/transform/html/index.js +77 -0
- package/src/transform/html/indexAnchor.js +24 -0
- package/src/transform/html/item/contents.js +48 -0
- package/src/transform/html/item/footnote.js +21 -0
- package/src/transform/html/item/index.js +21 -0
- package/src/transform/html/line.js +27 -0
- package/src/transform/html/link/contents.js +40 -0
- package/src/transform/html/link/footnote.js +58 -0
- package/src/transform/html/link/nestedFootnote.js +12 -0
- package/src/transform/html/list/contents.js +86 -0
- package/src/transform/html/list/footnotes.js +20 -0
- package/src/transform/html/list/index.js +27 -0
- package/src/transform/html/pageNumber.js +20 -0
- package/src/transform/html.js +78 -0
- package/src/transform/markdown/directive/embed.js +6 -7
- package/src/transform/markdown/directive/ignore.js +3 -9
- package/src/transform/markdown/directive/include.js +3 -3
- package/src/transform/markdown/subDivision.js +5 -17
- package/src/transform/markdown.js +9 -0
- package/src/utilities/contents.js +12 -12
- package/src/utilities/division.js +256 -0
- package/src/utilities/footnotes.js +5 -5
- package/src/utilities/html.js +39 -86
- package/src/utilities/index.js +26 -16
- package/src/utilities/markdown.js +0 -8
- package/src/utilities/string.js +5 -3
- package/src/utilities/whitespace.js +21 -0
- package/lib/node/markdown/anchor.js +0 -171
- package/lib/node/markdown/contentsItem.js +0 -112
- package/lib/node/markdown/directive/pageNumber.js +0 -163
- package/lib/node/markdown/heading/quaternary.js +0 -121
- package/lib/node/markdown/heading/secondary.js +0 -121
- package/lib/node/markdown/heading.js +0 -140
- package/lib/node/markdown/item/footnotes.js +0 -120
- package/lib/node/markdown/link/contents.js +0 -156
- package/lib/node/markdown/link/index.js +0 -117
- package/lib/node/markdown/list/contents.js +0 -112
- package/lib/node/markdown/list/footnotes.js +0 -165
- package/lib/node/markdown/list/index.js +0 -112
- package/lib/transform/contentsDirective.js +0 -112
- package/lib/transform/contentsItem.js +0 -134
- package/lib/transform/contentsLink.js +0 -115
- package/lib/transform/contentsList.js +0 -193
- package/lib/transform/footnote.js +0 -181
- package/lib/transform/footnoteIdentifier.js +0 -120
- package/lib/transform/footnotesDirective.js +0 -112
- package/lib/transform/footnotesItem.js +0 -123
- package/lib/transform/footnotesList.js +0 -172
- package/lib/transform/index.js +0 -166
- package/lib/transform/indexDirective.js +0 -112
- package/lib/transform/indexHeading.js +0 -104
- package/lib/transform/indexItem.js +0 -113
- package/lib/transform/indexList.js +0 -121
- package/lib/transform/line.js +0 -111
- package/lib/transform/pageNumberDirective.js +0 -112
- package/src/node/html/item/footnotes.js +0 -13
- package/src/node/markdown/anchor.js +0 -45
- package/src/node/markdown/contentsItem.js +0 -21
- package/src/node/markdown/directive/pageNumber.js +0 -34
- package/src/node/markdown/emphasisedText.js +0 -7
- package/src/node/markdown/heading/primary.js +0 -9
- package/src/node/markdown/heading/quaternary.js +0 -9
- package/src/node/markdown/heading/secondary.js +0 -9
- package/src/node/markdown/heading/tertiary.js +0 -9
- package/src/node/markdown/heading.js +0 -47
- package/src/node/markdown/inlineText.js +0 -7
- package/src/node/markdown/item/footnotes.js +0 -39
- package/src/node/markdown/line.js +0 -17
- package/src/node/markdown/link/contents.js +0 -31
- package/src/node/markdown/link/index.js +0 -18
- package/src/node/markdown/list/contents.js +0 -21
- package/src/node/markdown/list/footnotes.js +0 -45
- package/src/node/markdown/list/index.js +0 -21
- package/src/node/markdown/paragraph.js +0 -7
- package/src/node/markdown/strongText.js +0 -7
- package/src/node/markdown/stronglyEmphasisedText.js +0 -7
- package/src/transform/contentsDirective.js +0 -18
- package/src/transform/contentsItem.js +0 -55
- package/src/transform/contentsLink.js +0 -28
- package/src/transform/contentsList.js +0 -110
- package/src/transform/footnote.js +0 -51
- package/src/transform/footnoteIdentifier.js +0 -27
- package/src/transform/footnotesDirective.js +0 -18
- package/src/transform/footnotesItem.js +0 -25
- package/src/transform/footnotesList.js +0 -77
- package/src/transform/index.js +0 -90
- package/src/transform/indexAnchor.js +0 -27
- package/src/transform/indexDirective.js +0 -18
- package/src/transform/indexHeading.js +0 -18
- package/src/transform/indexItem.js +0 -29
- package/src/transform/indexList.js +0 -33
- package/src/transform/line.js +0 -19
- package/src/transform/pageNumberDirective.js +0 -18
- /package/src/node/markdown/directive/{embee.js → embed.js} +0 -0
|
@@ -1,15 +1,165 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
import HTMLNode from "../../node/html";
|
|
4
|
+
import PageNumberHTMLNode from "../../node/html/pageNumber";
|
|
5
|
+
import PageNumberHTMLTransform from "../../transform/html/pageNumber";
|
|
6
|
+
import IndexAnchorHTMLTransform from "../../transform/html/indexAnchor";
|
|
7
|
+
import FootnotesListHTMLTransform from "../../transform/html/list/footnotes";
|
|
8
|
+
|
|
9
|
+
import { DIVISION_RULE_NAME } from "../../ruleNames";
|
|
10
|
+
import { groupHTMLNodes,
|
|
11
|
+
removeHTMLNodes,
|
|
12
|
+
addFootnoteHTMLNodes,
|
|
13
|
+
removeFootnoteHTMLNodes,
|
|
14
|
+
paginateGroupedHTMLNodes,
|
|
15
|
+
numberFootnoteLinkHTMLNodes,
|
|
16
|
+
removeFootnotesDirectiveHTMLNode,
|
|
17
|
+
removePageNumberDirectiveHTMLNode,
|
|
18
|
+
removeNestedFootnoteLinkHTMLNodes,
|
|
19
|
+
lineHTMLTransformsFromFootnoteHTMLTransforms,
|
|
20
|
+
footnoteItemHTMLTransformsFromLineHTMLTransforms } from "../../utilities/division";
|
|
4
21
|
|
|
5
22
|
export default class DivisionHTMLNode extends HTMLNode {
|
|
6
|
-
|
|
23
|
+
constructor(outerNode, parentNode, childNodes, domElement, divisionClassName) {
|
|
24
|
+
super(outerNode, parentNode, childNodes, domElement);
|
|
25
|
+
|
|
26
|
+
this.divisionClassName = divisionClassName;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
getDivisionClassName() {
|
|
30
|
+
return this.divisionClassName;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
className(context) {
|
|
34
|
+
const className = this.divisionClassName; ///
|
|
35
|
+
|
|
36
|
+
return className;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
getRuleName() {
|
|
40
|
+
const ruleNme = DIVISION_RULE_NAME;
|
|
41
|
+
|
|
42
|
+
return ruleNme;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
resolve(divisionHTMLNodes, context) {
|
|
46
|
+
const node = this;
|
|
47
|
+
|
|
48
|
+
removeNestedFootnoteLinkHTMLNodes(node);
|
|
49
|
+
|
|
50
|
+
const pageNumberDirectiveHTNLTransform = removePageNumberDirectiveHTMLNode(node),
|
|
51
|
+
footnotesDirectiveHTMLNode = removeFootnotesDirectiveHTMLNode(node),
|
|
52
|
+
footnoteHTMLTransforms = removeFootnoteHTMLNodes(node);
|
|
53
|
+
|
|
54
|
+
if (footnotesDirectiveHTMLNode !== null) {
|
|
55
|
+
addFootnoteHTMLNodes(footnoteHTMLTransforms, node, context);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
this.paginate(pageNumberDirectiveHTNLTransform, divisionHTMLNodes, context);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
paginate(pageNumberDirectiveHTNLTransform, divisionHTMLNodes, context) {
|
|
62
|
+
const node = this, ///
|
|
63
|
+
outerNode = this.getOuterNode(),
|
|
64
|
+
pageNumbers = (pageNumberDirectiveHTNLTransform !== null),
|
|
65
|
+
identifierMap = {},
|
|
66
|
+
divisionClassName = outerNode.className(context);
|
|
67
|
+
|
|
68
|
+
const htmlNodes = removeHTMLNodes(node),
|
|
69
|
+
groupedHTMLNodesArray = groupHTMLNodes(htmlNodes),
|
|
70
|
+
paginatedHTMLNodesArray = paginateGroupedHTMLNodes(groupedHTMLNodesArray, context);
|
|
71
|
+
|
|
72
|
+
paginatedHTMLNodesArray.forEach((paginatedHTMLNodes) => {
|
|
73
|
+
let pageNumber;
|
|
74
|
+
|
|
75
|
+
({ pageNumber } = context);
|
|
76
|
+
|
|
77
|
+
const divisionHTMLNode = DivisionHTMLNode.fromPaginatedHTMLNodesAndDivisionClassName(paginatedHTMLNodes, divisionClassName);
|
|
78
|
+
|
|
79
|
+
divisionHTMLNode.resolveFootnotes(identifierMap, context);
|
|
80
|
+
|
|
81
|
+
if (pageNumbers) {
|
|
82
|
+
const indexAnchorHTMLTransform = IndexAnchorHTMLTransform.fromPageNumber(pageNumber),
|
|
83
|
+
pageNumberHTMLTransform = PageNumberHTMLTransform.fromPageNumber(pageNumber);
|
|
84
|
+
|
|
85
|
+
indexAnchorHTMLTransform.prependToDivisionHTMLNode(divisionHTMLNode);
|
|
86
|
+
|
|
87
|
+
pageNumberHTMLTransform.appendToDivisionHTMLNode(divisionHTMLNode);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
divisionHTMLNodes.push(divisionHTMLNode);
|
|
91
|
+
|
|
92
|
+
pageNumber++;
|
|
93
|
+
|
|
94
|
+
Object.assign(context, {
|
|
95
|
+
pageNumber
|
|
96
|
+
});
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
pageNumber() {
|
|
101
|
+
const pageNumber = this.fromFirstLastChildNode((firstLastChildNode) => {
|
|
102
|
+
let pageNumber = null;
|
|
103
|
+
|
|
104
|
+
const firstLastChildNodePageNumberHTMLNode = (firstLastChildNode instanceof PageNumberHTMLNode);
|
|
105
|
+
|
|
106
|
+
if (firstLastChildNodePageNumberHTMLNode) {
|
|
107
|
+
const pageNumberHTMLNode = firstLastChildNode; ///
|
|
108
|
+
|
|
109
|
+
pageNumber = pageNumberHTMLNode.getPageNumber();
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
return pageNumber;
|
|
113
|
+
});
|
|
114
|
+
|
|
115
|
+
return pageNumber;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
resolveFootnotes(identifierMap, context) {
|
|
119
|
+
const node = this, ///
|
|
120
|
+
footnoteHTMLTransforms = removeFootnoteHTMLNodes(node),
|
|
121
|
+
footnoteHTMLTransformsLength = footnoteHTMLTransforms.length;
|
|
122
|
+
|
|
123
|
+
if (footnoteHTMLTransformsLength === 0) {
|
|
124
|
+
return;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
const divisionHTMLNode = node, ///
|
|
128
|
+
start = numberFootnoteLinkHTMLNodes(footnoteHTMLTransforms, identifierMap, node, context),
|
|
129
|
+
lineHTMLTransforms = lineHTMLTransformsFromFootnoteHTMLTransforms(footnoteHTMLTransforms),
|
|
130
|
+
footnoteItemHTMLTransforms = footnoteItemHTMLTransformsFromLineHTMLTransforms(lineHTMLTransforms, identifierMap, start),
|
|
131
|
+
footnotesListHTMLTransform = FootnotesListHTMLTransform.fromStartAndFootnoteItemHTMLTransforms(start, footnoteItemHTMLTransforms);
|
|
132
|
+
|
|
133
|
+
footnotesListHTMLTransform.appendToDivisionHTMLNode(divisionHTMLNode);
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
asString() {
|
|
137
|
+
const ruleName = this.getRuleName(),
|
|
138
|
+
string = ruleName; ///
|
|
139
|
+
|
|
140
|
+
return string;
|
|
141
|
+
}
|
|
7
142
|
|
|
8
143
|
static tagName = "div";
|
|
9
144
|
|
|
10
|
-
static
|
|
145
|
+
static fromNothing() {
|
|
146
|
+
const divisionClassName = null,
|
|
147
|
+
divisionHTMLNode = HTMLNode.fromNothing(DivisionHTMLNode, divisionClassName);
|
|
148
|
+
|
|
149
|
+
return divisionHTMLNode;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
static fromOuterNode(outerNode) {
|
|
153
|
+
const divisionClassName = null,
|
|
154
|
+
divisionHTMLNode = HTMLNode.fromOuterNode(DivisionHTMLNode, outerNode, divisionClassName);
|
|
155
|
+
|
|
156
|
+
return divisionHTMLNode;
|
|
157
|
+
}
|
|
11
158
|
|
|
12
|
-
static
|
|
159
|
+
static fromPaginatedHTMLNodesAndDivisionClassName(paginatedHTMLNodes, divisionClassName) {
|
|
160
|
+
const childNodes = paginatedHTMLNodes, ///
|
|
161
|
+
divisionHTMLNode = HTMLNode.fromChildNodes(DivisionHTMLNode, childNodes, divisionClassName);
|
|
13
162
|
|
|
14
|
-
|
|
163
|
+
return divisionHTMLNode;
|
|
164
|
+
}
|
|
15
165
|
}
|
|
@@ -3,13 +3,7 @@
|
|
|
3
3
|
import HTMLNode from "../../node/html";
|
|
4
4
|
|
|
5
5
|
export default class FootnoteHTMLNode extends HTMLNode {
|
|
6
|
-
|
|
7
|
-
///
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
unmount(parentDOMElement, context) {
|
|
11
|
-
///
|
|
12
|
-
}
|
|
6
|
+
identifier(context) { return this.outerNode.identifier(context); }
|
|
13
7
|
|
|
14
8
|
static fromNothing() { return HTMLNode.fromNothing(FootnoteHTMLNode); }
|
|
15
9
|
|
|
@@ -2,12 +2,88 @@
|
|
|
2
2
|
|
|
3
3
|
import HTMLNode from "../../../node/html";
|
|
4
4
|
|
|
5
|
+
import { INDEX_HEADING_RULE_NAME } from "../../../ruleNames";
|
|
6
|
+
|
|
5
7
|
export default class IndexHeadingHTMLNode extends HTMLNode {
|
|
8
|
+
constructor(outerNode, parentNode, childNodes, domElement, letter) {
|
|
9
|
+
super(outerNode, parentNode, childNodes, domElement);
|
|
10
|
+
|
|
11
|
+
this.letter = letter;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
getLetter() {
|
|
15
|
+
return this.letter;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
getRuleName() {
|
|
19
|
+
const ruleName = INDEX_HEADING_RULE_NAME;
|
|
20
|
+
|
|
21
|
+
return ruleName;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
mount(parentDOMElement, siblingDOMElement, context) {
|
|
25
|
+
let domElement;
|
|
26
|
+
|
|
27
|
+
domElement = this.createDOMElement(context);
|
|
28
|
+
|
|
29
|
+
this.setDOMElement(domElement);
|
|
30
|
+
|
|
31
|
+
parentDOMElement.insertBefore(domElement, siblingDOMElement);
|
|
32
|
+
|
|
33
|
+
parentDOMElement = domElement; ///
|
|
34
|
+
|
|
35
|
+
siblingDOMElement = null;
|
|
36
|
+
|
|
37
|
+
const content = this.letter, ///
|
|
38
|
+
textNode = document.createTextNode(content);
|
|
39
|
+
|
|
40
|
+
domElement = textNode; ///
|
|
41
|
+
|
|
42
|
+
parentDOMElement.insertBefore(domElement, siblingDOMElement);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
unmount(parentDOMElement, context) {
|
|
46
|
+
let domElement;
|
|
47
|
+
|
|
48
|
+
{
|
|
49
|
+
domElement = this.getDOMElement();
|
|
50
|
+
|
|
51
|
+
const parentDOMElement = domElement, ///
|
|
52
|
+
firstChild = domElement.firstChild
|
|
53
|
+
|
|
54
|
+
domElement = firstChild; ///
|
|
55
|
+
|
|
56
|
+
parentDOMElement.removeChild(domElement);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
domElement = this.getDOMElement();
|
|
60
|
+
|
|
61
|
+
parentDOMElement.removeChild(domElement);
|
|
62
|
+
|
|
63
|
+
this.resetDOMElement();
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
childNodesAsHTML(indent, context) {
|
|
67
|
+
const childNodesHTML = `${this.letter}
|
|
68
|
+
`;
|
|
69
|
+
|
|
70
|
+
return childNodesHTML;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
asString() {
|
|
74
|
+
const ruleName = this.getRuleName(),
|
|
75
|
+
string = ruleName; ///
|
|
76
|
+
|
|
77
|
+
return string;
|
|
78
|
+
}
|
|
79
|
+
|
|
6
80
|
static tagName = "h3";
|
|
7
81
|
|
|
8
82
|
static className = "index";
|
|
9
83
|
|
|
10
|
-
static
|
|
84
|
+
static fromLetter(letter) {
|
|
85
|
+
const indexHeadingHTMLNode = HTMLNode.fromNothing(IndexHeadingHTMLNode, letter);
|
|
11
86
|
|
|
12
|
-
|
|
87
|
+
return indexHeadingHTMLNode;
|
|
88
|
+
}
|
|
13
89
|
}
|
|
@@ -1,15 +1,17 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
import
|
|
3
|
+
import HeadingHTMLNode from "../../../node/html/heading";
|
|
4
|
+
|
|
5
|
+
export default class PrimaryHeadingHTMLNode extends HeadingHTMLNode {
|
|
6
|
+
static depth = 1;
|
|
4
7
|
|
|
5
|
-
export default class PrimaryHeadingHTMLNode extends HTMLNode {
|
|
6
8
|
static lines = 3;
|
|
7
9
|
|
|
8
10
|
static tagName = "h1";
|
|
9
11
|
|
|
10
12
|
static className = null;
|
|
11
13
|
|
|
12
|
-
static fromNothing() { return
|
|
14
|
+
static fromNothing() { return HeadingHTMLNode.fromNothing(PrimaryHeadingHTMLNode); }
|
|
13
15
|
|
|
14
|
-
static fromOuterNode(outerNode) { return
|
|
16
|
+
static fromOuterNode(outerNode) { return HeadingHTMLNode.fromOuterNode(PrimaryHeadingHTMLNode, outerNode); }
|
|
15
17
|
}
|
|
@@ -1,15 +1,17 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
import
|
|
3
|
+
import HeadingHTMLNode from "../../../node/html/heading";
|
|
4
|
+
|
|
5
|
+
export default class QuaternaryHeadingHTMLNode extends HeadingHTMLNode {
|
|
6
|
+
static depth = 4;
|
|
4
7
|
|
|
5
|
-
export default class QuaternaryHeadingHTMLNode extends HTMLNode {
|
|
6
8
|
static lines = 2;
|
|
7
9
|
|
|
8
10
|
static tagName = "h4";
|
|
9
11
|
|
|
10
12
|
static className = null;
|
|
11
13
|
|
|
12
|
-
static fromNothing() { return
|
|
14
|
+
static fromNothing() { return HeadingHTMLNode.fromNothing(QuaternaryHeadingHTMLNode); }
|
|
13
15
|
|
|
14
|
-
static fromOuterNode(outerNode) { return
|
|
16
|
+
static fromOuterNode(outerNode) { return HeadingHTMLNode.fromOuterNode(QuaternaryHeadingHTMLNode, outerNode); }
|
|
15
17
|
}
|
|
@@ -1,15 +1,17 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
import
|
|
3
|
+
import HeadingHTMLNode from "../../../node/html/heading";
|
|
4
|
+
|
|
5
|
+
export default class SecondaryHeadingHTMLNode extends HeadingHTMLNode {
|
|
6
|
+
static depth = 2;
|
|
4
7
|
|
|
5
|
-
export default class SecondaryHeadingHTMLNode extends HTMLNode {
|
|
6
8
|
static lines = 2.5;
|
|
7
9
|
|
|
8
10
|
static tagName = "h2";
|
|
9
11
|
|
|
10
12
|
static className = null;
|
|
11
13
|
|
|
12
|
-
static fromNothing() { return
|
|
14
|
+
static fromNothing() { return HeadingHTMLNode.fromNothing(SecondaryHeadingHTMLNode); }
|
|
13
15
|
|
|
14
|
-
static fromOuterNode(outerNode) { return
|
|
16
|
+
static fromOuterNode(outerNode) { return HeadingHTMLNode.fromOuterNode(SecondaryHeadingHTMLNode, outerNode); }
|
|
15
17
|
}
|
|
@@ -1,15 +1,17 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
import
|
|
3
|
+
import HeadingHTMLNode from "../../../node/html/heading";
|
|
4
|
+
|
|
5
|
+
export default class TertiaryHeadingHTMLNode extends HeadingHTMLNode {
|
|
6
|
+
static depth = 3;
|
|
4
7
|
|
|
5
|
-
export default class TertiaryHeadingHTMLNode extends HTMLNode {
|
|
6
8
|
static lines = 2.25;
|
|
7
9
|
|
|
8
10
|
static tagName = "h3";
|
|
9
11
|
|
|
10
12
|
static className = null;
|
|
11
13
|
|
|
12
|
-
static fromNothing() { return
|
|
14
|
+
static fromNothing() { return HeadingHTMLNode.fromNothing(TertiaryHeadingHTMLNode); }
|
|
13
15
|
|
|
14
|
-
static fromOuterNode(outerNode) { return
|
|
16
|
+
static fromOuterNode(outerNode) { return HeadingHTMLNode.fromOuterNode(TertiaryHeadingHTMLNode, outerNode); }
|
|
15
17
|
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import HTMLNode from "../../node/html";
|
|
4
|
+
import AnchorHTMLNode from "../../node/html/anchor";
|
|
5
|
+
|
|
6
|
+
import { CONTENTS_PREPEND } from "../../prepends";
|
|
7
|
+
import { removeLeadingWhitespace, replaceSpacesWithHyphens, removeNonAlphabeticCharacters } from "../../utilities/string";
|
|
8
|
+
|
|
9
|
+
export default class HeadingHTMLNode extends HTMLNode {
|
|
10
|
+
getLineHTMLNode() {
|
|
11
|
+
const lineHTMLNode = this.fromFirstChildNode((firstChildNode) => {
|
|
12
|
+
const lineHTMLNode = firstChildNode; ///
|
|
13
|
+
|
|
14
|
+
return lineHTMLNode;
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
return lineHTMLNode;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
identifier(context) {
|
|
21
|
+
const plainText = this.childNodesAsPlainText(context),
|
|
22
|
+
identifier = identifierFromPlainText(plainText);
|
|
23
|
+
|
|
24
|
+
return identifier;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
anchor(context) {
|
|
28
|
+
const prepend = CONTENTS_PREPEND,
|
|
29
|
+
identifier = this.identifier(context),
|
|
30
|
+
anchorHTMLNode = AnchorHTMLNode.fromPrependAndIdentifier(prepend, identifier),
|
|
31
|
+
childNode = anchorHTMLNode; ///
|
|
32
|
+
|
|
33
|
+
this.prependChildNode(childNode);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
static tagName = "h1";
|
|
37
|
+
|
|
38
|
+
static fromNothing(Class) { return HTMLNode.fromNothing(Class); }
|
|
39
|
+
|
|
40
|
+
static fromOuterNode(Class, outerNode) { return HTMLNode.fromOuterNode(Class, outerNode); }
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
function identifierFromPlainText(plainText) {
|
|
44
|
+
let string;
|
|
45
|
+
|
|
46
|
+
string = plainText; ///
|
|
47
|
+
|
|
48
|
+
string = string.toLowerCase();
|
|
49
|
+
|
|
50
|
+
string = removeLeadingWhitespace(string);
|
|
51
|
+
|
|
52
|
+
string = replaceSpacesWithHyphens(string);
|
|
53
|
+
|
|
54
|
+
string = removeNonAlphabeticCharacters(string);
|
|
55
|
+
|
|
56
|
+
const identifier = string; ///
|
|
57
|
+
|
|
58
|
+
return identifier;
|
|
59
|
+
}
|
package/src/node/html/image.js
CHANGED
|
@@ -4,7 +4,6 @@ import HTMLNode from "../../node/html";
|
|
|
4
4
|
|
|
5
5
|
import { EMPTY_STRING } from "../../constants";
|
|
6
6
|
import { ALT_ATTRIBUTE_NAME, SRC_ATTRIBUTE_NAME } from "../../attributeNames";
|
|
7
|
-
import {IMAGE_RULE_NAME} from "../../ruleNames";
|
|
8
7
|
|
|
9
8
|
export default class ImageHTMLNode extends HTMLNode {
|
|
10
9
|
src(context) { return this.outerNode.src(context); }
|
|
@@ -61,15 +60,19 @@ export default class ImageHTMLNode extends HTMLNode {
|
|
|
61
60
|
}
|
|
62
61
|
|
|
63
62
|
mount(parentDOMElement, siblingDOMElement, context) {
|
|
64
|
-
|
|
63
|
+
const domElement = this.createDOMElement(context);
|
|
65
64
|
|
|
66
|
-
|
|
65
|
+
this.setDOMElement(domElement);
|
|
66
|
+
|
|
67
|
+
parentDOMElement.insertBefore(domElement, siblingDOMElement);
|
|
67
68
|
}
|
|
68
69
|
|
|
69
70
|
unmount(parentDOMElement, context) {
|
|
70
|
-
|
|
71
|
+
const domElement = this.getDOMElement();
|
|
72
|
+
|
|
73
|
+
parentDOMElement.removeChild(domElement);
|
|
71
74
|
|
|
72
|
-
this.
|
|
75
|
+
this.resetDOMElement();
|
|
73
76
|
}
|
|
74
77
|
|
|
75
78
|
createDOMElement(context) {
|
|
@@ -2,12 +2,35 @@
|
|
|
2
2
|
|
|
3
3
|
import HTMLNode from "../../../node/html";
|
|
4
4
|
|
|
5
|
+
import { CONTENTS_ITEM_RULE_NAME } from "../../../ruleNames";
|
|
6
|
+
|
|
5
7
|
export default class ContentsItemHTMLNode extends HTMLNode {
|
|
8
|
+
getRuleName() {
|
|
9
|
+
const ruleName = CONTENTS_ITEM_RULE_NAME;
|
|
10
|
+
|
|
11
|
+
return ruleName;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
asString() {
|
|
15
|
+
const ruleName = this.getRuleName(),
|
|
16
|
+
string = ruleName; ///
|
|
17
|
+
|
|
18
|
+
return string;
|
|
19
|
+
}
|
|
20
|
+
|
|
6
21
|
static tagName = "li";
|
|
7
22
|
|
|
8
23
|
static className = "contents";
|
|
9
24
|
|
|
10
|
-
static
|
|
25
|
+
static fromHTMLTransforms(htmlTransforms) {
|
|
26
|
+
const htmlNodes = htmlTransforms.map((htmlTransform) => {
|
|
27
|
+
const htmlNode = htmlTransform.getHTMLNode();
|
|
28
|
+
|
|
29
|
+
return htmlNode;
|
|
30
|
+
}),
|
|
31
|
+
childNodes = htmlNodes, ///
|
|
32
|
+
contentsItemHTMLNode = HTMLNode.fromChildNodes(ContentsItemHTMLNode, childNodes);
|
|
11
33
|
|
|
12
|
-
|
|
34
|
+
return contentsItemHTMLNode;
|
|
35
|
+
}
|
|
13
36
|
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import HTMLNode from "../../../node/html";
|
|
4
|
+
import AnchorHTMLNode from "../../../node/html/anchor";
|
|
5
|
+
|
|
6
|
+
import { FOOTNOTE_PREPEND } from "../../../prepends";
|
|
7
|
+
import { FOOTNOTE_ITEM_RULE_NAME } from "../../../ruleNames";
|
|
8
|
+
|
|
9
|
+
export default class FootnoteItemHTMLNode extends HTMLNode {
|
|
10
|
+
getRuleName() {
|
|
11
|
+
const ruleName = FOOTNOTE_ITEM_RULE_NAME; ///
|
|
12
|
+
|
|
13
|
+
return ruleName;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
asString() {
|
|
17
|
+
const ruleName = this.getRuleName(),
|
|
18
|
+
string = ruleName; ///
|
|
19
|
+
|
|
20
|
+
return string;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
static tagName = "li";
|
|
24
|
+
|
|
25
|
+
static className = "footnote";
|
|
26
|
+
|
|
27
|
+
static fromLineTMLTransformAndIdentifier(lineHTMLTransform, identifier) {
|
|
28
|
+
const prepend = FOOTNOTE_PREPEND,
|
|
29
|
+
anchorHTMLNode = AnchorHTMLNode.fromPrependAndIdentifier(prepend, identifier),
|
|
30
|
+
lineHTMLNode = lineHTMLTransform.getLineHTMLNode(),
|
|
31
|
+
childNodes = [
|
|
32
|
+
anchorHTMLNode,
|
|
33
|
+
lineHTMLNode
|
|
34
|
+
],
|
|
35
|
+
footnoteItemHTMLNode = HTMLNode.fromChildNodes(FootnoteItemHTMLNode, childNodes);
|
|
36
|
+
|
|
37
|
+
return footnoteItemHTMLNode;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
@@ -1,33 +1,52 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
import HTMLNode from "../../../node/html";
|
|
4
|
+
import IndexTextHTMLNode from "../../../node/html/text/index";
|
|
5
|
+
import IndexLinkHTMLNode from "../../../node/html/link/index";
|
|
4
6
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
indent = this.adjustIndent(indent);
|
|
7
|
+
import { INDEX_ITEM_RULE_NAME } from "../../../ruleNames";
|
|
8
|
+
import CommaTextHTMLNode from "../text/comma";
|
|
8
9
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
html = `${indent}${startingTag}${childNodesHTML}${closingTag}
|
|
13
|
-
`;
|
|
10
|
+
export default class IndexItemHTMLNode extends HTMLNode {
|
|
11
|
+
getRuleName() {
|
|
12
|
+
const ruleName = INDEX_ITEM_RULE_NAME;
|
|
14
13
|
|
|
15
|
-
return
|
|
14
|
+
return ruleName;
|
|
16
15
|
}
|
|
17
16
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
const childNodesHTML = super.childNodesAsHTML(indent, context);
|
|
17
|
+
asString() {
|
|
18
|
+
const ruleName = this.getRuleName(),
|
|
19
|
+
string = ruleName; ///
|
|
22
20
|
|
|
23
|
-
return
|
|
21
|
+
return string;
|
|
24
22
|
}
|
|
25
23
|
|
|
26
24
|
static tagName = "li";
|
|
27
25
|
|
|
28
26
|
static className = "index";
|
|
29
27
|
|
|
30
|
-
static
|
|
28
|
+
static fromIndexItem(indexItem) {
|
|
29
|
+
const wordOrPhrase = indexItem.getWordOrPhrase(),
|
|
30
|
+
pageNumbers = indexItem.getPageNumbers(),
|
|
31
|
+
indexSpanHTMLNode = IndexTextHTMLNode.fromWordOrPhrase(wordOrPhrase),
|
|
32
|
+
childNodes = [
|
|
33
|
+
indexSpanHTMLNode
|
|
34
|
+
];
|
|
35
|
+
|
|
36
|
+
pageNumbers.forEach((pageNumber) => {
|
|
37
|
+
const indexLinkHTMLNOde = IndexLinkHTMLNode.fromPageNumber(pageNumber);
|
|
38
|
+
|
|
39
|
+
childNodes.push(indexLinkHTMLNOde);
|
|
31
40
|
|
|
32
|
-
|
|
41
|
+
const commaTextHTMLNode = CommaTextHTMLNode.fromNothing();
|
|
42
|
+
|
|
43
|
+
childNodes.push(commaTextHTMLNode);
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
childNodes.pop();
|
|
47
|
+
|
|
48
|
+
const indexItemHTMLNode = HTMLNode.fromChildNodes(IndexItemHTMLNode, childNodes);
|
|
49
|
+
|
|
50
|
+
return indexItemHTMLNode;
|
|
51
|
+
}
|
|
33
52
|
}
|
package/src/node/html/line.js
CHANGED
|
@@ -3,12 +3,41 @@
|
|
|
3
3
|
import HTMLNode from "../../node/html";
|
|
4
4
|
import PlainTextHTMLNode from "./text/plain";
|
|
5
5
|
|
|
6
|
-
import {
|
|
6
|
+
import { assignIndexes, deleteIndexes } from "../../utilities/whitespace";
|
|
7
|
+
import { EMPTY_STRING, DEFAULT_MAXIMUM_LINE_CHARACTERS } from "../../constants";
|
|
7
8
|
|
|
8
9
|
export default class LineHTMLNode extends HTMLNode {
|
|
10
|
+
lines(context) {
|
|
11
|
+
const { maximumLineCharacters = DEFAULT_MAXIMUM_LINE_CHARACTERS } = context,
|
|
12
|
+
plainText = this.asPlainText(context),
|
|
13
|
+
plainTextLength = plainText.length,
|
|
14
|
+
characters = plainTextLength, ///
|
|
15
|
+
lines = (characters / maximumLineCharacters) + 1;
|
|
16
|
+
|
|
17
|
+
return lines;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
mount(parentDOMElement, siblingDOMElement, context) {
|
|
21
|
+
const node = this; ///
|
|
22
|
+
|
|
23
|
+
assignIndexes(node, context);
|
|
24
|
+
|
|
25
|
+
super.mount(parentDOMElement, siblingDOMElement, context);
|
|
26
|
+
|
|
27
|
+
deleteIndexes(context);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
unmount(parentDOMElement, context) {
|
|
31
|
+
super.unmount(parentDOMElement, context);
|
|
32
|
+
}
|
|
33
|
+
|
|
9
34
|
childNodesAsHTML(indent, context) {
|
|
10
35
|
let childNodesHTML;
|
|
11
36
|
|
|
37
|
+
const node = this; ///
|
|
38
|
+
|
|
39
|
+
assignIndexes(node, context);
|
|
40
|
+
|
|
12
41
|
let previousChildNode = null;
|
|
13
42
|
|
|
14
43
|
childNodesHTML = this.reduceChildNode((childNodesHTML, childNode) => {
|
|
@@ -39,11 +68,19 @@ export default class LineHTMLNode extends HTMLNode {
|
|
|
39
68
|
`;
|
|
40
69
|
}
|
|
41
70
|
|
|
71
|
+
deleteIndexes(context);
|
|
72
|
+
|
|
42
73
|
return childNodesHTML;
|
|
43
74
|
}
|
|
44
75
|
|
|
45
76
|
childNodesAsPlainText(context) {
|
|
46
|
-
|
|
77
|
+
let childNodesPlainText;
|
|
78
|
+
|
|
79
|
+
const node = this; ///
|
|
80
|
+
|
|
81
|
+
assignIndexes(node, context)
|
|
82
|
+
|
|
83
|
+
childNodesPlainText = this.reduceChildNode((childNodesPlainText, childNode) => {
|
|
47
84
|
const childNodePlainText = childNode.asPlainText(context);
|
|
48
85
|
|
|
49
86
|
childNodesPlainText = `${childNodesPlainText}${childNodePlainText}`;
|
|
@@ -51,6 +88,8 @@ export default class LineHTMLNode extends HTMLNode {
|
|
|
51
88
|
return childNodesPlainText;
|
|
52
89
|
}, EMPTY_STRING);
|
|
53
90
|
|
|
91
|
+
deleteIndexes(context);
|
|
92
|
+
|
|
54
93
|
return childNodesPlainText;
|
|
55
94
|
}
|
|
56
95
|
|