Comparing version 0.0.1 to 0.1.0
@@ -28,4 +28,2 @@ "use strict"; | ||
this.blockSrc = 0; | ||
this.options = utils.merge(defaults.options, options); | ||
@@ -87,3 +85,2 @@ | ||
walk.skipBlankLines(); | ||
this.blockSrc = walk.absoluteIndex(walk.position); | ||
this.countBlockIndent(walk); | ||
@@ -189,5 +186,2 @@ if (this.tryUnorderedList(walk)) return; | ||
} | ||
// emit data-src | ||
if (this.options.sourceIndices) | ||
this.out.push(" data-src=\"" + this.blockSrc + "\""); | ||
}, | ||
@@ -482,3 +476,3 @@ | ||
tryHrTable: function(walk) { | ||
if (!walk.at("---")) return; | ||
if (!walk.at("---")) return false; | ||
var startIdx = walk.position; | ||
@@ -490,2 +484,3 @@ walk.scrollToTerm(); | ||
else this.emitTable(b); | ||
return true; | ||
}, | ||
@@ -628,6 +623,7 @@ | ||
var blockTags = ["address", "article", "aside", "blockqoute", "canvas", | ||
var blockTags = ["address", "article", "aside", "blockquote", "canvas", | ||
"dd", "div", "dl", "dt", "fieldset", "figcaption", "figure", "footer", | ||
"form", "h1", "h2", "h3", "h4", "h5", "h6", "header", "hgroup", "hr", | ||
"nospript", "ol", "output", "p", "pre", "section", "table", "ul"]; | ||
"noscript", "ol", "output", "p", "pre", "section", "table", "ul", | ||
"style", "script"]; | ||
@@ -634,0 +630,0 @@ var htmlTagRe = /^<\/?([a-zA-Z]+)\b[\s\S]*?(\/)?>$/; |
@@ -13,6 +13,10 @@ "use strict"; | ||
sourceIndices: false, | ||
stripInvalidXmlChars: true, | ||
stripInvalidXmlChars: true | ||
typographics: true, | ||
"typo.ldquo": "“", | ||
"typo.rdquo": "”" | ||
}; |
@@ -78,2 +78,4 @@ "use strict"; | ||
* code — only backslash escapes and HTML chars are processed; | ||
* plain — only ampersand-escapes are processed. | ||
*/ | ||
@@ -84,2 +86,5 @@ emitNormal: function(walk) { | ||
if (this.tryBackslashEscape(walk)) return; | ||
// Typographics | ||
if (this.options.typographics && this.tryTypographics(walk)) | ||
return; | ||
// HTML chars | ||
@@ -133,2 +138,47 @@ if (this.tryAmp(walk)) return; | ||
tryTypographics: function(walk) { | ||
if (walk.at("--")) { | ||
walk.skip(2); | ||
this.out.push("—"); | ||
return true; | ||
} else if (walk.at("(c)") || walk.at("(C)")) { | ||
walk.skip(3); | ||
this.out.push("©"); | ||
return true; | ||
} else if (walk.at("(r)") || walk.at("(R)")) { | ||
walk.skip(3); | ||
this.out.push("®"); | ||
return true; | ||
} else if (walk.at("(tm)") || walk.at("(TM)")) { | ||
walk.skip(4); | ||
this.out.push("™"); | ||
return true; | ||
} else if (walk.at("<-")) { | ||
walk.skip(2); | ||
this.out.push("←"); | ||
return true; | ||
} else if (walk.at("<-")) { | ||
walk.skip(5); | ||
this.out.push("←"); | ||
return true; | ||
} else if (walk.at("->")) { | ||
walk.skip(2); | ||
this.out.push("→"); | ||
return true; | ||
} else if (walk.at("->")) { | ||
walk.skip(5); | ||
this.out.push("→"); | ||
return true; | ||
} else if (walk.at("\"")) { | ||
walk.skip(); | ||
var lastToken = this.out[this.out.length - 1] || ""; | ||
var lastChar = lastToken[lastToken.length - 1] || ""; | ||
if (lastChar.trim() == "") | ||
this.out.push(this.options['typo.ldquo']); | ||
else this.out.push(this.options['typo.rdquo']); | ||
return true; | ||
} | ||
return false; | ||
}, | ||
/* Ampersands should distinguish entity references. */ | ||
@@ -135,0 +185,0 @@ |
@@ -53,10 +53,2 @@ "use strict"; | ||
/* ## Absolute index resolution */ | ||
// resolves an index corresponding to `relative` from | ||
// underlying `source` | ||
absoluteIndex: function(relative) { | ||
return relative; | ||
}, | ||
/* ## Subregioning and exclusion | ||
@@ -153,4 +145,5 @@ | ||
found = c == "" || c == "\\" || c == "&" || c == "<" || | ||
c == ">" || c == "`" || c == "$" || c == '%' || c == '_' || | ||
c == '*' || c == "!" || c == "["; | ||
c == ">" || c == "`" || c == "$" || c == '%' || c == "_" || | ||
c == "*" || c == "!" || c == "[" || c == "(" || c == "{" || | ||
c == "-" || c == "\""; | ||
if (!found) | ||
@@ -379,9 +372,2 @@ this.skip(); | ||
SubWalker.prototype.absoluteIndex = function(relative) { | ||
var idx = this.start + relative; | ||
if (typeof(this.source.absoluteIndex) == "function") | ||
return this.source.absoluteIndex(idx); | ||
else return idx; | ||
}; | ||
SubWalker.prototype.charAt = function(i) { | ||
@@ -432,17 +418,2 @@ if (i >= this.length) | ||
MultiWalker.prototype.absoluteIndex = function(relative) { | ||
if (this.regions.length == 0) | ||
return -1; | ||
var i = 0; | ||
var idx = relative; | ||
while (idx >= this.regions[i].length) { | ||
idx -= this.regions[i].length; | ||
i += 1; | ||
} | ||
var r = this.regions[i]; | ||
if (typeof(r.absoluteIndex) == "function") | ||
return r.absoluteIndex(idx); | ||
else return idx; | ||
}; | ||
MultiWalker.prototype.charAt = function(idx) { | ||
@@ -449,0 +420,0 @@ return this.string.charAt(idx); |
@@ -5,3 +5,3 @@ { | ||
"version": "0.0.1", | ||
"version": "0.1.0", | ||
@@ -23,3 +23,3 @@ "description": "Easy-to-{read,write,understand} semantic plain text markup language for Node", | ||
"name": "Andrey Semenov", | ||
"email": "" | ||
"email": "semenow.andrew@gmail.com" | ||
} | ||
@@ -26,0 +26,0 @@ ], |
@@ -1,4 +0,4 @@ | ||
# Rho semantic markup language for Node | ||
# Rho — semantic markup language for Node | ||
Rho is easy-to-{read,write,understand} semantic plain text markup language for Node. | ||
Rho is easy-to-{read,write,understand} semantic markup language for Node. | ||
@@ -19,4 +19,12 @@ Rho *is not Markdown*, although it takes a lot of ideas from modern | ||
which can use data sources for resolving `[reference-style links][id]` and | ||
`![reference-style images][id]`. | ||
`![reference-style images][id]`; | ||
* reduced feature set: no blockquotes, no reference-style links in document, | ||
no whitespace-indented code blocks, no variations in list markers and | ||
heading styles, no line breaks syntax. | ||
## Syntax | ||
Please check out the [Rho Syntax Reference](https://github.com/inca/rho/blob/master/SYNTAX.md). | ||
## Installing | ||
@@ -49,3 +57,3 @@ | ||
With large documents in concurrent environment (e.g. in a web application) | ||
With large documents in a concurrent environment (e.g. in a web application) | ||
it might be a good idea to stick with asynchronous rendering: | ||
@@ -59,3 +67,3 @@ | ||
In asynchronous mode each block-level element is emitted at every tick. | ||
In asynchronous mode each block-level element is emitted every tick. | ||
@@ -86,6 +94,8 @@ ### Inline rendering | ||
[ ] common typographic enhancements | ||
[+] common typographic enhancements | ||
[ ] support for macros | ||
[ ] browser version | ||
## License | ||
@@ -92,0 +102,0 @@ |
@@ -42,7 +42,2 @@ "use strict"; | ||
it('should evaluate proper #absoluteIndex', function() { | ||
assert.equal(w.absoluteIndex(29), 10); | ||
assert.equal(w.absoluteIndex(10), 16); | ||
}); | ||
}); | ||
@@ -49,0 +44,0 @@ |
@@ -49,6 +49,2 @@ "use strict"; | ||
it('should evaluate proper #absoluteIndex', function() { | ||
assert.equal(w3.absoluteIndex(2), 12); | ||
}); | ||
}); | ||
@@ -55,0 +51,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
225711
56
2057
117