Permalink
Browse files

Added tag literal as options parameter

  • Loading branch information...
1 parent 18a992a commit 7858a65db7e73f922cfa97b2bb16742b9e70fbb3 Peter van der Zee committed Mar 28, 2012
Showing with 9 additions and 5 deletions.
  1. +4 −2 Tokenizer.js
  2. +5 −3 ZeParser.js
View
6 Tokenizer.js
@@ -10,8 +10,10 @@ if (typeof exports !== 'undefined') {
/**
* @param {Object} inp
+ * @param {Object} options
+ * @property {boolean} [options.tagLiterals] Instructs the tokenizer to also parse tag literals
*/
-function Tokenizer(inp){
+function Tokenizer(inp, options){
this.inp = inp||'';
// replace all other line terminators with \n (leave \r\n in tact though). we should probably remove the shadowInp when finished...
// only replace \r if it is not followed by a \n else \r\n would become \n\n causing a double newline where it is just a single
@@ -63,7 +65,7 @@ function Tokenizer(inp){
this.errorEscape = null;
// support tag literals
- this.tagLiterals = false;
+ this.tagLiterals = false || (options && options.tagLiterals);
};
Tokenizer.prototype = {
View
8 ZeParser.js
@@ -67,13 +67,15 @@ ZeParser.parse = function(input, simple){
/**
* Returns a new parser instance with parse details for input
* @param {string} input
+ * @param {Object} options
+ * @property {boolean} [options.tagLiterals] Instructs the tokenizer to also parse tag literals
* @returns {ZeParser}
*/
-ZeParser.createParser = function(input){
- var tok = new Tokenizer(input);
+ZeParser.createParser = function(input, options){
+ var tok = new Tokenizer(input, options);
var stack = [];
try {
- var parser = new ZeParser(input, tok, stack);
+ var parser = new ZeParser(input, tok, stack, options);
parser.parse();
return parser;
} catch (e) {

0 comments on commit 7858a65

Please sign in to comment.