Compare commits

..

No commits in common. "9275d018990770e6977555e3146bea545c9b26af" and "85c3f644998e1a5c80de2ef46d454a453ee335d9" have entirely different histories.

View File

@ -9,10 +9,6 @@
var types = require('ig-types') var types = require('ig-types')
var pwpath = require('./path')
//--------------------------------------------------------------------- //---------------------------------------------------------------------
@ -347,9 +343,9 @@ module.BaseParser = {
yield str } yield str }
macro = true } } }, macro = true } } },
// NOTE: so as to avod cluterring the main parser flow the macros are // XXX move macros here from page.js...
// defined separtly below... macros: {
macros: undefined, },
// Group block elements (generator)... // Group block elements (generator)...
// //
@ -656,72 +652,9 @@ module.BaseParser = {
.join('') }, .join('') },
} }
// XXX do we need anything else like .doc, attrs???
// XXX might be a good idea to offload arg value parsing to here...
var Macro =
module.Macro =
function(spec, func){
var args = [...arguments]
// function...
func = args.pop()
// arg sepc...
;(args.length > 0
&& args[args.length-1] instanceof Array)
&& (func.arg_spec = args.pop())
return func }
var parser = var parser =
module.parser = { module.parser = {
__proto__: BaseParser, __proto__: BaseParser,
// list of macros that will get raw text of their content...
QUOTING_MACROS: ['quote'],
// XXX move macros here from page.js...
macros: {
//
// @(<name>[ <else>][ local])
// @(name=<name>[ else=<value>][ local])
//
// @arg(<name>[ <else>][ local])
// @arg(name=<name>[ else=<value>][ local])
//
// <arg <name>[ <else>][ local]/>
// <arg name=<name>[ else=<value>][ local]/>
//
// Resolution order:
// - local
// - .renderer
// - .root
//
// NOTE: else (default) value is parsed when accessed...
arg: Macro(
['name', 'else', ['local']],
function(args){
var v = this.args[args.name]
|| (!args.local
&& (this.renderer
&& this.renderer.args[args.name])
|| (this.root
&& this.root.args[args.name]))
v = v === true ?
args.name
: v
return v
|| (args['else']
&& this.parse(args['else'])) }),
'': Macro(
['name', 'else', ['local']],
function(args){
return this.macros.arg.call(this, args) }),
args: function(){
return pwpath.obj2args(this.args) },
// XXX
},
} }