highmark-cli 0.0.114 → 0.0.116
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.
|
@@ -2,21 +2,31 @@
|
|
|
2
2
|
|
|
3
3
|
const importer = require("../importer");
|
|
4
4
|
|
|
5
|
-
const {
|
|
5
|
+
const { readFile } = require("../utilities/fileSystem"),
|
|
6
|
+
{ classNameFromFilePath } = require("../utilities/division"),
|
|
7
|
+
{ nodeFromTokens, tokensFromContent } = require("../utilities/markdown"),
|
|
8
|
+
{ UNABLE_TO_CONVERT_MARKDOWN_TO_HTML_MESSAGE } = require("../messages");
|
|
6
9
|
|
|
7
10
|
function markdownHTMLOperation(proceed, abort, context) {
|
|
8
11
|
const { inputFilePath } = context,
|
|
9
|
-
filePath = inputFilePath
|
|
12
|
+
filePath = inputFilePath, ///
|
|
13
|
+
content = readFile(filePath);
|
|
10
14
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
});
|
|
15
|
+
if (content === null) {
|
|
16
|
+
const message = UNABLE_TO_CONVERT_MARKDOWN_TO_HTML_MESSAGE;
|
|
14
17
|
|
|
15
|
-
|
|
18
|
+
console.log(message);
|
|
16
19
|
|
|
17
|
-
|
|
20
|
+
abort();
|
|
18
21
|
|
|
19
|
-
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
const className = classNameFromFilePath(filePath),
|
|
26
|
+
tokens = tokensFromContent(content),
|
|
27
|
+
node = nodeFromTokens(tokens);
|
|
28
|
+
|
|
29
|
+
if (node === null) {
|
|
20
30
|
const message = UNABLE_TO_CONVERT_MARKDOWN_TO_HTML_MESSAGE;
|
|
21
31
|
|
|
22
32
|
console.log(message);
|
|
@@ -26,17 +36,16 @@ function markdownHTMLOperation(proceed, abort, context) {
|
|
|
26
36
|
return;
|
|
27
37
|
}
|
|
28
38
|
|
|
29
|
-
|
|
30
|
-
|
|
39
|
+
Object.assign(context, {
|
|
40
|
+
tokens,
|
|
41
|
+
importer
|
|
42
|
+
});
|
|
31
43
|
|
|
32
|
-
const
|
|
33
|
-
|
|
34
|
-
parentNode = null,
|
|
44
|
+
const parentNode = null,
|
|
45
|
+
divisionClassName = className, ///
|
|
35
46
|
divisionMarkdownNode = node; ///
|
|
36
47
|
|
|
37
|
-
|
|
38
|
-
tokens
|
|
39
|
-
});
|
|
48
|
+
divisionMarkdownNode.setDivisionClassName(divisionClassName);
|
|
40
49
|
|
|
41
50
|
divisionMarkdownNode.resolveImports(parentNode, context);
|
|
42
51
|
|
|
@@ -3,34 +3,44 @@
|
|
|
3
3
|
const { filePathUtilities } = require("occam-entities"),
|
|
4
4
|
{ cssUtilities, defaultMarkdownStyle } = require("highmark-markdown-style")
|
|
5
5
|
|
|
6
|
-
const {
|
|
6
|
+
const { classNameFromFilePath } = require("../utilities/division"),
|
|
7
|
+
{ readFile, readDirectory } = require("../utilities/fileSystem"),
|
|
7
8
|
{ DEFAULT_SELECTOR_STRING } = require("../constants"),
|
|
8
|
-
{ directoryPathFromFilePath } = require("../utilities/path")
|
|
9
|
-
{ divisionClassNameFromFilePath } = require("../utilities/division");
|
|
9
|
+
{ directoryPathFromFilePath } = require("../utilities/path");
|
|
10
10
|
|
|
11
|
-
const {
|
|
12
|
-
{
|
|
11
|
+
const { cssFromMarkdownStyleAndSelectorString } = cssUtilities,
|
|
12
|
+
{ isFilePathMarkdownStyleFilePath, isFilePathDefaultMarkdownStyleFilePath } = filePathUtilities;
|
|
13
13
|
|
|
14
14
|
function markdownStylesCSSOperation(proceed, abort, context) {
|
|
15
15
|
const { inputFilePath } = context,
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
let markdownStylesCSS = defaultCSS; ///
|
|
16
|
+
inputDirectoryPath = directoryPathFromFilePath(inputFilePath),
|
|
17
|
+
markdownStyleFilePaths = [];
|
|
20
18
|
|
|
21
19
|
readDirectory(inputDirectoryPath, (filePath) => {
|
|
22
20
|
const filePathMarkdownStyleFilePath = isFilePathMarkdownStyleFilePath(filePath);
|
|
23
21
|
|
|
24
22
|
if (filePathMarkdownStyleFilePath) {
|
|
25
|
-
const markdownStyleFilePath = filePath,
|
|
26
|
-
|
|
27
|
-
markdownStyle = markdownStyleFromMarkdownStyleFilePath(markdownStyleFilePath),
|
|
28
|
-
css = cssFromMarkdownStyleAndSelectorString(markdownStyle, selectorString, markdownStylesCSS); ///
|
|
23
|
+
const markdownStyleFilePath = filePath,
|
|
24
|
+
filePathDefaultMarkdownStyleFilePath = isFilePathDefaultMarkdownStyleFilePath(filePath);
|
|
29
25
|
|
|
30
|
-
|
|
26
|
+
filePathDefaultMarkdownStyleFilePath ?
|
|
27
|
+
markdownStyleFilePaths.unshift(markdownStyleFilePath) :
|
|
28
|
+
markdownStyleFilePaths.push(markdownStyleFilePath);
|
|
31
29
|
}
|
|
32
30
|
});
|
|
33
31
|
|
|
32
|
+
const defaultCSS = cssFromMarkdownStyleAndSelectorString(defaultMarkdownStyle, DEFAULT_SELECTOR_STRING);
|
|
33
|
+
|
|
34
|
+
let markdownStylesCSS = defaultCSS; ///
|
|
35
|
+
|
|
36
|
+
markdownStyleFilePaths.forEach((markdownStyleFilePath) => {
|
|
37
|
+
const selectorString = selectorStringFromMarkdownStyleFilePath(markdownStyleFilePath),
|
|
38
|
+
markdownStyle = markdownStyleFromMarkdownStyleFilePath(markdownStyleFilePath),
|
|
39
|
+
css = cssFromMarkdownStyleAndSelectorString(markdownStyle, selectorString, markdownStylesCSS); ///
|
|
40
|
+
|
|
41
|
+
markdownStylesCSS = `${markdownStylesCSS}${css}`;
|
|
42
|
+
});
|
|
43
|
+
|
|
34
44
|
Object.assign(context, {
|
|
35
45
|
markdownStylesCSS
|
|
36
46
|
});
|
|
@@ -50,9 +60,9 @@ function markdownStyleFromMarkdownStyleFilePath(markdownStyleFilePath) {
|
|
|
50
60
|
|
|
51
61
|
function selectorStringFromMarkdownStyleFilePath(markdownStyleFilePath) {
|
|
52
62
|
const filePath = markdownStyleFilePath, ///
|
|
53
|
-
|
|
54
|
-
selectorString = (
|
|
55
|
-
`div.${
|
|
63
|
+
className = classNameFromFilePath(filePath),
|
|
64
|
+
selectorString = (className !== null) ?
|
|
65
|
+
`div.${className}` :
|
|
56
66
|
`div`;
|
|
57
67
|
|
|
58
68
|
return selectorString;
|
|
@@ -8,19 +8,16 @@ const { second } = arrayUtilities,
|
|
|
8
8
|
{ isPathName, bottommostNameFromPath } = pathUtilities;
|
|
9
9
|
|
|
10
10
|
function classNameFromFilePath(filePath) {
|
|
11
|
-
let className = null;
|
|
12
|
-
|
|
13
11
|
const path = filePath,
|
|
14
12
|
pathName = isPathName(path),
|
|
15
13
|
name = pathName ?
|
|
16
14
|
path :
|
|
17
15
|
bottommostNameFromPath(path),
|
|
18
16
|
matches = name.match(/^([^.]+)\..+$/),
|
|
19
|
-
secondMatch = second(matches)
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
}
|
|
17
|
+
secondMatch = second(matches),
|
|
18
|
+
className = (secondMatch !== DEFAULT_DIVISION_IDENTIFIER) ?
|
|
19
|
+
secondMatch : ///
|
|
20
|
+
null;
|
|
24
21
|
|
|
25
22
|
return className;
|
|
26
23
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "highmark-cli",
|
|
3
3
|
"author": "James Smith",
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.116",
|
|
5
5
|
"license": "MIT, Anti-996",
|
|
6
6
|
"homepage": "https://github.com/djalbat/highmark-cli",
|
|
7
7
|
"description": "Extensible, styleable Markdown.",
|
|
@@ -13,8 +13,8 @@
|
|
|
13
13
|
"argumentative": "^2.0.28",
|
|
14
14
|
"express": "^4.19.2",
|
|
15
15
|
"highmark-fonts": "^1.0.36",
|
|
16
|
-
"highmark-markdown": "^0.0.
|
|
17
|
-
"highmark-markdown-style": "^0.0.
|
|
16
|
+
"highmark-markdown": "^0.0.199",
|
|
17
|
+
"highmark-markdown-style": "^0.0.213",
|
|
18
18
|
"lively-cli": "^2.0.55",
|
|
19
19
|
"necessary": "^13.6.1",
|
|
20
20
|
"occam-entities": "^1.0.90"
|