highmark-cli 0.0.113 → 0.0.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/bin/importer.js CHANGED
@@ -1,27 +1,22 @@
1
1
  "use strict";
2
2
 
3
3
  const { readFile } = require("./utilities/fileSystem"),
4
- { divisionClassNameFromFilePath } = require("./utilities/division"),
4
+ { classNameFromFilePath } = require("./utilities/division"),
5
5
  { nodeFromTokens, tokensFromContent } = require("./utilities/markdown");
6
6
 
7
7
  function importer(filePath, context) {
8
8
  const content = readFile(filePath);
9
9
 
10
10
  if (content !== null) {
11
- const divisionClassName = divisionClassNameFromFilePath(filePath),
11
+ const className = classNameFromFilePath(filePath),
12
12
  tokens = tokensFromContent(content),
13
13
  node = nodeFromTokens(tokens);
14
14
 
15
15
  if (node !== null) {
16
- const importedNode = node, ///
17
- importedTokens = tokens, ///
18
- divisionMarkdownNode = node; ///
19
-
20
- divisionMarkdownNode.setDivisionClassName(divisionClassName);
21
-
22
16
  Object.assign(context, {
23
- importedNode,
24
- importedTokens
17
+ node,
18
+ tokens,
19
+ className
25
20
  });
26
21
  }
27
22
  }
@@ -2,21 +2,31 @@
2
2
 
3
3
  const importer = require("../importer");
4
4
 
5
- const { UNABLE_TO_CONVERT_MARKDOWN_TO_HTML_MESSAGE } = require("../messages");
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
- Object.assign(context, {
12
- importer
13
- });
15
+ if (content === null) {
16
+ const message = UNABLE_TO_CONVERT_MARKDOWN_TO_HTML_MESSAGE;
14
17
 
15
- importer(filePath, context);
18
+ console.log(message);
16
19
 
17
- const { importedNode = null, importedTokens = null } = context;
20
+ abort();
18
21
 
19
- if (importedNode === null) {
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
- delete context.importedNode;
30
- delete context.importedTokens;
39
+ Object.assign(context, {
40
+ tokens,
41
+ importer
42
+ });
31
43
 
32
- const node = importedNode, ///
33
- tokens = importedTokens, ///
34
- parentNode = null,
44
+ const parentNode = null,
45
+ divisionClassName = className, ///
35
46
  divisionMarkdownNode = node; ///
36
47
 
37
- Object.assign(context, {
38
- tokens
39
- });
48
+ divisionMarkdownNode.setDivisionClassName(divisionClassName);
40
49
 
41
50
  divisionMarkdownNode.resolveImports(parentNode, context);
42
51
 
@@ -3,10 +3,10 @@
3
3
  const { filePathUtilities } = require("occam-entities"),
4
4
  { cssUtilities, defaultMarkdownStyle } = require("highmark-markdown-style")
5
5
 
6
- const { readFile, readDirectory } = require("../utilities/fileSystem"),
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
11
  const { isFilePathMarkdownStyleFilePath } = filePathUtilities,
12
12
  { cssFromMarkdownStyleAndSelectorString } = cssUtilities;
@@ -50,9 +50,9 @@ function markdownStyleFromMarkdownStyleFilePath(markdownStyleFilePath) {
50
50
 
51
51
  function selectorStringFromMarkdownStyleFilePath(markdownStyleFilePath) {
52
52
  const filePath = markdownStyleFilePath, ///
53
- divisionClassName = divisionClassNameFromFilePath(filePath),
54
- selectorString = (divisionClassName !== null) ?
55
- `div.${divisionClassName}` :
53
+ className = classNameFromFilePath(filePath),
54
+ selectorString = (className !== null) ?
55
+ `div.${className}` :
56
56
  `div`;
57
57
 
58
58
  return selectorString;
@@ -7,24 +7,21 @@ const { DEFAULT_DIVISION_IDENTIFIER } = require("../constants");
7
7
  const { second } = arrayUtilities,
8
8
  { isPathName, bottommostNameFromPath } = pathUtilities;
9
9
 
10
- function divisionClassNameFromFilePath(filePath) {
11
- let divisionClassName = null;
12
-
10
+ function classNameFromFilePath(filePath) {
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
- if (secondMatch !== DEFAULT_DIVISION_IDENTIFIER) {
22
- divisionClassName = secondMatch; ///
23
- }
17
+ secondMatch = second(matches),
18
+ className = (secondMatch !== DEFAULT_DIVISION_IDENTIFIER) ?
19
+ secondMatch : ///
20
+ null;
24
21
 
25
- return divisionClassName;
22
+ return className;
26
23
  }
27
24
 
28
25
  module.exports = {
29
- divisionClassNameFromFilePath
26
+ classNameFromFilePath
30
27
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "highmark-cli",
3
3
  "author": "James Smith",
4
- "version": "0.0.113",
4
+ "version": "0.0.115",
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.188",
17
- "highmark-markdown-style": "^0.0.210",
16
+ "highmark-markdown": "^0.0.197",
17
+ "highmark-markdown-style": "^0.0.212",
18
18
  "lively-cli": "^2.0.55",
19
19
  "necessary": "^13.6.1",
20
20
  "occam-entities": "^1.0.90"