Comparing version 1.0.0 to 1.0.1
@@ -18,2 +18,45 @@ var request = require('request') | ||
// | ||
// ## parse `parse(options, callback)` | ||
// | ||
// Parses **options.text**, replacing all blocks delimited by **options.boundary** with their SVG counterparts. | ||
// | ||
// Returns the replaced version of **options.text**. | ||
// | ||
A2SRenderer.prototype.parse = parse | ||
function parse(options, callback) { | ||
var self = this | ||
, text = options.text | ||
, boundary = options.boundary | ||
, regex = new RegExp(boundary, 'g') | ||
, original = null | ||
, start | ||
, end | ||
function parseChunk(err, content) { | ||
if (err) { | ||
callback(err) | ||
return | ||
} | ||
if (original) { | ||
text = text.replace(original, content) | ||
} | ||
start = regex.exec(text) | ||
end = regex.exec(text) | ||
if (start && end) { | ||
original = text.slice(start.index, end.index + boundary.length) | ||
self.render({ | ||
text: text.slice(start.index + boundary.length, end.index) | ||
}, parseChunk) | ||
} else { | ||
callback(null, text) | ||
} | ||
} | ||
parseChunk() | ||
} | ||
// | ||
// ## render `render(options, callback)` | ||
@@ -20,0 +63,0 @@ // |
{ | ||
"name": "a2s", | ||
"version": "1.0.0", | ||
"version": "1.0.1", | ||
"description": "Provides a nice interface to a2saas.com, the asciitosvg web service.", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
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
9303
153