diff --git a/pwiki/page.js b/pwiki/page.js index 5595d8e..0698231 100755 --- a/pwiki/page.js +++ b/pwiki/page.js @@ -780,6 +780,7 @@ object.Constructor('Page', BasePage, { // NOTE: the filter argument has the same semantics as the filter // macro with one exception, when used in quote, the body is // not expanded... + // NOTE: the filter argument uses the same filters as @filter(..) // // XXX need a way to escape macros -- i.e. include in a quoted text... quote: Macro( @@ -817,19 +818,19 @@ object.Constructor('Page', BasePage, { // NOTE: since the body of quote(..) only has filters applied // to it doing the first stage of .filter(..) as late // as the second stage here will have no ill effect... - return function(state){ + // NOTE: this uses the same filters as @filter(..) + return async function(state){ // add global quote-filters... filters = (state.quote_filters && !(filters ?? []).includes(this.ISOLATED_FILTERS)) ? [...state.quote_filters, ...(filters ?? [])] : filters - if(filters){ - filters = Object.fromEntries(Object.entries(filters)) - return this.macros.filter - .call(this, filters, text, state, false) - .call(this, state) } - return text } }), + return filters ? + await this.__parser__.callMacro( + this, 'filter', filters, text, state, false) + .call(this, state) + : text } }), // very similar to @filter(..) but will affect @quote(..) filters... 'quote-filter': function(args, body, state){ var filters = state.quote_filters = diff --git a/pwiki/parser.js b/pwiki/parser.js index 5587c4b..7aa6e7b 100755 --- a/pwiki/parser.js +++ b/pwiki/parser.js @@ -148,8 +148,7 @@ module.BaseParser = { // NOTE: arg pre-parsing is dome by .lex(..) but at that stage we do not // yet touch the actual macros (we need them to get the .arg_spec) // so the actual parsing is done in .expand(..) - parseArgs: function(spec, args, state){ - var that = this + parseArgs: function(spec, args){ // spec... var order = spec.slice() var bools = new Set( @@ -179,6 +178,16 @@ module.BaseParser = { (res[e] = true) : (res[order.shift()] = e) }) return res }, + // XXX should this be here or on page??? + callMacro: function(page, name, args, body, state, ...rest){ + return page.macros[name].call(page, + this.parseArgs( + page.macros[name].arg_spec + ?? [], + args), + body, + state, + ...rest) }, // Strip comments... @@ -415,16 +424,11 @@ module.BaseParser = { // nested macro -- skip... if(typeof(page.macros[name]) != 'function'){ continue } - // args... - args = this.parseArgs.call(page, - page.macros[name].arg_spec - ?? [], - args, - state) - // call... + var res = - await page.macros[name].call(page, args, body, state, value) + await this.callMacro(page, name, args, body, state) ?? '' + // result... if(res instanceof Array || page.macros[name] instanceof types.Generator){