Comparing version 0.3.3 to 0.3.4
@@ -14,3 +14,4 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) { | ||
"return": C, "break": C, "continue": C, "new": C, "delete": C, "throw": C, | ||
"var": kw("var"), "function": kw("function"), "catch": kw("catch"), | ||
"var": kw("var"), "const": kw("var"), "let": kw("var"), | ||
"function": kw("function"), "catch": kw("catch"), | ||
"for": kw("for"), "switch": kw("switch"), "case": kw("case"), "default": kw("default"), | ||
@@ -90,3 +91,3 @@ "in": operator, "typeof": operator, "instanceof": operator, | ||
var word = stream.current(), known = keywords.propertyIsEnumerable(word) && keywords[word]; | ||
return known ? ret(known.type, known.style, word) : | ||
return (known && state.kwAllowed) ? ret(known.type, known.style, word) : | ||
ret("variable", "variable", word); | ||
@@ -233,3 +234,3 @@ } | ||
if (type == "function") return cont(functiondef); | ||
if (type == "keyword c") return cont(expression); | ||
if (type == "keyword c") return cont(maybeexpression); | ||
if (type == "(") return cont(pushlex(")"), expression, expect(")"), poplex, maybeoperator); | ||
@@ -241,2 +242,7 @@ if (type == "operator") return cont(expression); | ||
} | ||
function maybeexpression(type) { | ||
if (type.match(/[;\}\)\],]/)) return pass(); | ||
return pass(expression); | ||
} | ||
function maybeoperator(type, value) { | ||
@@ -317,2 +323,3 @@ if (type == "operator" && /\+\+|--/.test(value)) return cont(maybeoperator); | ||
reAllowed: true, | ||
kwAllowed: true, | ||
cc: [], | ||
@@ -336,2 +343,3 @@ lexical: new JSLexical((basecolumn || 0) - indentUnit, 0, "block", false), | ||
state.reAllowed = type == "operator" || type == "keyword c" || type.match(/^[\[{}\(,;:]$/); | ||
state.kwAllowed = type != '.'; | ||
return parseJS(state, style, type, content, stream); | ||
@@ -338,0 +346,0 @@ }, |
@@ -34,8 +34,5 @@ window.runDemo = function runDemo() { | ||
function watchHashChange() { | ||
window.setTimeout(watchHashChange, 750); | ||
if (hash !== location.hash.toString()) { | ||
hash = location.hash.toString(); | ||
updateSource(); | ||
} | ||
function handleHashChange(newHash) { | ||
hash = newHash; | ||
updateSource(); | ||
} | ||
@@ -81,3 +78,6 @@ | ||
// start monitor hash change | ||
watchHashChange(); | ||
hasher.prependHash = ''; | ||
hasher.changed.add(handleHashChange); | ||
hasher.initialized.add(handleHashChange); | ||
hasher.init(); | ||
}; | ||
@@ -84,0 +84,0 @@ |
@@ -0,1 +1,8 @@ | ||
0.3.4 / 2011-12-24 | ||
------------------ | ||
* Fixes str[] for oldIEs support. | ||
* Adds better has change support for browserified demo. | ||
* improves compact output of Error. Closes #33. | ||
0.3.3 / 2011-12-20 | ||
@@ -2,0 +9,0 @@ ------------------ |
@@ -65,3 +65,3 @@ 'use strict'; | ||
Mark.prototype.toString = function (compact) { | ||
Mark.prototype.toString = function () { | ||
var snippet = this.getSnippet(), where; | ||
@@ -73,3 +73,3 @@ | ||
if (snippet && !compact) { | ||
if (snippet) { | ||
where += ':\n' + snippet; | ||
@@ -89,2 +89,51 @@ } | ||
function toStringCompact(self) { | ||
var str = "Error "; | ||
if (null !== self.problemMark) { | ||
str += "on line " + (self.problemMark.line+1) + ", col " + (self.problemMark.column+1) + ": "; | ||
} | ||
if (null !== self.problem) { | ||
str += self.problem; | ||
} | ||
if (null !== self.note) { | ||
str += self.note; | ||
} | ||
return str; | ||
} | ||
function toStringFull(self) { | ||
var lines = []; | ||
if (null !== self.context) { | ||
lines.push(self.context); | ||
} | ||
if (null !== self.contextMark | ||
&& (null === self.problem || null === self.problemMark | ||
|| self.contextMark.name !== self.problemMark.name | ||
|| self.contextMark.line !== self.problemMark.line | ||
|| self.contextMark.column !== self.problemMark.column)) { | ||
lines.push(self.contextMark.toString()); | ||
} | ||
if (null !== self.problem) { | ||
lines.push(self.problem); | ||
} | ||
if (null !== self.problemMark) { | ||
lines.push(self.problemMark.toString()); | ||
} | ||
if (null !== self.note) { | ||
lines.push(self.note); | ||
} | ||
return lines.join('\n'); | ||
} | ||
function MarkedYAMLError(context, contextMark, problem, problemMark, note) { | ||
@@ -101,31 +150,3 @@ YAMLError.call(this); | ||
this.toString = function toString(compact) { | ||
var lines = []; | ||
if (!compact) { | ||
if (null !== this.context) { | ||
lines.push(this.context); | ||
} | ||
if (null !== this.contextMark | ||
&& (null === this.problem || null === this.problemMark | ||
|| this.contextMark.name !== this.problemMark.name | ||
|| this.contextMark.line !== this.problemMark.line | ||
|| this.contextMark.column !== this.problemMark.column)) { | ||
lines.push(this.contextMark.toString()); | ||
} | ||
} | ||
if (null !== this.problem) { | ||
lines.push(this.problem); | ||
} | ||
if (null !== this.problemMark) { | ||
lines.push(this.problemMark.toString(compact)); | ||
} | ||
if (null !== this.note) { | ||
lines.push(this.note); | ||
} | ||
return lines.join(compact ? ' ' : '\n'); | ||
return compact ? toStringCompact(this) : toStringFull(this); | ||
}; | ||
@@ -132,0 +153,0 @@ } |
@@ -13,2 +13,10 @@ 'use strict'; | ||
// IE 7-8 hack. As we use ONLY strings in browsers as input stream, there's no | ||
// need for stream.slice() call and we can simply use stream.charAt() when we | ||
// are running on that shit... | ||
var getSingleChar = (undefined === ('a')[0]) | ||
? function (str, pos) { return str.charAt(pos); } | ||
: function (str, pos) { return str[pos]; }; | ||
function ReaderError(name, position, character, encoding, reason) { | ||
@@ -66,7 +74,7 @@ _errors.YAMLError.apply(this); | ||
index = +index || 0; | ||
data = this.buffer[this.pointer + index]; | ||
data = getSingleChar(this.buffer, this.pointer + index); | ||
if (undefined === data) { | ||
this.update(index + 1); | ||
data = this.buffer[this.pointer + index]; | ||
data = getSingleChar(this.buffer, this.pointer + index); | ||
} | ||
@@ -73,0 +81,0 @@ |
{ | ||
"name" : "js-yaml", | ||
"version" : "0.3.3", | ||
"version" : "0.3.4", | ||
"description" : "YAML 1.1 Parser", | ||
@@ -9,2 +9,9 @@ "keywords" : ["yaml", "parser", "pyyaml"], | ||
"author" : "Aleksey V Zapparov <ixti@member.fsf.org> (http://www.ixti.net/)", | ||
"contributors" : [ | ||
{ | ||
"name" : "Martin Grenfell", | ||
"email" : "martin.grenfell@gmail.com>", | ||
"url" : "http://got-ravings.blogspot.com" | ||
} | ||
], | ||
@@ -11,0 +18,0 @@ "bugs" : { "url": "https://github.com/nodeca/js-yaml/issues" }, |
@@ -19,13 +19,6 @@ JS-YAML - YAML 1.1 parser for JavaScript | ||
If you want to inspect your YAML files from CLI, install [js-yaml.bin](https://github.com/nodeca/js-yaml.bin) | ||
and then you'll be able to call it like this: | ||
If you want to inspect your YAML files from CLI, | ||
install [js-yaml.bin](https://github.com/nodeca/js-yaml.bin). | ||
``` | ||
$ jsyaml /home/ixti/example.yml | ||
--------------------------------------------------------------------------- | ||
{ jsyaml: 'rocks!' } | ||
........................................................................... | ||
``` | ||
### bundled YAML library for browser | ||
@@ -160,10 +153,12 @@ | ||
Note, that if you use arrays as key in JS, it's automatically converted to string. | ||
So, if you have maps as key in YAML, result will flat: | ||
Note, that you use arrays or objects as key in JS-YAML. JS do not allows objects | ||
or array as keys, and stringifies them at the moment of adding them. | ||
``` yaml | ||
--- | ||
? - foo | ||
- bar | ||
? [ foo, bar ] | ||
: - baz | ||
? { foo: bar } | ||
: - baz | ||
- baz | ||
``` | ||
@@ -174,3 +169,3 @@ | ||
``` javascript | ||
{ "foo,bar": ["baz"] } | ||
{ "": ["baz"], "[object Object]": ["baz", "baz"] } | ||
``` | ||
@@ -177,0 +172,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
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
1103442
666
16285
173
44