highmark-markdown 0.0.362 → 0.0.363
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/package.json +1 -1
- package/src/markdown/bnf.js +1 -1
- package/src/node/markdown/directive/contents.js +0 -21
- package/src/node/markdown/division.js +4 -4
- package/src/node/markdown/heading/primary.js +1 -1
- package/src/node/markdown/heading/quaternary.js +1 -1
- package/src/node/markdown/heading/secondary.js +1 -1
- package/src/node/markdown/heading/tertiary.js +1 -1
- package/src/node/markdown/heading.js +3 -3
- package/src/utilities/contents.js +13 -13
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "highmark-markdown",
|
|
3
3
|
"author": "James Smith",
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.363",
|
|
5
5
|
"license": "MIT, Anti-996",
|
|
6
6
|
"homepage": "https://github.com/djalbat/highmark-markdown",
|
|
7
7
|
"description": "Highmark's Markdown and Markdown Style languages.",
|
package/src/markdown/bnf.js
CHANGED
|
@@ -1,28 +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 { second } = arrayUtilities;
|
|
8
|
-
|
|
9
5
|
export default class ContentsDirectiveMarkdownNode extends MarkdownNode {
|
|
10
|
-
maximumLevel(context) {
|
|
11
|
-
let maximumLevel = 1;
|
|
12
|
-
|
|
13
|
-
const childNodes = this.getChildNodes(),
|
|
14
|
-
childNodesLength = childNodes.length;
|
|
15
|
-
|
|
16
|
-
if (childNodesLength> 1) {
|
|
17
|
-
const secondChildNode = second(childNodes),
|
|
18
|
-
terminalNode = secondChildNode, ///
|
|
19
|
-
content = terminalNode.getContent();
|
|
20
|
-
|
|
21
|
-
maximumLevel = Number(content); ///
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
return maximumLevel;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
6
|
static fromRuleNameChildNodesAndOpacity(ruleName, childNodes, opacity) { return MarkdownNode.fromRuleNameChildNodesAndOpacity(ContentsDirectiveMarkdownNode, ruleName, childNodes, opacity); }
|
|
28
7
|
}
|
|
@@ -197,8 +197,8 @@ ${childNodesHTML}${indent}${closingTag}
|
|
|
197
197
|
}
|
|
198
198
|
|
|
199
199
|
function headingMarkdownNodesFromDivisionMarkdownNodeAndContentsDirectiveMarkdownNode(divisionMarkdownNode, contentsDirectiveMarkdownNode, context) {
|
|
200
|
-
const
|
|
201
|
-
|
|
200
|
+
const { contentsDepth } = context,
|
|
201
|
+
headingMarkdownNodes = [];
|
|
202
202
|
|
|
203
203
|
let { divisionMarkdownNodes } = context;
|
|
204
204
|
|
|
@@ -214,9 +214,9 @@ function headingMarkdownNodesFromDivisionMarkdownNodeAndContentsDirectiveMarkdow
|
|
|
214
214
|
});
|
|
215
215
|
|
|
216
216
|
filter(headingMarkdownNodes, (headingMarkdownNode) => {
|
|
217
|
-
const
|
|
217
|
+
const depth = headingMarkdownNode.getDepth();
|
|
218
218
|
|
|
219
|
-
if (
|
|
219
|
+
if (depth <= contentsDepth) {
|
|
220
220
|
return true;
|
|
221
221
|
}
|
|
222
222
|
});
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
import HeadingMarkdownNode from "../../../node/markdown/heading";
|
|
4
4
|
|
|
5
5
|
export default class PrimaryHeadingMarkdownNode extends HeadingMarkdownNode {
|
|
6
|
-
static
|
|
6
|
+
static depth = 1;
|
|
7
7
|
|
|
8
8
|
static fromRuleNameChildNodesAndOpacity(ruleName, childNodes, opacity) { return HeadingMarkdownNode.fromRuleNameChildNodesAndOpacity(PrimaryHeadingMarkdownNode, ruleName, childNodes, opacity); }
|
|
9
9
|
}
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
import HeadingMarkdownNode from "../../../node/markdown/heading";
|
|
4
4
|
|
|
5
5
|
export default class QuaternaryHeadingMarkdownNode extends HeadingMarkdownNode {
|
|
6
|
-
static
|
|
6
|
+
static depth = 4;
|
|
7
7
|
|
|
8
8
|
static fromRuleNameChildNodesAndOpacity(ruleName, childNodes, opacity) { return HeadingMarkdownNode.fromRuleNameChildNodesAndOpacity(QuaternaryHeadingMarkdownNode, ruleName, childNodes, opacity); }
|
|
9
9
|
}
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
import HeadingMarkdownNode from "../../../node/markdown/heading";
|
|
4
4
|
|
|
5
5
|
export default class SecondaryHeadingMarkdownNode extends HeadingMarkdownNode {
|
|
6
|
-
static
|
|
6
|
+
static depth = 2;
|
|
7
7
|
|
|
8
8
|
static fromRuleNameChildNodesAndOpacity(ruleName, childNodes, opacity) { return HeadingMarkdownNode.fromRuleNameChildNodesAndOpacity(SecondaryHeadingMarkdownNode, ruleName, childNodes, opacity); }
|
|
9
9
|
}
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
import HeadingMarkdownNode from "../../../node/markdown/heading";
|
|
4
4
|
|
|
5
5
|
export default class TertiaryHeadingMarkdownNode extends HeadingMarkdownNode {
|
|
6
|
-
static
|
|
6
|
+
static depth = 3;
|
|
7
7
|
|
|
8
8
|
static fromRuleNameChildNodesAndOpacity(ruleName, childNodes, opacity) { return HeadingMarkdownNode.fromRuleNameChildNodesAndOpacity(TertiaryHeadingMarkdownNode, ruleName, childNodes, opacity); }
|
|
9
9
|
}
|
|
@@ -11,10 +11,10 @@ import { replaceSpacesWithHyphens, removedLeadingWhitespace, removeNonAlphabetic
|
|
|
11
11
|
const { last } = arrayUtilities;
|
|
12
12
|
|
|
13
13
|
export default class HeadingMarkdownNode extends MarkdownNode {
|
|
14
|
-
|
|
15
|
-
const {
|
|
14
|
+
getDepth() {
|
|
15
|
+
const { depth } = this.constructor;
|
|
16
16
|
|
|
17
|
-
return
|
|
17
|
+
return depth;
|
|
18
18
|
}
|
|
19
19
|
|
|
20
20
|
addAnchor(context) {
|
|
@@ -8,16 +8,16 @@ export function nestNodes(nodes) {
|
|
|
8
8
|
const nestedNodesStack = NestedNodeStack.fromNothing();
|
|
9
9
|
|
|
10
10
|
nodes.forEach((node) => {
|
|
11
|
-
const
|
|
11
|
+
const depth = node.getDepth();
|
|
12
12
|
|
|
13
|
-
let
|
|
13
|
+
let nestedNodesStackDepth = nestedNodesStack.getDepth()
|
|
14
14
|
|
|
15
|
-
while (
|
|
16
|
-
|
|
15
|
+
while (nestedNodesStackDepth < depth) {
|
|
16
|
+
nestedNodesStackDepth = nestedNodesStack.increment();
|
|
17
17
|
}
|
|
18
18
|
|
|
19
|
-
while (
|
|
20
|
-
|
|
19
|
+
while (nestedNodesStackDepth > depth) {
|
|
20
|
+
nestedNodesStackDepth = nestedNodesStack.decrement();
|
|
21
21
|
}
|
|
22
22
|
|
|
23
23
|
const nestedNode = NestedNode.fromNode(node);
|
|
@@ -88,11 +88,11 @@ class NestedNodeStack {
|
|
|
88
88
|
return nestedNode;
|
|
89
89
|
}
|
|
90
90
|
|
|
91
|
-
|
|
91
|
+
getDepth() {
|
|
92
92
|
const nestedNodesLength = this.nestedNodes.length,
|
|
93
|
-
|
|
93
|
+
depth = nestedNodesLength; ///
|
|
94
94
|
|
|
95
|
-
return
|
|
95
|
+
return depth;
|
|
96
96
|
}
|
|
97
97
|
|
|
98
98
|
increment() {
|
|
@@ -100,17 +100,17 @@ class NestedNodeStack {
|
|
|
100
100
|
|
|
101
101
|
this.addNestedNode(nestedNode);
|
|
102
102
|
|
|
103
|
-
const
|
|
103
|
+
const depth = this.getDepth();
|
|
104
104
|
|
|
105
|
-
return
|
|
105
|
+
return depth;
|
|
106
106
|
}
|
|
107
107
|
|
|
108
108
|
decrement() {
|
|
109
109
|
this.removeNestedNode();
|
|
110
110
|
|
|
111
|
-
const
|
|
111
|
+
const depth = this.getDepth();
|
|
112
112
|
|
|
113
|
-
return
|
|
113
|
+
return depth;
|
|
114
114
|
}
|
|
115
115
|
|
|
116
116
|
addNestedNode(nestedNode) {
|