Comparing version 3.7.1 to 3.8.0
@@ -8,2 +8,8 @@ import { NodeDefinition, ThemeDecorators } from "./interfaces"; | ||
source(source: string, tree: Tree, definitions?: NodeDefinition[]): R[]; | ||
/** | ||
* Sometimes a single node contains multiple definitions. This function does that trick. | ||
* @param text | ||
* @param node | ||
* @param definitions | ||
*/ | ||
private decorateNode; | ||
@@ -10,0 +16,0 @@ private decorateText; |
@@ -34,11 +34,22 @@ "use strict"; | ||
// For CSS | ||
decoratedStrings.push(...this.decorateNode(wordInRange, nodes[currentToken], definitions)); | ||
decoratedStrings.push(this.decorateText("\n", "new_line")); | ||
wordInRange += char; | ||
if (wordInRange === nodes[currentToken].text) { | ||
decoratedStrings.push(...this.decorateNode(wordInRange, nodes[currentToken], definitions)); | ||
currentToken += 1; | ||
inRange = false; | ||
wordInRange = ""; | ||
} | ||
} | ||
else if (((_a = nodes[currentToken]) === null || _a === void 0 ? void 0 : _a.type) === "text" || ((_b = nodes[currentToken]) === null || _b === void 0 ? void 0 : _b.type) === "raw_text") { | ||
// For HTML | ||
decoratedStrings.push(this.decorateText("\n", "new_line")); | ||
if (currentToken < nodes.length || ((_c = nodes[currentToken]) === null || _c === void 0 ? void 0 : _c.text) === "\n") { | ||
if (((_c = nodes[currentToken]) === null || _c === void 0 ? void 0 : _c.text) === "\n") { | ||
decoratedStrings.push(this.decorateText("\n", "new_line")); | ||
currentToken += 1; | ||
wordInRange = ""; | ||
inRange = false; | ||
} | ||
else { | ||
wordInRange += char; | ||
inRange = true; | ||
} | ||
} | ||
@@ -50,7 +61,6 @@ else { | ||
} | ||
wordInRange = ""; | ||
} | ||
wordInRange = ""; | ||
row++; | ||
columnAtLine = 0; | ||
inRange = false; | ||
continue; | ||
@@ -96,2 +106,8 @@ } | ||
} | ||
/** | ||
* Sometimes a single node contains multiple definitions. This function does that trick. | ||
* @param text | ||
* @param node | ||
* @param definitions | ||
*/ | ||
decorateNode(text, node, definitions) { | ||
@@ -103,7 +119,4 @@ const decoratedStrings = []; | ||
let wordInRange = ""; | ||
let matches = []; | ||
if (definitions) { | ||
matches = Highlight.findNodeDefinition(node, definitions); | ||
} | ||
if (matches.length === 0) { | ||
const matches = definitions ? Highlight.findNodeDefinition(node, definitions) : []; | ||
if (matches.length === 0 && text.includes("\n") === false) { | ||
decoratedStrings.push(this.decorateText(text, node.type)); | ||
@@ -115,2 +128,6 @@ } | ||
const char = text[column]; | ||
if (char === "\n") { | ||
decoratedStrings.push(this.decorateText(char, "new_line")); | ||
continue; | ||
} | ||
// calculate the column position relative to the startPosition | ||
@@ -117,0 +134,0 @@ // of the node |
{ | ||
"name": "kmdr-ast", | ||
"version": "3.7.1", | ||
"version": "3.8.0", | ||
"description": "Traverse the AST of an explanation by kmdr", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
60866
763