fixes to quote macro...

Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
Alex A. Naanou 2022-05-02 17:18:31 +03:00
parent a47aa54587
commit a093281a37

View File

@ -934,7 +934,7 @@ object.Constructor('Page', BasePage, {
dummy: function(){}, dummy: function(){},
test: function(source){ test: function(source){
return source return source
.replace(/ test /g, ' TEST ') }, .replace(/test/g, 'TEST') },
wikiword: function(source){ wikiword: function(source){
// XXX // XXX
@ -1074,7 +1074,6 @@ object.Constructor('Page', BasePage, {
args, body, state, 'sources', args, body, state, 'sources',
function(){ function(){
return this.__parser__.parse(this, this.get(src).raw, state) }) }, return this.__parser__.parse(this, this.get(src).raw, state) }) },
// //
// @quote(<src>) // @quote(<src>)
// //
@ -1089,29 +1088,38 @@ object.Constructor('Page', BasePage, {
// //
// NOTE: src ant text arguments are mutually exclusive, src takes // NOTE: src ant text arguments are mutually exclusive, src takes
// priority. // priority.
// // XXX handle interactions with page filters....
quote: function(args, body, state){ quote: function(args, body, state){
var that = this var that = this
var src = args.src var src = args.src
?? args[0] ?? args[0]
var filters = args.filter var filters = args.filter
&& this.__parser__.normalizeFilters(
args.filter
.trim()
.split(/\\s+/g))
var text = args.text var text = args.text
?? body ?? body
?? [] ?? []
// source page... text = src ?
if(src){ // source page...
return filters ? this.get(src).raw
// body/arg...
: text.join('')
return text ?
(filters ?
// apply filters... // apply filters...
this.__parser__.normalizeFilters(filters) // XXX handle interactions with page filters....
filters
.reduce( .reduce(
function(res, filter){ function(res, filter){
return that.filters[filter].call(that, res) }, return that.filters[filter].call(that, res)
this.get(src).raw) ?? res },
: this.get(src).raw } text)
// body... : text)
if(text){ // empty...
return text.join('') } }, : '' },
// //
// <slot name=<name>/> // <slot name=<name>/>
// //