Comparing version 0.0.5 to 0.0.6
{ | ||
"name": "cbml", | ||
"version": "0.0.5", | ||
"version": "0.0.6", | ||
"description": "CBML Parser", | ||
@@ -5,0 +5,0 @@ "homepage": "https://github.com/cbml/cbmljs", |
@@ -5,3 +5,24 @@ # [![NPM version][npm-image]][npm-url] [![Build Status][travis-image]][travis-url] | ||
## Struct | ||
```json | ||
{ | ||
"type": "block", // token type : "text" | "block" | "single" | ||
"pos": 7, // Starting position | ||
"endpos": 333, // End position | ||
"value": "/*<jdists>*/.../*</jdists>*/", // All value // as "{{prefix}}" + "{{content}}" + "{{suffix}}" | ||
"tag": "jdists", // tag name | ||
"language": "c", // language : "c" | "pascal" | "python" | "lua" | ||
"attrs": {}, | ||
"line": 1, // Line Numbers | ||
"col": 8 // Column number | ||
"nodes": [ | ||
... | ||
], | ||
"content": "...", | ||
"prefix": "/*<jdists>*/", | ||
"suffix": "/*</jdists>*/" | ||
} | ||
``` | ||
## Install | ||
@@ -8,0 +29,0 @@ |
@@ -147,3 +147,4 @@ (function (exportName) { | ||
pushToken('commentRight', S.pos, S.pos + offset, { | ||
pushToken('right', S.pos, S.pos + offset, { | ||
comment: true, | ||
tag: tag, | ||
@@ -260,5 +261,6 @@ language: language | ||
if (match[1] === '>') { // 需要闭合 // 《!--/jdists》...《/jdists--》」 | ||
pushToken('commentLeft', | ||
pushToken('left', | ||
S.pos, | ||
S.pos + offset, { | ||
comment: true, | ||
tag: tag, | ||
@@ -326,5 +328,3 @@ language: language, | ||
//</debug>*/ | ||
var lefts = []; | ||
var commentLefts = []; | ||
var items = []; | ||
var lefts = []; // 左边标签集合,用于寻找配对的右边标签 | ||
tokens.forEach(function (token) { | ||
@@ -340,27 +340,15 @@ switch (token.type) { | ||
break; | ||
case 'commentLeft': | ||
case 'left': | ||
if (token.type === 'left') { | ||
items = lefts; | ||
} | ||
else { | ||
items = commentLefts; | ||
} | ||
token.nodes = []; | ||
items.push(token); | ||
lefts.push(token); | ||
current.nodes.push(token); | ||
current = token; | ||
break; | ||
case 'commentRight': | ||
case 'right': | ||
if (token.type === 'right') { | ||
items = lefts; | ||
} | ||
else { | ||
items = commentLefts; | ||
} | ||
for (var i = items.length - 1; i >= 0; i--) { | ||
var curr = items[i]; | ||
var prev = items[i - 1]; | ||
if (curr.tag === token.tag && curr.language === token.language) { | ||
for (var i = lefts.length - 1; i >= 0; i--) { | ||
var curr = lefts[i]; | ||
var prev = lefts[i - 1]; | ||
if (curr.tag === token.tag && | ||
curr.language === token.language && | ||
curr.comment === token.comment) { | ||
curr.type = 'block'; | ||
@@ -389,3 +377,3 @@ | ||
items = items.slice(0, i); | ||
lefts = lefts.slice(0, i); | ||
break; | ||
@@ -406,8 +394,2 @@ } | ||
} | ||
if (token.type === 'right') { | ||
lefts = items; | ||
} | ||
else { | ||
commentLefts = items; | ||
} | ||
break; | ||
@@ -414,0 +396,0 @@ } |
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
13388
54
422