highmark-markdown 0.0.56 → 0.0.60
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 +137 -204
- package/lib/example/view.js +2 -2
- package/lib/markdown/bnf.js +2 -2
- package/lib/markdown/entries.js +2 -2
- package/lib/markdown/lexer.js +2 -2
- package/lib/mixins/content.js +3 -3
- package/lib/node/markdown/address.js +3 -2
- package/lib/node/markdown/blockListing.js +1 -8
- package/lib/node/markdown/blockText.js +4 -4
- package/lib/node/markdown/division.js +1 -2
- package/lib/node/markdown/emphasisedText.js +2 -2
- package/lib/node/markdown/endOfLine.js +5 -9
- package/lib/node/markdown/error.js +7 -13
- package/lib/node/markdown/hyperlink.js +24 -24
- package/lib/node/markdown/image.js +15 -22
- package/lib/node/markdown/inlineText.js +2 -2
- package/lib/node/markdown/line.js +4 -3
- package/lib/node/markdown/mailToLink.js +24 -24
- package/lib/node/markdown/strongText.js +2 -2
- package/lib/node/markdown/stronglyEmphasisedText.js +2 -2
- package/lib/node/markdown/tableCell.js +7 -43
- package/lib/node/markdown/text.js +2 -12
- package/lib/node/markdown/url.js +3 -2
- package/lib/node/markdown/verticalSpace.js +12 -14
- package/lib/node/markdown.js +15 -15
- package/lib/utilities/content.js +15 -12
- package/package.json +1 -1
- package/src/example/view.js +5 -1
- package/src/markdown/bnf.js +2 -2
- package/src/markdown/entries.js +1 -1
- package/src/markdown/lexer.js +1 -2
- package/src/mixins/content.js +3 -2
- package/src/node/markdown/address.js +3 -1
- package/src/node/markdown/blockListing.js +0 -9
- package/src/node/markdown/blockText.js +6 -5
- package/src/node/markdown/division.js +0 -1
- package/src/node/markdown/emphasisedText.js +1 -2
- package/src/node/markdown/endOfLine.js +6 -9
- package/src/node/markdown/error.js +7 -18
- package/src/node/markdown/hyperlink.js +30 -30
- package/src/node/markdown/image.js +22 -28
- package/src/node/markdown/inlineText.js +1 -2
- package/src/node/markdown/line.js +1 -4
- package/src/node/markdown/mailToLink.js +28 -28
- package/src/node/markdown/strongText.js +1 -2
- package/src/node/markdown/stronglyEmphasisedText.js +1 -2
- package/src/node/markdown/tableCell.js +6 -51
- package/src/node/markdown/text.js +0 -13
- package/src/node/markdown/url.js +3 -1
- package/src/node/markdown/verticalSpace.js +19 -16
- package/src/node/markdown.js +12 -12
- package/src/utilities/content.js +17 -15
|
@@ -9,6 +9,34 @@ import { HREF_ATTRIBUTE_NAME } from "../../attributeNames";
|
|
|
9
9
|
const { first, second, secondLast } = arrayUtilities;
|
|
10
10
|
|
|
11
11
|
export default class MailToLinkMarkdownNode extends MarkdownNode {
|
|
12
|
+
attributeName(context) {
|
|
13
|
+
const attributeName = HREF_ATTRIBUTE_NAME;
|
|
14
|
+
|
|
15
|
+
return attributeName;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
attributeValue(context) {
|
|
19
|
+
const childNodes = this.getChildNodes(),
|
|
20
|
+
childNodesLength = childNodes.length;
|
|
21
|
+
|
|
22
|
+
let addressMarkdownNode;
|
|
23
|
+
|
|
24
|
+
if (childNodesLength === 1) {
|
|
25
|
+
const firstChildNode = first(childNodes);
|
|
26
|
+
|
|
27
|
+
addressMarkdownNode = firstChildNode; ///
|
|
28
|
+
} else {
|
|
29
|
+
const secondLastChildNode = secondLast(childNodes);
|
|
30
|
+
|
|
31
|
+
addressMarkdownNode = secondLastChildNode; ///
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
const addressMarkdownNodeContent = addressMarkdownNode.content(context),
|
|
35
|
+
attributeValue = `mailto:${addressMarkdownNodeContent}`;
|
|
36
|
+
|
|
37
|
+
return attributeValue;
|
|
38
|
+
}
|
|
39
|
+
|
|
12
40
|
childNodesAsHTML(indent, context) {
|
|
13
41
|
let childNodesHTML;
|
|
14
42
|
|
|
@@ -51,33 +79,5 @@ export default class MailToLinkMarkdownNode extends MarkdownNode {
|
|
|
51
79
|
}
|
|
52
80
|
}
|
|
53
81
|
|
|
54
|
-
attributeName(context) {
|
|
55
|
-
const attributeName = HREF_ATTRIBUTE_NAME;
|
|
56
|
-
|
|
57
|
-
return attributeName;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
attributeValue(context) {
|
|
61
|
-
const childNodes = this.getChildNodes(),
|
|
62
|
-
childNodesLength = childNodes.length;
|
|
63
|
-
|
|
64
|
-
let addressMarkdownNode;
|
|
65
|
-
|
|
66
|
-
if (childNodesLength === 1) {
|
|
67
|
-
const firstChildNode = first(childNodes);
|
|
68
|
-
|
|
69
|
-
addressMarkdownNode = firstChildNode; ///
|
|
70
|
-
} else {
|
|
71
|
-
const secondLastChildNode = secondLast(childNodes);
|
|
72
|
-
|
|
73
|
-
addressMarkdownNode = secondLastChildNode; ///
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
const addressMarkdownNodeContent = addressMarkdownNode.content(context),
|
|
77
|
-
attributeValue = `mailto:${addressMarkdownNodeContent}`;
|
|
78
|
-
|
|
79
|
-
return attributeValue;
|
|
80
|
-
}
|
|
81
|
-
|
|
82
82
|
static fromRuleNameChildNodesAndOpacity(ruleName, childNodes, opacity) { return MarkdownNode.fromRuleNameChildNodesAndOpacity(MailToLinkMarkdownNode, ruleName, childNodes, opacity); }
|
|
83
83
|
}
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
import contentMixins from "../../mixins/content";
|
|
4
|
-
|
|
5
3
|
import MarkdownNode from "../markdown";
|
|
4
|
+
import contentMixins from "../../mixins/content";
|
|
6
5
|
|
|
7
6
|
class StrongTextMarkdownNode extends MarkdownNode {
|
|
8
7
|
static fromRuleNameChildNodesAndOpacity(ruleName, childNodes, opacity) { return MarkdownNode.fromRuleNameChildNodesAndOpacity(StrongTextMarkdownNode, ruleName, childNodes, opacity); }
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
import contentMixins from "../../mixins/content";
|
|
4
|
-
|
|
5
3
|
import MarkdownNode from "../markdown";
|
|
4
|
+
import contentMixins from "../../mixins/content";
|
|
6
5
|
import ruleNameToHTMLMap from "../../ruleNameToHTMLMap";
|
|
7
6
|
|
|
8
7
|
import { STRONG_TEXT_RULE_NAME } from "../../ruleNames";
|
|
@@ -1,69 +1,24 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
import { arrayUtilities } from "necessary";
|
|
4
|
-
|
|
5
3
|
import MarkdownNode from "../../node/markdown";
|
|
6
|
-
import TextMarkdownNode from "./text";
|
|
7
4
|
|
|
8
|
-
import { PERIOD } from "../../constants";
|
|
9
5
|
import { htmlFromChildNodes, domElementsFromChildNodes } from "../../utilities/childNodes";
|
|
10
6
|
|
|
11
|
-
const { first } = arrayUtilities;
|
|
12
|
-
|
|
13
7
|
export default class TableCellMarkdownNode extends MarkdownNode {
|
|
14
|
-
isEmpty(context) {
|
|
15
|
-
let empty = false;
|
|
16
|
-
|
|
17
|
-
const childNodes = this.getChildNodes(),
|
|
18
|
-
childNodesLength = childNodes.length;
|
|
19
|
-
|
|
20
|
-
if (childNodesLength === 2) {
|
|
21
|
-
const firstChildNode = first(childNodes),
|
|
22
|
-
firstChildNodeTextMarkdownNode = (firstChildNode instanceof TextMarkdownNode);
|
|
23
|
-
|
|
24
|
-
if (firstChildNodeTextMarkdownNode) {
|
|
25
|
-
const textMarkdownNode = firstChildNode, ///
|
|
26
|
-
content = textMarkdownNode.content(context);
|
|
27
|
-
|
|
28
|
-
if (content === PERIOD) {
|
|
29
|
-
empty = true;
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
return empty;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
8
|
childNodesAsHTML(indent, context) {
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
const empty = this.isEmpty(context);
|
|
41
|
-
|
|
42
|
-
if (!empty) {
|
|
43
|
-
const childNodes = this.getChildNodes(),
|
|
44
|
-
html = htmlFromChildNodes(childNodes, context);
|
|
45
|
-
|
|
46
|
-
childNodesHTML = html; ///
|
|
47
|
-
}
|
|
9
|
+
const childNodes = this.getChildNodes(),
|
|
10
|
+
childNodesHTML = htmlFromChildNodes(childNodes, context);
|
|
48
11
|
|
|
49
12
|
return childNodesHTML;
|
|
50
13
|
}
|
|
51
14
|
|
|
52
|
-
createChildNodeDOMElements(
|
|
53
|
-
const empty = this.isEmpty(context);
|
|
54
|
-
|
|
55
|
-
if (empty) {
|
|
56
|
-
return;
|
|
57
|
-
}
|
|
58
|
-
|
|
15
|
+
createChildNodeDOMElements(context) {
|
|
59
16
|
const childNodes = this.getChildNodes(),
|
|
60
17
|
domElements = domElementsFromChildNodes(childNodes, context),
|
|
61
|
-
|
|
62
|
-
childDOMElements = domElements, ///
|
|
63
|
-
siblingDOMElement = null;
|
|
18
|
+
childNodeDOMElements = domElements; ///
|
|
64
19
|
|
|
65
|
-
|
|
66
|
-
|
|
20
|
+
childNodeDOMElements.forEach((childNodeDOMElement) => {
|
|
21
|
+
this.insertDOMElement(childNodeDOMElement);
|
|
67
22
|
});
|
|
68
23
|
}
|
|
69
24
|
|
|
@@ -1,20 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
import { arrayUtilities } from "necessary";
|
|
4
|
-
|
|
5
3
|
import MarkdownNode from "../../node/markdown";
|
|
6
4
|
|
|
7
|
-
const { first } = arrayUtilities;
|
|
8
|
-
|
|
9
5
|
export default class TextMarkdownNode extends MarkdownNode {
|
|
10
|
-
content(context) {
|
|
11
|
-
const childNodes = this.getChildNodes(),
|
|
12
|
-
firstChildNode = first(childNodes),
|
|
13
|
-
terminalNode = firstChildNode, ///
|
|
14
|
-
content = terminalNode.getContent();
|
|
15
|
-
|
|
16
|
-
return content;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
6
|
static fromRuleNameChildNodesAndOpacity(ruleName, childNodes, opacity) { return MarkdownNode.fromRuleNameChildNodesAndOpacity(TextMarkdownNode, ruleName, childNodes, opacity); }
|
|
20
7
|
}
|
package/src/node/markdown/url.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
import MarkdownNode from "../../node/markdown";
|
|
4
4
|
import contentMixins from "../../mixins/content";
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
class URLMarkdownNode extends MarkdownNode {
|
|
7
7
|
asHTML(indent, context) {
|
|
8
8
|
const content = this.content(context),
|
|
9
9
|
html = content; ///
|
|
@@ -24,3 +24,5 @@ export default class URLMarkdownNode extends MarkdownNode {
|
|
|
24
24
|
}
|
|
25
25
|
|
|
26
26
|
Object.assign(URLMarkdownNode.prototype, contentMixins);
|
|
27
|
+
|
|
28
|
+
export default URLMarkdownNode;
|
|
@@ -1,28 +1,31 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
import { arrayUtilities } from "necessary";
|
|
4
|
+
|
|
3
5
|
import MarkdownNode from "../../node/markdown";
|
|
4
|
-
import contentMixins from "../../mixins/content";
|
|
5
6
|
|
|
6
|
-
|
|
7
|
-
asHTML(indent, context) {
|
|
8
|
-
const content = this.content(context),
|
|
9
|
-
html = content; ///
|
|
7
|
+
const { first } = arrayUtilities;
|
|
10
8
|
|
|
11
|
-
|
|
12
|
-
|
|
9
|
+
export default class VerticalSpaceMarkdownNode extends MarkdownNode {
|
|
10
|
+
childNodesAsHTML(indent, context) {
|
|
11
|
+
const childNodes = this.getChildNodes(),
|
|
12
|
+
firstChildNode = first(childNodes),
|
|
13
|
+
endOfLineMarkdownNode = firstChildNode,
|
|
14
|
+
content = endOfLineMarkdownNode.content(context),
|
|
15
|
+
childNodesHTML = content; ///
|
|
13
16
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
domElement = document.createTextNode(content);
|
|
17
|
+
return childNodesHTML;
|
|
18
|
+
}
|
|
17
19
|
|
|
18
|
-
|
|
20
|
+
createChildNodeDOMElements(context) {
|
|
21
|
+
const childNodes = this.getChildNodes(),
|
|
22
|
+
firstChildNode = first(childNodes),
|
|
23
|
+
inlineTextMarkdownNode = firstChildNode, ///
|
|
24
|
+
content = inlineTextMarkdownNode.content(context),
|
|
25
|
+
childNodeDOMElement = document.createTextNode(content);
|
|
19
26
|
|
|
20
|
-
|
|
27
|
+
this.insertDOMElement(childNodeDOMElement);
|
|
21
28
|
}
|
|
22
29
|
|
|
23
30
|
static fromRuleNameChildNodesAndOpacity(ruleName, childNodes, opacity) { return MarkdownNode.fromRuleNameChildNodesAndOpacity(VerticalSpaceMarkdownNode, ruleName, childNodes, opacity); }
|
|
24
31
|
}
|
|
25
|
-
|
|
26
|
-
Object.assign(VerticalSpaceMarkdownNode.prototype, contentMixins);
|
|
27
|
-
|
|
28
|
-
export default VerticalSpaceMarkdownNode;
|
package/src/node/markdown.js
CHANGED
|
@@ -36,18 +36,6 @@ class MarkdownNode extends NonTerminalNode {
|
|
|
36
36
|
return className;
|
|
37
37
|
}
|
|
38
38
|
|
|
39
|
-
attributeName(context) {
|
|
40
|
-
const attributeName = null;
|
|
41
|
-
|
|
42
|
-
return attributeName;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
attributeValue(context) {
|
|
46
|
-
const attributeValue = null;
|
|
47
|
-
|
|
48
|
-
return attributeValue;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
39
|
asHTML(indent, context) {
|
|
52
40
|
if (context === undefined) {
|
|
53
41
|
context = indent; ///
|
|
@@ -148,6 +136,18 @@ ${indent}${closingTag}
|
|
|
148
136
|
return indent;
|
|
149
137
|
}
|
|
150
138
|
|
|
139
|
+
attributeName(context) {
|
|
140
|
+
const attributeName = null;
|
|
141
|
+
|
|
142
|
+
return attributeName;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
attributeValue(context) {
|
|
146
|
+
const attributeValue = null;
|
|
147
|
+
|
|
148
|
+
return attributeValue;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
151
|
childNodesAsHTML(indent, context) {
|
|
152
152
|
const childNodes = this.getChildNodes(),
|
|
153
153
|
childNodesHTML = childNodes.reduce((childNodesHTML, childNode) => {
|
package/src/utilities/content.js
CHANGED
|
@@ -7,7 +7,7 @@ import { ESCAPED_TOKEN_TYPE } from "../tokenTypes";
|
|
|
7
7
|
|
|
8
8
|
const { first, last } = arrayUtilities;
|
|
9
9
|
|
|
10
|
-
export function contentFromMarkdownNodes(markdownNodes, context) {
|
|
10
|
+
export function contentFromMarkdownNodes(markdownNodes, context, trimmed = false) {
|
|
11
11
|
let content = EMPTY_STRING;
|
|
12
12
|
|
|
13
13
|
let { tokens } = context;
|
|
@@ -25,26 +25,28 @@ export function contentFromMarkdownNodes(markdownNodes, context) {
|
|
|
25
25
|
let firstTokenIndex = firstSignificantTokenIndex, ///
|
|
26
26
|
lastTokenIndex = lastSignificantTokenIndex; ///
|
|
27
27
|
|
|
28
|
-
|
|
29
|
-
|
|
28
|
+
if (!trimmed) {
|
|
29
|
+
const previousTokenIndex = firstTokenIndex - 1,
|
|
30
|
+
nextTokenIndex = lastTokenIndex + 1;
|
|
30
31
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
32
|
+
if (previousTokenIndex > -1) {
|
|
33
|
+
const previousToken = tokens[previousTokenIndex],
|
|
34
|
+
previousTokenSignificant = previousToken.isSignificant();
|
|
34
35
|
|
|
35
|
-
|
|
36
|
-
|
|
36
|
+
if (!previousTokenSignificant) {
|
|
37
|
+
firstTokenIndex--;
|
|
38
|
+
}
|
|
37
39
|
}
|
|
38
|
-
}
|
|
39
40
|
|
|
40
|
-
|
|
41
|
+
const tokensLength = tokens.length;
|
|
41
42
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
43
|
+
if (nextTokenIndex < tokensLength) {
|
|
44
|
+
const nextToken = tokens[nextTokenIndex],
|
|
45
|
+
nextTokenSignificant = nextToken.isSignificant();
|
|
45
46
|
|
|
46
|
-
|
|
47
|
-
|
|
47
|
+
if (!nextTokenSignificant) {
|
|
48
|
+
lastTokenIndex++;
|
|
49
|
+
}
|
|
48
50
|
}
|
|
49
51
|
}
|
|
50
52
|
|