highmark-cli 0.0.68 → 0.0.69

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.
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
 
3
3
  const readInputFileOperation = require("../operation/readInputFile"),
4
- inputFileContentToHTMLOperation = require("../operation/inputFileContentToHTML");
4
+ inputFileToHTMLOperation = require("../operation/inputFileToHTML");
5
5
 
6
6
  const { executeOperations } = require("../utilities/operation"),
7
7
  { SUCCESSFUL_PUBLISH_MESSAGE, FAILED_PUBLISH_MESSAGE } = require("../messages");
@@ -9,7 +9,7 @@ const { executeOperations } = require("../utilities/operation"),
9
9
  function publishAction(inputFilePath, outputFilePath) {
10
10
  const operations = [
11
11
  readInputFileOperation,
12
- inputFileContentToHTMLOperation
12
+ inputFileToHTMLOperation
13
13
  ],
14
14
  context = {
15
15
  inputFilePath,
package/bin/importer.js CHANGED
@@ -1,10 +1,28 @@
1
1
  "use strict";
2
2
 
3
3
  const { readFile } = require("./utilities/file");
4
- const { nodeFromContent } = require("./utilities/markdown");
4
+ const { nodeFromTokens, tokensFromContent } = require("./utilities/markdown");
5
5
 
6
- function importer(path, indent, context) {
7
- debugger
6
+ function importer(filePath, indent, context) {
7
+ let html = null;
8
+
9
+ const content = readFile(filePath);
10
+
11
+ if (content !== null) {
12
+ const tokens = tokensFromContent(content),
13
+ node = nodeFromTokens(tokens);
14
+
15
+ let { indent } = context;
16
+
17
+ if (node !== null) {
18
+ html = node.asHTML({
19
+ tokens,
20
+ importer
21
+ });
22
+ }
23
+ }
24
+
25
+ return html;
8
26
  }
9
27
 
10
28
  module.exports = importer;
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+
3
+ const importer = require("../importer");
4
+
5
+ const { nodeFromTokens, tokensFromContent } = require("../utilities/markdown");
6
+
7
+ function inputFileHTMLOperation(proceed, abort, context) {
8
+ const { inputFileContent } = context,
9
+ content = inputFileContent, ///
10
+ tokens = tokensFromContent(content),
11
+ node = nodeFromTokens(tokens);
12
+
13
+ if (node === null) {
14
+ abort();
15
+
16
+ return;
17
+ }
18
+
19
+ const html = node.asHTML({ ///
20
+ tokens,
21
+ importer
22
+ }),
23
+ inputFileHTML = html; ///
24
+
25
+ Object.assign(context, {
26
+ inputFileHTML
27
+ });
28
+
29
+ proceed();
30
+ }
31
+
32
+ module.exports = inputFileHTMLOperation;
@@ -7,9 +7,14 @@ const { UNABLE_TO_PARSE_INPUT_FILE_MESSAGE } = require("../messages");
7
7
  const markdownLexer = MarkdownLexer.fromNothing(),
8
8
  markdownParser = MarkdownParser.fromNothing();
9
9
 
10
- function nodeFromContent(content) {
11
- const tokens = markdownLexer.tokenise(content),
12
- node = markdownParser.parse(tokens);
10
+ function tokensFromContent(content) {
11
+ const tokens = markdownLexer.tokenise(content);
12
+
13
+ return tokens;
14
+ }
15
+
16
+ function nodeFromTokens(tokens) {
17
+ const node = markdownParser.parse(tokens);
13
18
 
14
19
  if (node === null) {
15
20
  const message = UNABLE_TO_PARSE_INPUT_FILE_MESSAGE;
@@ -21,5 +26,6 @@ function nodeFromContent(content) {
21
26
  }
22
27
 
23
28
  module.exports = {
24
- nodeFromContent
29
+ tokensFromContent,
30
+ nodeFromTokens
25
31
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "highmark-cli",
3
3
  "author": "James Smith",
4
- "version": "0.0.68",
4
+ "version": "0.0.69",
5
5
  "license": "MIT, Anti-996",
6
6
  "homepage": "https://github.com/djalbat/highmark-cli",
7
7
  "description": "Extensible, styleable Markdown.",
@@ -11,8 +11,8 @@
11
11
  },
12
12
  "dependencies": {
13
13
  "argumentative": "^2.0.28",
14
- "highmark-markdown": "^0.0.114",
15
- "highmark-markdown-style": "^0.0.153",
14
+ "highmark-markdown": "^0.0.117",
15
+ "highmark-markdown-style": "^0.0.154",
16
16
  "necessary": "^13.4.2"
17
17
  },
18
18
  "scripts": {},
@@ -1,29 +0,0 @@
1
- "use strict";
2
-
3
- const importer = require("../importer");
4
-
5
- const { nodeFromContent } = require("../utilities/markdown");
6
-
7
- function inputFileContentToHTMLOperation(proceed, abort, context) {
8
- const { inputFileContent } = context,
9
- content = inputFileContent, ///
10
- node = nodeFromContent(content);
11
-
12
- if (node === null) {
13
- abort();
14
-
15
- return;
16
- }
17
-
18
- const html = node.asHTML({ ///
19
- importer
20
- });
21
-
22
- Object.assign(context, {
23
- html
24
- });
25
-
26
- proceed();
27
- }
28
-
29
- module.exports = inputFileContentToHTMLOperation;