highmark-markdown 0.0.404 → 0.0.406
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 +1537 -728
- package/lib/defaultMarkdownStyle.js +2 -2
- package/lib/example/constants.js +7 -11
- package/lib/example/importer.js +56 -0
- package/lib/example/view/textarea/css.js +2 -2
- package/lib/example/view.js +51 -16
- package/lib/example.js +2 -2
- package/lib/index.js +9 -9
- package/lib/markdown/bnf.js +2 -2
- package/lib/mixins/node.js +42 -6
- package/lib/node/markdown/contentsLink.js +2 -2
- package/lib/node/markdown/contentsList.js +2 -2
- package/lib/node/markdown/directive/embee.js +15 -18
- package/lib/node/markdown/directive/include.js +18 -23
- package/lib/node/markdown/directives.js +13 -62
- package/lib/node/markdown/division.js +63 -54
- package/lib/node/markdown/footnotesList.js +2 -9
- package/lib/node/markdown/heading.js +3 -3
- package/lib/node/markdown/plainText.js +10 -2
- package/lib/node/markdown/subDivision.js +24 -8
- package/lib/node/markdown/tableCell.js +4 -5
- package/lib/node/markdown.js +24 -60
- package/lib/replacement/contentsItem.js +9 -7
- package/lib/replacement/contentsLink.js +2 -31
- package/lib/replacement/contentsList.js +4 -10
- package/lib/replacement/embedDirective.js +163 -0
- package/lib/replacement/footnote.js +81 -5
- package/lib/replacement/footnotesItem.js +13 -17
- package/lib/replacement/footnotesList.js +23 -22
- package/lib/replacement/includeDirective.js +176 -0
- package/lib/replacement/line.js +9 -7
- package/lib/replacement/subDivision/embedDirectives.js +152 -0
- package/lib/replacement/subDivision/footnote.js +10 -2
- package/lib/replacement/subDivision/footnotesDirective.js +33 -2
- package/lib/replacement/subDivision/includeDirectives.js +184 -0
- package/lib/replacement/subDivision.js +55 -12
- package/lib/replacement.js +28 -6
- package/lib/utilities/childNodes.js +4 -17
- package/lib/utilities/footnotes.js +9 -6
- package/lib/utilities/processing.js +83 -0
- package/lib/utilities/query.js +2 -2
- package/lib/utilities/replacement.js +31 -6
- package/package.json +1 -1
- package/src/defaultMarkdownStyle.js +0 -1
- package/src/example/constants.js +3 -4
- package/src/example/importer.js +115 -0
- package/src/example/view/textarea/css.js +1 -1
- package/src/example/view.js +11 -36
- package/src/example.js +2 -2
- package/src/index.js +1 -1
- package/src/markdown/bnf.js +3 -1
- package/src/mixins/node.js +54 -5
- package/src/node/markdown/contentsLink.js +1 -2
- package/src/node/markdown/contentsList.js +1 -1
- package/src/node/markdown/directive/embee.js +15 -18
- package/src/node/markdown/directive/include.js +20 -28
- package/src/node/markdown/directives.js +15 -52
- package/src/node/markdown/division.js +74 -69
- package/src/node/markdown/footnotesList.js +2 -8
- package/src/node/markdown/heading.js +2 -2
- package/src/node/markdown/plainText.js +6 -0
- package/src/node/markdown/subDivision.js +24 -7
- package/src/node/markdown/tableCell.js +4 -5
- package/src/node/markdown.js +15 -70
- package/src/replacement/contentsItem.js +7 -2
- package/src/replacement/contentsLink.js +1 -3
- package/src/replacement/contentsList.js +4 -6
- package/src/replacement/embedDirective.js +34 -0
- package/src/replacement/footnote.js +38 -1
- package/src/replacement/footnotesItem.js +10 -23
- package/src/replacement/footnotesList.js +28 -20
- package/src/replacement/includeDirective.js +49 -0
- package/src/replacement/line.js +7 -2
- package/src/replacement/subDivision/embedDirectives.js +52 -0
- package/src/replacement/subDivision/footnote.js +9 -0
- package/src/replacement/subDivision/footnotesDirective.js +6 -0
- package/src/replacement/subDivision/includeDirectives.js +58 -0
- package/src/replacement/subDivision.js +13 -14
- package/src/replacement.js +19 -9
- package/src/utilities/childNodes.js +3 -5
- package/src/utilities/footnotes.js +9 -7
- package/src/utilities/processing.js +93 -0
- package/src/utilities/query.js +9 -9
- package/src/utilities/replacement.js +28 -5
- package/lib/replacement/imported.js +0 -151
- package/lib/utilities/markdown.js +0 -87
- package/src/replacement/imported.js +0 -13
- package/src/utilities/markdown.js +0 -103
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { MarkdownLexer, MarkdownParser } from "../index";
|
|
4
|
+
|
|
5
|
+
import { EMPTY_STRING } from "./constants";
|
|
6
|
+
|
|
7
|
+
const markdownLexer = MarkdownLexer.fromNothing(),
|
|
8
|
+
markdownParser = MarkdownParser.fromNothing();
|
|
9
|
+
|
|
10
|
+
export default function importer(filePath, context) {
|
|
11
|
+
const content = contentMap[filePath] || null;
|
|
12
|
+
|
|
13
|
+
if (content !== null) {
|
|
14
|
+
const startOfContent = true,
|
|
15
|
+
startRule = markdownParser.getStartRule(),
|
|
16
|
+
tokens = markdownLexer.tokenise(content),
|
|
17
|
+
node = markdownParser.parse(tokens, startRule, startOfContent),
|
|
18
|
+
importedNode = node, ///
|
|
19
|
+
importedTokens = tokens,
|
|
20
|
+
importedClassName = classNameFromFilePath(filePath);
|
|
21
|
+
|
|
22
|
+
Object.assign(context, {
|
|
23
|
+
importedNode,
|
|
24
|
+
importedTokens,
|
|
25
|
+
importedClassName
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
function classNameFromFilePath(filePath) {
|
|
31
|
+
const className = filePath.replace(/\.md/, EMPTY_STRING);
|
|
32
|
+
|
|
33
|
+
return className;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
const CONTENT_PATH = "content.md",
|
|
37
|
+
CONTENTS_PATH = "contents.md",
|
|
38
|
+
HALF_TITLE_PATH = "half-title.md",
|
|
39
|
+
FRONT_MATTER_PATH = "front-matter.md",
|
|
40
|
+
INTRODUCTION_PATH = "introduction.md",
|
|
41
|
+
GETTING_STARTED_PATH = "getting-started.md",
|
|
42
|
+
INSTALLING_THE_CLI_PATH = "installing-the-cli.md",
|
|
43
|
+
GETTING_TO_GRIPS_WITH_THE_IDE_PATH = "getting-to-grips-with-the-ide.md";
|
|
44
|
+
|
|
45
|
+
export const defaultContent = `@ignore
|
|
46
|
+
|
|
47
|
+
@include ${FRONT_MATTER_PATH}
|
|
48
|
+
@include ${CONTENT_PATH}`;
|
|
49
|
+
|
|
50
|
+
const contentContent = `@ignore
|
|
51
|
+
|
|
52
|
+
@include ${INTRODUCTION_PATH}
|
|
53
|
+
@include ${GETTING_STARTED_PATH}`,
|
|
54
|
+
|
|
55
|
+
contentsContent = `## Contents
|
|
56
|
+
|
|
57
|
+
@contents`,
|
|
58
|
+
|
|
59
|
+
halfTitleContent = `# Occam`,
|
|
60
|
+
|
|
61
|
+
frontMatterContent = `@ignore
|
|
62
|
+
|
|
63
|
+
@include ${HALF_TITLE_PATH}
|
|
64
|
+
@include ${CONTENTS_PATH}`,
|
|
65
|
+
|
|
66
|
+
introductionContent = `# Introduction
|
|
67
|
+
|
|
68
|
+
I have tried to make Occam[^occam] as useable as possible but there are limits.
|
|
69
|
+
At the end of the day it is an expert system and some of its parts, not least the verifier, need detailed explanation.
|
|
70
|
+
It is the purpose of this book is to provide these explanations.
|
|
71
|
+
|
|
72
|
+
This book also goes into considerable detail on the subject of Occam's approach to language, which largely boils down to its use of grammars.
|
|
73
|
+
Occam has its own language, called Florence,[^florence] but it will also support controlled natural languages in the near future.
|
|
74
|
+
Indeed, the verifier cannot distinguish between these languages at all.
|
|
75
|
+
This book explains how this is possible.
|
|
76
|
+
|
|
77
|
+
@footnotes
|
|
78
|
+
|
|
79
|
+
@pageNumber
|
|
80
|
+
`,
|
|
81
|
+
|
|
82
|
+
gettingStartedContent = `# Getting started
|
|
83
|
+
|
|
84
|
+
Another short paragraph with a reference to a footnote[^occam].
|
|
85
|
+
|
|
86
|
+
[^occam]: The word Occam is used somewhat nebulously here.
|
|
87
|
+
It is most often associated with Occam's IDE but in fact it encompasses a range of software and services.
|
|
88
|
+
This book explains these divers parts and there is a companion book, called The Foundations of Symbolic Reasoning, that covers the underlying theory.
|
|
89
|
+
|
|
90
|
+
[^florence]: Occam was originally called Florence but the former seemed more apt.
|
|
91
|
+
|
|
92
|
+
@footnotes
|
|
93
|
+
|
|
94
|
+
@embed ${INSTALLING_THE_CLI_PATH}
|
|
95
|
+
@embed ${GETTING_TO_GRIPS_WITH_THE_IDE_PATH}
|
|
96
|
+
|
|
97
|
+
@pageNumber
|
|
98
|
+
`,
|
|
99
|
+
|
|
100
|
+
installingTheCLIContent = `## Installing the CLI`,
|
|
101
|
+
|
|
102
|
+
gettingToGripsWithTheIDEIContent = `## Getting to grips with the IDE`;
|
|
103
|
+
|
|
104
|
+
const contentMap = {
|
|
105
|
+
|
|
106
|
+
[CONTENT_PATH]: contentContent,
|
|
107
|
+
[CONTENTS_PATH]: contentsContent,
|
|
108
|
+
[HALF_TITLE_PATH]: halfTitleContent,
|
|
109
|
+
[FRONT_MATTER_PATH]: frontMatterContent,
|
|
110
|
+
[INTRODUCTION_PATH]: introductionContent,
|
|
111
|
+
[GETTING_STARTED_PATH]: gettingStartedContent,
|
|
112
|
+
[INSTALLING_THE_CLI_PATH]: installingTheCLIContent,
|
|
113
|
+
[GETTING_TO_GRIPS_WITH_THE_IDE_PATH]: gettingToGripsWithTheIDEIContent
|
|
114
|
+
|
|
115
|
+
};
|
package/src/example/view.js
CHANGED
|
@@ -7,6 +7,7 @@ import { MarkdownLexer, MarkdownParser, MarkdownStyleLexer, MarkdownStyleParser
|
|
|
7
7
|
import { RowDiv, RowsDiv, ColumnDiv, ColumnsDiv, VerticalSplitterDiv, HorizontalSplitterDiv } from "easy-layout";
|
|
8
8
|
|
|
9
9
|
import HTMLDiv from "./view/div/html";
|
|
10
|
+
import importer from "./importer";
|
|
10
11
|
import PreviewDiv from "./view/div/preview";
|
|
11
12
|
import SubHeading from "./view/subHeading";
|
|
12
13
|
import CSSTextarea from "./view/textarea/css";
|
|
@@ -16,8 +17,9 @@ import RightSizeableDiv from "./view/div/sizeable/right";
|
|
|
16
17
|
import MarkdownContainerDiv from "./view/div/container/markdown";
|
|
17
18
|
import MarkdownStyleContainerDiv from "./view/div/container/markdownStyle";
|
|
18
19
|
|
|
19
|
-
import { postprocess } from "../utilities/
|
|
20
|
-
import {
|
|
20
|
+
import { postprocess } from "../utilities/processing";
|
|
21
|
+
import { defaultContent } from "./importer";
|
|
22
|
+
import { LINES_PER_PAGE, CONTENTS_DEPTH, CHARACTERS_PER_LINE } from "./constants";
|
|
21
23
|
|
|
22
24
|
const markdownLexer = MarkdownLexer.fromNothing(),
|
|
23
25
|
markdownParser = MarkdownParser.fromNothing(),
|
|
@@ -80,15 +82,15 @@ class View extends Element {
|
|
|
80
82
|
this.setTokens(tokens);
|
|
81
83
|
|
|
82
84
|
if (node !== null) {
|
|
83
|
-
const
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
const charactersPerLine = CHARACTERS_PER_LINE,
|
|
85
|
+
const divisionMarkdownNode = node, ///
|
|
86
|
+
charactersPerLine = CHARACTERS_PER_LINE,
|
|
87
|
+
contentsDepth = CONTENTS_DEPTH,
|
|
88
|
+
linesPerPage = LINES_PER_PAGE,
|
|
89
89
|
context = {
|
|
90
90
|
tokens,
|
|
91
91
|
importer,
|
|
92
|
+
linesPerPage,
|
|
93
|
+
contentsDepth,
|
|
92
94
|
charactersPerLine
|
|
93
95
|
},
|
|
94
96
|
divisionMarkdownNodes = postprocess(divisionMarkdownNode, context);
|
|
@@ -254,14 +256,7 @@ class View extends Element {
|
|
|
254
256
|
className: "view"
|
|
255
257
|
};
|
|
256
258
|
|
|
257
|
-
static initialMarkdown =
|
|
258
|
-
|
|
259
|
-
@embed introduction.md
|
|
260
|
-
|
|
261
|
-
@footnotes
|
|
262
|
-
|
|
263
|
-
@pageNumber
|
|
264
|
-
`;
|
|
259
|
+
static initialMarkdown = defaultContent; ///
|
|
265
260
|
|
|
266
261
|
static initialMarkdownStyle = `width: 100%;
|
|
267
262
|
position: absolute;
|
|
@@ -275,23 +270,3 @@ export default withStyle(View)`
|
|
|
275
270
|
padding: 1rem;
|
|
276
271
|
|
|
277
272
|
`;
|
|
278
|
-
|
|
279
|
-
function importer(filePath, context) {
|
|
280
|
-
const content = `Florence [^florence].
|
|
281
|
-
|
|
282
|
-
[^florence]: Florence footnote.
|
|
283
|
-
`,
|
|
284
|
-
startOfContent = true,
|
|
285
|
-
startRule = markdownParser.getStartRule(),
|
|
286
|
-
tokens = markdownLexer.tokenise(content),
|
|
287
|
-
node = markdownParser.parse(tokens, startRule, startOfContent),
|
|
288
|
-
importedNode = node, ///
|
|
289
|
-
importedTokens = tokens,
|
|
290
|
-
importedClassName = "introduction";
|
|
291
|
-
|
|
292
|
-
Object.assign(context, {
|
|
293
|
-
importedNode,
|
|
294
|
-
importedTokens,
|
|
295
|
-
importedClassName
|
|
296
|
-
});
|
|
297
|
-
}
|
package/src/example.js
CHANGED
|
@@ -9,13 +9,13 @@ import { mediaTypeNames, MarkdownStyleElement, DefaultMarkdownStyleElement } fro
|
|
|
9
9
|
|
|
10
10
|
import View from "./example/view";
|
|
11
11
|
|
|
12
|
-
import {
|
|
12
|
+
import { PREVIEWED_DIV_SELECTORS_STRING } from "./example/constants";
|
|
13
13
|
|
|
14
14
|
const { renderStyles } = withStyle,
|
|
15
15
|
{ PREVIEW_MEDIA_TYPE_NAME } = mediaTypeNames;
|
|
16
16
|
|
|
17
17
|
const mediaTypeName = PREVIEW_MEDIA_TYPE_NAME,
|
|
18
|
-
selectorsString =
|
|
18
|
+
selectorsString = PREVIEWED_DIV_SELECTORS_STRING;
|
|
19
19
|
|
|
20
20
|
DefaultMarkdownStyleElement.fromMediaTypeNameAndSelectorsString(mediaTypeName, selectorsString);
|
|
21
21
|
|
package/src/index.js
CHANGED
|
@@ -8,8 +8,8 @@ export { default as MarkdownStyleParser } from "./markdownStyle/parser";
|
|
|
8
8
|
export { default as cssUtilities } from "./utilities/css";
|
|
9
9
|
export { default as nodeUtilities } from "./utilities/node";
|
|
10
10
|
export { default as queryUtilities } from "./utilities/query";
|
|
11
|
-
export { default as markdownUtilities } from "./utilities/markdown";
|
|
12
11
|
export { default as footnotesUtilities } from "./utilities/footnotes";
|
|
12
|
+
export { default as processingUtilities } from "./utilities/processing";
|
|
13
13
|
|
|
14
14
|
export { default as nodeMap } from "./nodeMap";
|
|
15
15
|
export { default as ruleNames } from "./ruleNames";
|
package/src/markdown/bnf.js
CHANGED
|
@@ -49,8 +49,10 @@ const bnf = `
|
|
|
49
49
|
|
|
50
50
|
| footnotesDirective
|
|
51
51
|
|
|
52
|
-
|
|
|
52
|
+
| embedDirective ( endOfLine embedDirective )*
|
|
53
53
|
|
|
54
|
+
| includeDirective ( endOfLine includeDirective )*
|
|
55
|
+
|
|
54
56
|
;
|
|
55
57
|
|
|
56
58
|
|
package/src/mixins/node.js
CHANGED
|
@@ -26,16 +26,16 @@ function removeChildNode(removedChildNode) {
|
|
|
26
26
|
childNodes.splice(start, deleteCount);
|
|
27
27
|
}
|
|
28
28
|
|
|
29
|
-
function prependChildNode(
|
|
29
|
+
function prependChildNode(prependedChildNode) {
|
|
30
30
|
const childNodes = this.getChildNodes();
|
|
31
31
|
|
|
32
|
-
childNodes.unshift(
|
|
32
|
+
childNodes.unshift(prependedChildNode);
|
|
33
33
|
}
|
|
34
34
|
|
|
35
|
-
function appendChildNode(
|
|
35
|
+
function appendChildNode(appendedChildNode) {
|
|
36
36
|
const childNodes = this.getChildNodes();
|
|
37
37
|
|
|
38
|
-
childNodes.push(
|
|
38
|
+
childNodes.push(appendedChildNode);
|
|
39
39
|
}
|
|
40
40
|
|
|
41
41
|
function replaceChildNode(replacedChildNode, replacementChildNode) {
|
|
@@ -56,6 +56,24 @@ function replaceChildNodes(replacedChildNode, replacementChildNodes) {
|
|
|
56
56
|
childNodes.splice(start, deleteCount, ...replacementChildNodes);
|
|
57
57
|
}
|
|
58
58
|
|
|
59
|
+
function addChildNodeAfter(existingChildNode, addedChildNode) {
|
|
60
|
+
const childNodes = this.getChildNodes(),
|
|
61
|
+
index = childNodes.indexOf(existingChildNode),
|
|
62
|
+
start = index + 1,
|
|
63
|
+
deleteCount = 0;
|
|
64
|
+
|
|
65
|
+
childNodes.splice(start, deleteCount, addedChildNode);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
function addChildNodesAfter(existingChildNode, addedChildNodes) {
|
|
69
|
+
const childNodes = this.getChildNodes(),
|
|
70
|
+
index = childNodes.indexOf(existingChildNode),
|
|
71
|
+
start = index + 1,
|
|
72
|
+
deleteCount = 0;
|
|
73
|
+
|
|
74
|
+
childNodes.splice(start, deleteCount, ...addedChildNodes);
|
|
75
|
+
}
|
|
76
|
+
|
|
59
77
|
function getDescendantNodes(descendantNodes = []) {
|
|
60
78
|
const descendantNode = this; ///
|
|
61
79
|
|
|
@@ -76,6 +94,34 @@ function getDescendantNodes(descendantNodes = []) {
|
|
|
76
94
|
return descendantNodes;
|
|
77
95
|
}
|
|
78
96
|
|
|
97
|
+
function retrieveParentNode(childNode, node = this) {
|
|
98
|
+
let parentNode = null;
|
|
99
|
+
|
|
100
|
+
const nodeNonTerminalNode = node.isNonTerminalNode();
|
|
101
|
+
|
|
102
|
+
if (nodeNonTerminalNode) {
|
|
103
|
+
const nonTerminalNode = node, ///
|
|
104
|
+
childNodes = nonTerminalNode.getChildNodes(),
|
|
105
|
+
index = childNodes.indexOf(childNode);
|
|
106
|
+
|
|
107
|
+
if (index !== -1) {
|
|
108
|
+
parentNode = node; ///
|
|
109
|
+
} else {
|
|
110
|
+
const nodes = childNodes; ///
|
|
111
|
+
|
|
112
|
+
nodes.some((node) => {
|
|
113
|
+
parentNode = this.retrieveParentNode(childNode, node);
|
|
114
|
+
|
|
115
|
+
if (parentNode !== null) {
|
|
116
|
+
return true;
|
|
117
|
+
}
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
return parentNode;
|
|
123
|
+
}
|
|
124
|
+
|
|
79
125
|
const nodeMixins = {
|
|
80
126
|
removeChildNodes,
|
|
81
127
|
removeChildNode,
|
|
@@ -83,7 +129,10 @@ const nodeMixins = {
|
|
|
83
129
|
prependChildNode,
|
|
84
130
|
replaceChildNode,
|
|
85
131
|
replaceChildNodes,
|
|
86
|
-
|
|
132
|
+
addChildNodeAfter,
|
|
133
|
+
addChildNodesAfter,
|
|
134
|
+
getDescendantNodes,
|
|
135
|
+
retrieveParentNode
|
|
87
136
|
};
|
|
88
137
|
|
|
89
138
|
export default nodeMixins;
|
|
@@ -31,8 +31,7 @@ export default class ContentsLinkMarkdownNode extends MarkdownNode {
|
|
|
31
31
|
clone() { return super.clone(this.identifier); }
|
|
32
32
|
|
|
33
33
|
static fromLineReplacementAndIdentifier(lineReplacement, identifier) {
|
|
34
|
-
const
|
|
35
|
-
lineMarkdownNode = lineReplacementNode, ///
|
|
34
|
+
const lineMarkdownNode = lineReplacement.getLineMarkdownNode(),
|
|
36
35
|
ruleName = CONTENTS_LINK_RULE_NAME,
|
|
37
36
|
childNodes = [
|
|
38
37
|
lineMarkdownNode
|
|
@@ -8,7 +8,7 @@ export default class ContentsListMarkdownNode extends MarkdownNode {
|
|
|
8
8
|
static fromContentsItemReplacements(contentsItemReplacements) {
|
|
9
9
|
const ruleName = CONTENTS_LIST_RULE_NAME,
|
|
10
10
|
childNodes = contentsItemReplacements.map((contentsItemReplacement) => {
|
|
11
|
-
const contentsItemReplacementNode = contentsItemReplacement.
|
|
11
|
+
const contentsItemReplacementNode = contentsItemReplacement.getContentsItemMarkdownNode(),
|
|
12
12
|
childNode = contentsItemReplacementNode; ///
|
|
13
13
|
|
|
14
14
|
return childNode;
|
|
@@ -2,38 +2,35 @@
|
|
|
2
2
|
|
|
3
3
|
import { arrayUtilities } from "necessary";
|
|
4
4
|
|
|
5
|
-
import ImportedReplacement from "../../../replacement/imported";
|
|
6
5
|
import DirectiveMarkdownNode from "../../../node/markdown/directive";
|
|
6
|
+
import EmbedDirectiveReplacement from "../../../replacement/embedDirective";
|
|
7
7
|
|
|
8
8
|
const { last } = arrayUtilities;
|
|
9
9
|
|
|
10
10
|
export default class EmbedDirectiveMarkdownNode extends DirectiveMarkdownNode {
|
|
11
|
-
|
|
12
|
-
let
|
|
11
|
+
resolve(context) {
|
|
12
|
+
let embedDirectiveReplacement = null;
|
|
13
13
|
|
|
14
|
-
const { importer
|
|
14
|
+
const { importer } = context;
|
|
15
15
|
|
|
16
|
-
|
|
17
|
-
const filePath = this.filePath(context);
|
|
16
|
+
const filePath = this.filePath(context);
|
|
18
17
|
|
|
19
|
-
|
|
18
|
+
importer(filePath, context);
|
|
20
19
|
|
|
21
|
-
|
|
22
|
-
|
|
20
|
+
const { importedNode = null,
|
|
21
|
+
importedTokens = null } = context;
|
|
23
22
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
23
|
+
if (importedNode !== null) {
|
|
24
|
+
delete context.importedNode;
|
|
25
|
+
delete context.importedTokens;
|
|
27
26
|
|
|
28
|
-
|
|
27
|
+
const divisionMarkdownNode = importedNode, ///
|
|
28
|
+
tokens = importedTokens; ///
|
|
29
29
|
|
|
30
|
-
|
|
31
|
-
delete context.importedTokens;
|
|
32
|
-
delete context.importedClassName;
|
|
33
|
-
}
|
|
30
|
+
embedDirectiveReplacement = EmbedDirectiveReplacement.fromDivisionMarkdownNodeAndTokens(divisionMarkdownNode, tokens);
|
|
34
31
|
}
|
|
35
32
|
|
|
36
|
-
return
|
|
33
|
+
return embedDirectiveReplacement;
|
|
37
34
|
}
|
|
38
35
|
|
|
39
36
|
filePath(context) {
|
|
@@ -3,47 +3,39 @@
|
|
|
3
3
|
import { arrayUtilities } from "necessary";
|
|
4
4
|
|
|
5
5
|
import DirectiveMarkdownNode from "../../../node/markdown/directive";
|
|
6
|
+
import IncludeDirectiveReplacement from "../../../replacement/includeDirective";
|
|
6
7
|
|
|
7
|
-
const {
|
|
8
|
+
const { last } = arrayUtilities;
|
|
8
9
|
|
|
9
10
|
export default class IncludeDirectiveMarkdownNode extends DirectiveMarkdownNode {
|
|
10
|
-
|
|
11
|
-
let
|
|
11
|
+
resolve(context) {
|
|
12
|
+
let includeDirectiveReplacement = null;
|
|
12
13
|
|
|
13
|
-
const { importer
|
|
14
|
+
const { importer } = context;
|
|
14
15
|
|
|
15
|
-
|
|
16
|
-
const filePath = this.filePath(context);
|
|
16
|
+
const filePath = this.filePath(context);
|
|
17
17
|
|
|
18
|
-
|
|
18
|
+
importer(filePath, context);
|
|
19
19
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
20
|
+
const { importedNode = null,
|
|
21
|
+
importedTokens = null,
|
|
22
|
+
importedClassName = null } = context;
|
|
23
23
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
24
|
+
if (importedNode !== null) {
|
|
25
|
+
delete context.importedNode;
|
|
26
|
+
delete context.importedTokens;
|
|
27
|
+
delete context.importedClassName;
|
|
28
28
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
ignored = divisionMarkdownNode.isIgnored();
|
|
29
|
+
const divisionMarkdownNode = importedNode, ///
|
|
30
|
+
divisionClassName = importedClassName, ///
|
|
31
|
+
tokens = importedTokens; ///
|
|
33
32
|
|
|
34
|
-
|
|
33
|
+
divisionMarkdownNode.setDivisionClassName(divisionClassName);
|
|
35
34
|
|
|
36
|
-
|
|
37
|
-
push(tokens, importedTokens);
|
|
38
|
-
|
|
39
|
-
divisionMarkdownNodes.push(divisionMarkdownNode);
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
divisionMarkdownNode.resolveIncludes(context);
|
|
43
|
-
}
|
|
35
|
+
includeDirectiveReplacement = IncludeDirectiveReplacement.fromDivisionMarkdownNodeAndTokens(divisionMarkdownNode, tokens);
|
|
44
36
|
}
|
|
45
37
|
|
|
46
|
-
return
|
|
38
|
+
return includeDirectiveReplacement;
|
|
47
39
|
}
|
|
48
40
|
|
|
49
41
|
filePath(context) {
|
|
@@ -4,75 +4,38 @@ import { arrayUtilities } from "necessary";
|
|
|
4
4
|
|
|
5
5
|
import MarkdownNode from "../../node/markdown";
|
|
6
6
|
|
|
7
|
-
const {
|
|
7
|
+
const { first } = arrayUtilities;
|
|
8
8
|
|
|
9
9
|
export default class DirectivesMarkdownNode extends MarkdownNode {
|
|
10
|
-
constructor(ruleName, childNodes, opacity, precedence, domElement, domElements) {
|
|
11
|
-
super(ruleName, childNodes, opacity, precedence, domElement);
|
|
12
|
-
|
|
13
|
-
this.domElements = domElements;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
10
|
getDOMElement() {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
if (domElementsLength > 0) {
|
|
22
|
-
const firstDOMElement = first(this.domElements);
|
|
23
|
-
|
|
24
|
-
domElement = firstDOMElement; ///
|
|
25
|
-
}
|
|
11
|
+
const directiveMarkdownNode = this.getDirectiveMarkdownNode(),
|
|
12
|
+
directiveMarkdownNodeDOMElement = directiveMarkdownNode.getDOMElement(),
|
|
13
|
+
domElement = directiveMarkdownNodeDOMElement; ///
|
|
26
14
|
|
|
27
15
|
return domElement;
|
|
28
16
|
}
|
|
29
17
|
|
|
30
|
-
getDOMElements() {
|
|
31
|
-
return this.domElements;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
18
|
asHTML(indent, context) {
|
|
35
|
-
const
|
|
36
|
-
|
|
19
|
+
const directiveMarkdownNode = this.getDirectiveMarkdownNode(),
|
|
20
|
+
directiveMarkdownNodeHTML = directiveMarkdownNode.asHTML(indent, context),
|
|
21
|
+
html = directiveMarkdownNodeHTML; ///
|
|
37
22
|
|
|
38
23
|
return html;
|
|
39
24
|
}
|
|
40
25
|
|
|
41
26
|
createDOMElement(context) {
|
|
42
|
-
const
|
|
43
|
-
childNodes = this.getChildNodes();
|
|
44
|
-
|
|
45
|
-
clear(this.domElements);
|
|
27
|
+
const directiveMarkdownNode = this.getDirectiveMarkdownNode();
|
|
46
28
|
|
|
47
|
-
|
|
48
|
-
const childNodeNonTerminalNode = childNode.isNonTerminalNode();
|
|
49
|
-
|
|
50
|
-
if (childNodeNonTerminalNode) {
|
|
51
|
-
const nonTerminalNode = childNode, ///
|
|
52
|
-
markdownNode = nonTerminalNode; ///
|
|
53
|
-
|
|
54
|
-
markdownNode.createDOMElement(context);
|
|
55
|
-
|
|
56
|
-
const markdownNodeDOMElements = markdownNode.getDOMElements();
|
|
57
|
-
|
|
58
|
-
push(this.domElements, markdownNodeDOMElements);
|
|
59
|
-
}
|
|
60
|
-
});
|
|
61
|
-
|
|
62
|
-
return domElement;
|
|
29
|
+
directiveMarkdownNode.createDOMElement(context);
|
|
63
30
|
}
|
|
64
31
|
|
|
65
|
-
|
|
66
|
-
const
|
|
67
|
-
|
|
32
|
+
getDirectiveMarkdownNode() {
|
|
33
|
+
const childNodes = this.getChildNodes(),
|
|
34
|
+
firstChildNode = first(childNodes),
|
|
35
|
+
directiveMarkdownNode = firstChildNode; ///
|
|
68
36
|
|
|
69
|
-
return
|
|
37
|
+
return directiveMarkdownNode;
|
|
70
38
|
}
|
|
71
39
|
|
|
72
|
-
static fromRuleNameChildNodesAndOpacity(ruleName, childNodes, opacity) {
|
|
73
|
-
const domElements = [],
|
|
74
|
-
directivesMarkdownNode = MarkdownNode.fromRuleNameChildNodesAndOpacity(DirectivesMarkdownNode, ruleName, childNodes, opacity, domElements);
|
|
75
|
-
|
|
76
|
-
return directivesMarkdownNode;
|
|
77
|
-
}
|
|
40
|
+
static fromRuleNameChildNodesAndOpacity(ruleName, childNodes, opacity) { return MarkdownNode.fromRuleNameChildNodesAndOpacity(DirectivesMarkdownNode, ruleName, childNodes, opacity); }
|
|
78
41
|
}
|