highmark-markdown 1.1.113 → 1.1.115
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 +66 -23
- package/lib/example/view/xmp.js +2 -3
- package/lib/example/view.js +9 -13
- package/lib/utilities/grammar.js +50 -2
- package/lib/utilities/index.js +8 -10
- package/package.json +1 -1
- package/src/example/view/xmp.js +1 -4
- package/src/example/view.js +19 -21
- package/src/utilities/grammar.js +30 -1
- package/src/utilities/index.js +15 -24
package/src/example/view.js
CHANGED
|
@@ -22,13 +22,16 @@ import MarkdownStyleContainerDiv from "./view/div/container/markdownStyle";
|
|
|
22
22
|
|
|
23
23
|
import { importer } from "./importer";
|
|
24
24
|
import { WEB_TARGET } from "../targets";
|
|
25
|
+
import { PREVIEW_CSS_SELECTORS_STRING } from "./constants";
|
|
25
26
|
|
|
26
27
|
const { tokensFromMarkdown,
|
|
27
28
|
markdownNodeFromTokens,
|
|
28
29
|
tokensFromMarkdownStyle,
|
|
29
30
|
markdownStyleNodeFromTokens,
|
|
30
31
|
topmostHTMLNodeFromMarkdownNode,
|
|
31
|
-
|
|
32
|
+
htmlFromMarkdownOptionsAndImporter,
|
|
33
|
+
topmostCSSNodeFromMarkdownStyleNode,
|
|
34
|
+
cssFromMarkdownStyleAndCSSSelectorsString } = grammarUtilities;
|
|
32
35
|
|
|
33
36
|
class View extends Element {
|
|
34
37
|
pageUpdateCustomHandler = (event, element, index) => {
|
|
@@ -98,20 +101,6 @@ class View extends Element {
|
|
|
98
101
|
this.setTopmostMarkdownStyleNode(topmostMarkdownStyleNode);
|
|
99
102
|
|
|
100
103
|
this.updateMarkdownStyleParseTreeTextarea(parseTree);
|
|
101
|
-
|
|
102
|
-
const markdownStyleElement = this.getMarkdownStyleElement(),
|
|
103
|
-
topmostCSSNode = topmostCSSNodeFromMarkdownStyleNode(markdownStyleNode),
|
|
104
|
-
target = WEB_TARGET,
|
|
105
|
-
context = {
|
|
106
|
-
target,
|
|
107
|
-
tokens
|
|
108
|
-
};
|
|
109
|
-
|
|
110
|
-
topmostCSSNode.resolve(context);
|
|
111
|
-
|
|
112
|
-
const css = topmostCSSNode.asCSS(context);
|
|
113
|
-
|
|
114
|
-
markdownStyleElement.setCSS(css);
|
|
115
104
|
}
|
|
116
105
|
|
|
117
106
|
updateMarkdown() {
|
|
@@ -176,7 +165,6 @@ class View extends Element {
|
|
|
176
165
|
tokens = markdownTokens; ///
|
|
177
166
|
|
|
178
167
|
context = {
|
|
179
|
-
indexOptions,
|
|
180
168
|
tokens
|
|
181
169
|
};
|
|
182
170
|
|
|
@@ -191,15 +179,13 @@ class View extends Element {
|
|
|
191
179
|
const divisionHTMLNOdeParseTree = divisionHTMLNOde.asParseTree(),
|
|
192
180
|
htmlParseTree = divisionHTMLNOdeParseTree, ///
|
|
193
181
|
multiplicity = topmostHTMLNode.getMultiplicity(),
|
|
194
|
-
length = multiplicity;
|
|
182
|
+
length = multiplicity; ///
|
|
195
183
|
|
|
196
184
|
context = {
|
|
197
185
|
tokens,
|
|
198
186
|
pathToURL
|
|
199
187
|
};
|
|
200
188
|
|
|
201
|
-
this.updateXMP(divisionHTMLNOde, context);
|
|
202
|
-
|
|
203
189
|
this.updatePreviewDiv(divisionHTMLNOde, context);
|
|
204
190
|
|
|
205
191
|
this.updatePlainTextTextarea(divisionHTMLNOde, context);
|
|
@@ -207,6 +193,12 @@ class View extends Element {
|
|
|
207
193
|
this.updateHTMLParseTreeTextarea(htmlParseTree);
|
|
208
194
|
|
|
209
195
|
this.updatePageButtonsDiv(length, index);
|
|
196
|
+
|
|
197
|
+
const markdown = this.getMarkdown(),
|
|
198
|
+
options = indexOptions, ///
|
|
199
|
+
html = htmlFromMarkdownOptionsAndImporter(markdown, options, importer);
|
|
200
|
+
|
|
201
|
+
this.updateXMP(html, context);
|
|
210
202
|
}
|
|
211
203
|
|
|
212
204
|
updateCSS() {
|
|
@@ -224,11 +216,17 @@ class View extends Element {
|
|
|
224
216
|
topmostCSSNode.resolve(context);
|
|
225
217
|
|
|
226
218
|
const topmostCSSNodeParseTree = topmostCSSNode.asParseTree(tokens),
|
|
227
|
-
cssParseTree = topmostCSSNodeParseTree
|
|
228
|
-
css = topmostCSSNode.asCSS(context);
|
|
219
|
+
cssParseTree = topmostCSSNodeParseTree; ///
|
|
229
220
|
|
|
230
221
|
this.updateCSSParseTreeTextarea(cssParseTree);
|
|
231
222
|
|
|
223
|
+
const markdownStyleElement = this.getMarkdownStyleElement(),
|
|
224
|
+
cssSelectorsString = PREVIEW_CSS_SELECTORS_STRING,
|
|
225
|
+
markdownStyle = this.getMarkdownStyle(),
|
|
226
|
+
css = cssFromMarkdownStyleAndCSSSelectorsString(markdownStyle, cssSelectorsString);
|
|
227
|
+
|
|
228
|
+
markdownStyleElement.setCSS(css);
|
|
229
|
+
|
|
232
230
|
this.setCSS(css);
|
|
233
231
|
}
|
|
234
232
|
|
package/src/utilities/grammar.js
CHANGED
|
@@ -101,6 +101,34 @@ export function topmostHTMLNodeFromMarkdownNode(markdownNode, ClassFromOuterNode
|
|
|
101
101
|
return topmostHTMLNode;
|
|
102
102
|
}
|
|
103
103
|
|
|
104
|
+
export function htmlFromMarkdownOptionsAndImporter(markdown, options, importer) {
|
|
105
|
+
let html = null;
|
|
106
|
+
|
|
107
|
+
const tokens = tokensFromMarkdown(markdown),
|
|
108
|
+
markdownNode = markdownNodeFromTokens(tokens);
|
|
109
|
+
|
|
110
|
+
if (markdownNode !== null) {
|
|
111
|
+
const topmostMarkdownNode = markdownNode, ///
|
|
112
|
+
context = {
|
|
113
|
+
tokens,
|
|
114
|
+
importer,
|
|
115
|
+
...options
|
|
116
|
+
};
|
|
117
|
+
|
|
118
|
+
topmostMarkdownNode.resolve(context);
|
|
119
|
+
|
|
120
|
+
const topmostHTMLNode = topmostHTMLNodeFromMarkdownNode(markdownNode);
|
|
121
|
+
|
|
122
|
+
topmostHTMLNode.resolve(context);
|
|
123
|
+
|
|
124
|
+
const divisionHTMLNOde = topmostHTMLNode.getDivisionHTMLNode();
|
|
125
|
+
|
|
126
|
+
html = divisionHTMLNOde.asHTML(context);
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
return html;
|
|
130
|
+
}
|
|
131
|
+
|
|
104
132
|
export function topmostCSSNodeFromMarkdownStyleNode(markdownStyleNode, ClassFromOuterNode = CSSClassFromMarkdownStyleNode) {
|
|
105
133
|
const node = markdownStyleNode, ///
|
|
106
134
|
queries = markdownStyleQueries, ///
|
|
@@ -132,7 +160,7 @@ export function cssFromMarkdownStyleAndCSSSelectorsString(markdownStyle, cssSele
|
|
|
132
160
|
}
|
|
133
161
|
|
|
134
162
|
css = `${cssSelectorsString} {
|
|
135
|
-
|
|
163
|
+
${css}
|
|
136
164
|
}`;
|
|
137
165
|
|
|
138
166
|
return css;
|
|
@@ -146,6 +174,7 @@ export default {
|
|
|
146
174
|
markdownStyleNodeFromTokens,
|
|
147
175
|
CSSClassFromMarkdownStyleNode,
|
|
148
176
|
topmostHTMLNodeFromMarkdownNode,
|
|
177
|
+
htmlFromMarkdownOptionsAndImporter,
|
|
149
178
|
topmostCSSNodeFromMarkdownStyleNode,
|
|
150
179
|
cssFromMarkdownStyleAndCSSSelectorsString
|
|
151
180
|
};
|
package/src/utilities/index.js
CHANGED
|
@@ -34,8 +34,7 @@ export function indexMapFromIndexDirectiveHTMLNodeAndDivisionHTMLNodes(indexDire
|
|
|
34
34
|
function createIndexMap(indexDirectiveHTMLNode, divisionHTMLNodes, context) {
|
|
35
35
|
const indexMap = {};
|
|
36
36
|
|
|
37
|
-
const {
|
|
38
|
-
{ phrases } = indexOptions,
|
|
37
|
+
const { phrases } = context,
|
|
39
38
|
indexMatches = phrases.map((phrase) => {
|
|
40
39
|
const indexMatch = IndexMatch.fromPhrase(phrase);
|
|
41
40
|
|
|
@@ -115,8 +114,7 @@ function compressPageNumbers(indexMap) {
|
|
|
115
114
|
}
|
|
116
115
|
|
|
117
116
|
function removeIgnoredWords(indexMap, context) {
|
|
118
|
-
const {
|
|
119
|
-
{ ignoredWords } = indexOptions;
|
|
117
|
+
const { ignoredWords } = context;
|
|
120
118
|
|
|
121
119
|
ignoredWords.forEach((ignoredWord) => {
|
|
122
120
|
delete indexMap[ignoredWord];
|
|
@@ -124,14 +122,12 @@ function removeIgnoredWords(indexMap, context) {
|
|
|
124
122
|
}
|
|
125
123
|
|
|
126
124
|
function adjustProperNouns(indexMap, context) {
|
|
127
|
-
const {
|
|
128
|
-
|
|
125
|
+
const { properNouns } = context,
|
|
126
|
+
lowerCaseProperNouns = properNouns.map((properNoun) => {
|
|
127
|
+
const lowerCaseProperNoun = properNoun.toLowerCase();
|
|
129
128
|
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
return lowerCaseProperNoun;
|
|
134
|
-
});
|
|
129
|
+
return lowerCaseProperNoun;
|
|
130
|
+
});
|
|
135
131
|
|
|
136
132
|
mapKeys(indexMap, (wordOrPhrase) => {
|
|
137
133
|
const index = lowerCaseProperNouns.findIndex((lowerCaseProperName) => {
|
|
@@ -163,14 +159,12 @@ function preparePlainText(plainText) {
|
|
|
163
159
|
}
|
|
164
160
|
|
|
165
161
|
function adjustAcronyms(indexMap, context) {
|
|
166
|
-
const {
|
|
167
|
-
|
|
162
|
+
const { acronyms } = context,
|
|
163
|
+
lowerCaseAcronyms = acronyms.map((acronym) => {
|
|
164
|
+
const lowerCaseAcronym = acronym.toLowerCase();
|
|
168
165
|
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
return lowerCaseAcronym;
|
|
173
|
-
});
|
|
166
|
+
return lowerCaseAcronym;
|
|
167
|
+
});
|
|
174
168
|
|
|
175
169
|
mapKeys(indexMap, (wordOrPhrase) => {
|
|
176
170
|
const index = lowerCaseAcronyms.findIndex((lowerCaseProperName) => {
|
|
@@ -190,8 +184,7 @@ function adjustAcronyms(indexMap, context) {
|
|
|
190
184
|
}
|
|
191
185
|
|
|
192
186
|
function adjustMixedPlurals(indexMap, context) {
|
|
193
|
-
const {
|
|
194
|
-
{ plurals } = indexOptions,
|
|
187
|
+
const { plurals } = context,
|
|
195
188
|
mixedPlurals = reducePlurals(plurals, isMixed),
|
|
196
189
|
pluralPlurals = mapPlurals(mixedPlurals, mixedToPlural),
|
|
197
190
|
singularPlurals = mapPlurals(mixedPlurals, mixedToSingular);
|
|
@@ -236,8 +229,7 @@ function adjustMixedPlurals(indexMap, context) {
|
|
|
236
229
|
}
|
|
237
230
|
|
|
238
231
|
function adjustPluralPlurals(indexMap, context) {
|
|
239
|
-
const {
|
|
240
|
-
{ plurals } = indexOptions,
|
|
232
|
+
const { plurals } = context,
|
|
241
233
|
pluralPlurals = reducePlurals(plurals, isPlural),
|
|
242
234
|
singularPlurals = mapPlurals(pluralPlurals, pluralToSingular);
|
|
243
235
|
|
|
@@ -263,8 +255,7 @@ function adjustPluralPlurals(indexMap, context) {
|
|
|
263
255
|
}
|
|
264
256
|
|
|
265
257
|
function adjustSingularPlurals(indexMap, context) {
|
|
266
|
-
const {
|
|
267
|
-
{ plurals } = indexOptions,
|
|
258
|
+
const { plurals } = context,
|
|
268
259
|
singularPlurals = reducePlurals(plurals, isSingular),
|
|
269
260
|
pluralPlurals = mapPlurals(singularPlurals, singularToPlural);
|
|
270
261
|
|