Comparing version 3.5.3 to 3.6.0
@@ -20,7 +20,7 @@ "use strict"; | ||
const [start, end] = serialized.split("-"); | ||
const startPosition = start.split(",").map(n => parseInt(n, 10)); | ||
const endPosition = end.split(",").map(n => parseInt(n, 10)); | ||
const startPosition = start.split(",").map((n) => parseInt(n, 10)); | ||
const endPosition = end.split(",").map((n) => parseInt(n, 10)); | ||
return [ | ||
new ASTNodePoint({ row: startPosition[0], column: startPosition[1] }), | ||
new ASTNodePoint({ row: endPosition[0], column: endPosition[1] }) | ||
new ASTNodePoint({ row: endPosition[0], column: endPosition[1] }), | ||
]; | ||
@@ -30,2 +30,13 @@ } | ||
const [startPosition, endPosition] = range; | ||
const rangeSpansMultipleLines = startPosition.row !== endPosition.row; | ||
if (rangeSpansMultipleLines) { | ||
// If the node spans 3 lines or more, just check if point it's in the middle... | ||
if (point.row > startPosition.row && point.row < endPosition.row) { | ||
return true; | ||
} | ||
else if ((point.row === startPosition.row && point.column >= startPosition.column) || | ||
(point.row === endPosition.row && point.column < endPosition.column)) { | ||
return true; | ||
} | ||
} | ||
return (startPosition.row <= point.row && | ||
@@ -32,0 +43,0 @@ startPosition.column <= point.column && |
@@ -32,10 +32,20 @@ "use strict"; | ||
if (char === `\n`) { | ||
decoratedStrings.push(this.decorators.newLine()); | ||
wordInRange = ""; | ||
if (currentToken < nodes.length && nodes[currentToken].type === "\n") { | ||
currentToken += 1; | ||
if (inRange) { | ||
decoratedStrings.push(...this.decorateNode(wordInRange, nodes[currentToken], definitions)); | ||
decoratedStrings.push(this.decorators.newLine()); | ||
wordInRange = ""; | ||
row++; | ||
columnAtLine = 0; | ||
inRange = false; | ||
} | ||
inRange = false; | ||
row++; | ||
columnAtLine = 0; | ||
else { | ||
decoratedStrings.push(this.decorators.newLine()); | ||
wordInRange = ""; | ||
if (currentToken < nodes.length && nodes[currentToken].type === "\n") { | ||
currentToken += 1; | ||
} | ||
row++; | ||
columnAtLine = 0; | ||
inRange = false; | ||
} | ||
continue; | ||
@@ -50,3 +60,4 @@ } | ||
// if there's a token that spans till the end of the string | ||
if (column === source.length - 1 || columnAtLine === nodes[currentToken].endPosition.column - 1) { | ||
if (column === source.length - 1 || | ||
(columnAtLine === nodes[currentToken].endPosition.column - 1 && row === nodes[currentToken].endPosition.row)) { | ||
decoratedStrings.push(...this.decorateNode(wordInRange, nodes[currentToken], definitions)); | ||
@@ -58,9 +69,9 @@ wordInRange = ""; | ||
} | ||
else if (inRange) { | ||
decoratedStrings.push(...this.decorateNode(wordInRange, nodes[currentToken], definitions)); | ||
wordInRange = ""; | ||
currentToken += 1; | ||
inRange = false; | ||
} | ||
else { | ||
if (inRange) { | ||
decoratedStrings.push(...this.decorateNode(wordInRange, nodes[currentToken], definitions)); | ||
wordInRange = ""; | ||
currentToken += 1; | ||
inRange = false; | ||
} | ||
// if the current char is not part of any token, then append it to the array | ||
@@ -147,3 +158,3 @@ decoratedStrings.push(this.decorators.word(char)); | ||
case "{": | ||
case "${": | ||
case `\${`: | ||
case "}": | ||
@@ -218,2 +229,25 @@ return this.decorators.braces(text); | ||
return this.decorators.while(text, definition); | ||
///////////////////////////// | ||
// CSS | ||
//////////////////////////// | ||
case "property": { | ||
if (this.decorators.property) | ||
return this.decorators.property(text, definition); | ||
return this.decorators.word(text, definition); | ||
} | ||
case "class_name": { | ||
if (this.decorators.className) | ||
return this.decorators.className(text, definition); | ||
return this.decorators.word(text, definition); | ||
} | ||
case "*": { | ||
if (this.decorators.universalSelector) | ||
return this.decorators.universalSelector(text, definition); | ||
return this.decorators.word(text, definition); | ||
} | ||
case "tag_name": { | ||
if (this.decorators.tagName) | ||
return this.decorators.tagName(text, definition); | ||
return this.decorators.word(text, definition); | ||
} | ||
default: | ||
@@ -220,0 +254,0 @@ return this.decorators.word(text, definition); |
@@ -6,2 +6,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.Highlight = exports.ASTNodePoint = exports.TreeCursor = exports.Tree = exports.SubcommandNodeDefinition = exports.ProgramNodeDefinition = exports.OptionNodeDefinition = exports.OptionArgNodeDefinition = exports.ArgumentNodeDefinition = exports.ASTNode = void 0; | ||
const astNode_1 = __importDefault(require("./astNode")); | ||
@@ -18,7 +19,7 @@ exports.ASTNode = astNode_1.default; | ||
const nodeDefinition_1 = require("./nodeDefinition"); | ||
exports.ArgumentNodeDefinition = nodeDefinition_1.ArgumentNodeDefinition; | ||
exports.OptionArgNodeDefinition = nodeDefinition_1.OptionArgNodeDefinition; | ||
exports.OptionNodeDefinition = nodeDefinition_1.OptionNodeDefinition; | ||
exports.ProgramNodeDefinition = nodeDefinition_1.ProgramNodeDefinition; | ||
exports.SubcommandNodeDefinition = nodeDefinition_1.SubcommandNodeDefinition; | ||
Object.defineProperty(exports, "ArgumentNodeDefinition", { enumerable: true, get: function () { return nodeDefinition_1.ArgumentNodeDefinition; } }); | ||
Object.defineProperty(exports, "OptionArgNodeDefinition", { enumerable: true, get: function () { return nodeDefinition_1.OptionArgNodeDefinition; } }); | ||
Object.defineProperty(exports, "OptionNodeDefinition", { enumerable: true, get: function () { return nodeDefinition_1.OptionNodeDefinition; } }); | ||
Object.defineProperty(exports, "ProgramNodeDefinition", { enumerable: true, get: function () { return nodeDefinition_1.ProgramNodeDefinition; } }); | ||
Object.defineProperty(exports, "SubcommandNodeDefinition", { enumerable: true, get: function () { return nodeDefinition_1.SubcommandNodeDefinition; } }); | ||
//# sourceMappingURL=index.js.map |
@@ -46,2 +46,10 @@ import { ArgumentSchema, OptionSchema, ProgramSchema, SubcommandSchema } from "kmdr-parser"; | ||
brackets(text: string, node?: Node, definition?: NodeDefinition): T; | ||
/** | ||
* lang: css | ||
* A class Selector | ||
* @param text | ||
* @param node | ||
* @param definition | ||
*/ | ||
className?(text: string, node?: Node, definition?: NodeDefinition): T; | ||
command(text: string, node?: Node): T; | ||
@@ -74,8 +82,32 @@ comment(text: string, node?: Node, definition?: NodeDefinition): T; | ||
subcommand(text: string, node?: Node, definition?: NodeDefinition): T; | ||
/** | ||
* lang: css | ||
* A tag name selector | ||
* @param text | ||
* @param node | ||
* @param definition | ||
*/ | ||
tagName?(text: string, node?: Node, definition?: NodeDefinition): T; | ||
testOperator(text: string, node?: Node, definition?: NodeDefinition): T; | ||
then(text: string, node?: Node, definition?: NodeDefinition): T; | ||
/** | ||
* lang: css | ||
* A universal selector | ||
* @param text | ||
* @param node | ||
* @param definition | ||
*/ | ||
universalSelector?(text: string, node?: Node, definition?: Node): T; | ||
variableName(text: string, node?: Node, definition?: NodeDefinition): T; | ||
while(text: string, node?: Node, definition?: NodeDefinition): T; | ||
word(text: string, node?: Node, definition?: NodeDefinition): T; | ||
/** | ||
* lang: bash | ||
* A property name | ||
* @param text | ||
* @param node | ||
* @param definition | ||
*/ | ||
property?(text: string, node?: Node, definition?: NodeDefinition): T; | ||
} | ||
//# sourceMappingURL=interfaces.d.ts.map |
@@ -6,2 +6,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.SubcommandNodeDefinition = exports.ProgramNodeDefinition = exports.OptionNodeDefinition = exports.OptionArgNodeDefinition = exports.ArgumentNodeDefinition = void 0; | ||
const argumentNodeDefinition_1 = __importDefault(require("./argumentNodeDefinition")); | ||
@@ -8,0 +9,0 @@ exports.ArgumentNodeDefinition = argumentNodeDefinition_1.default; |
{ | ||
"name": "kmdr-ast", | ||
"version": "3.5.3", | ||
"version": "3.6.0", | ||
"description": "Traverse the AST of an explanation by kmdr", | ||
@@ -10,3 +10,3 @@ "main": "dist/index.js", | ||
"dependencies": { | ||
"@types/react": "^16.9.34", | ||
"@types/react": "^16.14.5", | ||
"kmdr-parser": "^2.6.1" | ||
@@ -16,11 +16,11 @@ }, | ||
"@types/jest": "^24.9.1", | ||
"@types/node": "^12.12.35", | ||
"@types/node": "^12.20.5", | ||
"create-html-element": "^3.0.0", | ||
"jest": "^24.9.0", | ||
"prettier": "^1.19.1", | ||
"ts-jest": "^24.3.0", | ||
"ts-jest": "^26.5.3", | ||
"tslint": "^5.20.1", | ||
"tslint-config-prettier": "^1.18.0", | ||
"tslint-config-standard": "^8.0.1", | ||
"typescript": "^3.8.3" | ||
"typescript": "^4.2.3" | ||
}, | ||
@@ -27,0 +27,0 @@ "scripts": { |
@@ -7,12 +7,18 @@ # kmdr-ast | ||
### Install Dependencies | ||
```bash | ||
npm install | ||
``` | ||
### Tests | ||
```bash | ||
npm run test | ||
``` | ||
yarn run test | ||
``` | ||
### Build | ||
```bash | ||
npm run build | ||
``` | ||
yarn run build | ||
``` |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
66519
60
810
24
Updated@types/react@^16.14.5