diff --git a/pwiki2.js b/pwiki2.js index d2994fd..6a65ac4 100755 --- a/pwiki2.js +++ b/pwiki2.js @@ -492,18 +492,25 @@ object.Constructor('BasePage', { // XXX BUG? '' is parsed semi-wrong... var parser = module.parser = { + // XXX the pattern dance is getting a bit cumbersome, might be a + // good idea to move the thing out of the parser into the module + // root combine it there and reference the result from the parser + // letting the user to override it if necessary without + // overcomplicating things... // XXX update a-la MACRO_ARGS... MACRO_INLINE_ARGS: '[^)]*', // XXX need to update the arg pattern below too... MACRO_ARGS: ['(', // "arg" | 'arg' - // XXX add quote escaping?? + // XXX quote escaping??? + // XXX CHROME/NODE BUG: this does not work yet... + //'\\s+(?[\'"])[^\\k]*\\k', '\\s+"[^"]*"', "|\\s+'[^']*'", // arg '|\\s+[^\\s\\/>\'"]+', // arg='val' | arg="val" | arg=val - '|\\s+[a-z]+=(\'[^\']*\'|"[^"]*"|[^\\s"\']*)', + '|\\s+[a-z]+\\s*=\\s*(\'[^\']*\'|"[^"]*"|[^\\s"\']*)', ')*'].join(''), // patterns... // @@ -518,7 +525,7 @@ module.parser = { // | // XXX need to ignore ">" in quotes and "/" not before >... //'<\\s*(?MACROS)(?\\s+([^>/])*)?/?>', - '<\\s*(?MACROS)(?MACRO_ARGS)?/?>', + '<\\s*(?MACROS)(?MACRO_ARGS)?\\s*/?>', // 'MACROS)\\s*>', ].join('|'), 'smig'], @@ -533,14 +540,18 @@ module.parser = { .replace(/MACRO_INLINE_ARGS/g, this.MACRO_INLINE_ARGS) })`)).length-2) }, // XXX update using MACRO_ARGS... + MACRO_ARGS_PATTERN: RegExp('('+[ + ].join('|') +')', 'smig'), + /*/ MACRO_ARGS_PATTERN: RegExp('('+[ // named args... - '(?[a-zA-Z-_]+)\\s*=([\'"])(?([^\\3]|\\\\3)*)\\3\\s*', - '(?[a-zA-Z-_]+)\\s*=(?[^\\s]*)', + '(?[a-zA-Z-_]+)\\s*=\\s*([\'"])(?([^\\3]|\\\\3)*)\\3\\s*', + '(?[a-zA-Z-_]+)\\s*=\\s*(?[^\\s]*)', // positional args... '([\'"])(?([^\\8]|\\\\8)*)\\8', '(?[^\\s]+)', ].join('|') +')', 'smig'), + //*/ // XXX do we need basic inline and block commets a-la lisp??? COMMENT_PATTERN: RegExp('('+[ //