mirror of
https://github.com/flynx/pWiki.git
synced 2026-07-13 20:10:57 +00:00
cleanup + refactoring...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
parent
46d768e4e1
commit
dd1ac686f3
@ -247,6 +247,19 @@ module.BaseParser = {
|
|||||||
?? args.text }
|
?? args.text }
|
||||||
return macro.call(this, page, args, body, state, ...rest) },
|
return macro.call(this, page, args, body, state, ...rest) },
|
||||||
|
|
||||||
|
// place join block between block elements...
|
||||||
|
joinBlocks: function(page, blocks, join, state){
|
||||||
|
if(typeof(blocks) == 'string'
|
||||||
|
|| join == null){
|
||||||
|
return blocks }
|
||||||
|
return blocks
|
||||||
|
.map(function(block, i, l){
|
||||||
|
return [
|
||||||
|
block,
|
||||||
|
this.expand(page, join, state),
|
||||||
|
] })
|
||||||
|
.flat() },
|
||||||
|
|
||||||
|
|
||||||
// Strip comments...
|
// Strip comments...
|
||||||
//
|
//
|
||||||
@ -1128,6 +1141,10 @@ function(macro){
|
|||||||
return macro }
|
return macro }
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// XXX RENAME...
|
// XXX RENAME...
|
||||||
// ...this is more of an expander/executer...
|
// ...this is more of an expander/executer...
|
||||||
// ...might be a good idea to also do a check without executing...
|
// ...might be a good idea to also do a check without executing...
|
||||||
@ -1590,16 +1607,6 @@ module.parser = {
|
|||||||
: {})
|
: {})
|
||||||
: this.expand(page, text, state)}
|
: this.expand(page, text, state)}
|
||||||
|
|
||||||
var pageHandler =
|
|
||||||
function(text, i, l){
|
|
||||||
return [
|
|
||||||
handler.call(that, page, text, state),
|
|
||||||
// join...
|
|
||||||
(args.join
|
|
||||||
&& i < l.length - 1) ?
|
|
||||||
that.expand(page, args.join, state)
|
|
||||||
: [],
|
|
||||||
].flat() }
|
|
||||||
var resultHandler =
|
var resultHandler =
|
||||||
function(pages){
|
function(pages){
|
||||||
// XXX not sure if this can happen or why...
|
// XXX not sure if this can happen or why...
|
||||||
@ -1624,8 +1631,13 @@ module.parser = {
|
|||||||
return Promise.awaitOrRun(
|
return Promise.awaitOrRun(
|
||||||
// handle pages...
|
// handle pages...
|
||||||
Promise
|
Promise
|
||||||
.iter(pages
|
.iter(
|
||||||
.map( pageHandler ))
|
that.joinBlocks(
|
||||||
|
page,
|
||||||
|
pages.map(function(text){
|
||||||
|
return handler.call(that, page, text, state) }),
|
||||||
|
args.join,
|
||||||
|
state))
|
||||||
.flat()
|
.flat()
|
||||||
.sync(),
|
.sync(),
|
||||||
resultHandler ) }) }) })),
|
resultHandler ) }) }) })),
|
||||||
@ -1685,13 +1697,7 @@ module.parser = {
|
|||||||
return Promise.awaitOrRun(
|
return Promise.awaitOrRun(
|
||||||
text,
|
text,
|
||||||
function(text){
|
function(text){
|
||||||
// filter...
|
return that.joinBlocks(page, text, args.join, state) }) }) })),
|
||||||
if(args.filter){
|
|
||||||
// XXX
|
|
||||||
}
|
|
||||||
// XXX join...
|
|
||||||
// XXX
|
|
||||||
return text }) }) })),
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// @quote(<src>)
|
// @quote(<src>)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user