From 2d2345a589bbcf4b84624fd0d26bad887d9958c5 Mon Sep 17 00:00:00 2001 From: "Alex A. Naanou" Date: Fri, 3 Jul 2026 14:30:26 +0300 Subject: [PATCH] cleanup and fixes... Signed-off-by: Alex A. Naanou --- v3/pwiki/parser.js | 24 +++++++++++++++++++----- v3/pwiki/test/parser.js | 7 ++++++- 2 files changed, 25 insertions(+), 6 deletions(-) diff --git a/v3/pwiki/parser.js b/v3/pwiki/parser.js index 103e55f..9287e31 100644 --- a/v3/pwiki/parser.js +++ b/v3/pwiki/parser.js @@ -249,6 +249,7 @@ module.BaseParser = { // place join block between block elements... joinBlocks: function(page, blocks, join, state){ + var that = this if(typeof(blocks) == 'string' || join == null){ return blocks } @@ -256,10 +257,18 @@ module.BaseParser = { .map(function(block, i, l){ return [ block, - this.expand(page, join, state), + ...(i < l.length-1 ? + that.expand(page, join, state) + : []), ] }) .flat() }, + filterBlocks: function(page, blocks, filter, state){ + if(filter == null){ + return blocks } + // XXX + + return blocks }, // Strip comments... // @@ -1649,9 +1658,7 @@ module.parser = { // i.e. for @include(PATH) the paths within the included page // are resolved relative to PATH while for @source(PATH) // relative to the page containing the @source(..) statement... - // XXX UPDATE... source: Macro( - // XXX should this have the same args as include??? ['src', 'recursive', 'join', ['s', 'strict']], //['src'], @@ -1689,7 +1696,6 @@ module.parser = { function(src){ var text = src ? - // can be async... page.get(src).raw : body ? body @@ -1697,7 +1703,15 @@ module.parser = { return Promise.awaitOrRun( text, function(text){ - return that.joinBlocks(page, text, args.join, state) }) }) })), + return that.joinBlocks( + page, + that.filterBlocks( + page, + text, + args.filter, + state), + args.join, + state) }) }) })), // // @quote() diff --git a/v3/pwiki/test/parser.js b/v3/pwiki/test/parser.js index 14a87ff..224fc7c 100755 --- a/v3/pwiki/test/parser.js +++ b/v3/pwiki/test/parser.js @@ -17,7 +17,10 @@ module.exports.PAGES = { '/page': 'Page', '/async/page': Promise.resolve('Page'), '/includePage': '@include(/page)', - '/isolated': '@slot(slot original)' + '/isolated': '@slot(slot original)', + '/includeSelf': '@include(/includeSelf)', + '/async/includeSelf': Promise.resolve('@include(/includeSelf)'), + '/multi/page': [ 'A', 'B', 'C' ], } var P = @@ -218,6 +221,8 @@ test.Setups({ } }, // XXX recursion... // XXX + + // quote... })