From 97fb6ee8564df5148dfb83fbb4d36427efb9fe0c Mon Sep 17 00:00:00 2001 From: "Alex A. Naanou" Date: Fri, 3 Jul 2026 19:29:04 +0300 Subject: [PATCH] added to @include(..) -- not yet sure if this is a good idea... Signed-off-by: Alex A. Naanou --- v3/pwiki/parser.js | 35 ++++++++++++++++++++++------------- v3/pwiki/test/parser.js | 11 ++++++++++- 2 files changed, 32 insertions(+), 14 deletions(-) diff --git a/v3/pwiki/parser.js b/v3/pwiki/parser.js index 89bcbf9..eff978e 100644 --- a/v3/pwiki/parser.js +++ b/v3/pwiki/parser.js @@ -1456,9 +1456,13 @@ module.parser = { // @include(src= isolated recursive=) // // .. > - // + // ... + // + // ... // // + // NOTE: if body is not empty and is not present, the + // included page will not be placed. // NOTE: there can be two ways of recursion in pWiki: // - flat recursion // /A -> /A -> /A -> .. @@ -1473,15 +1477,12 @@ module.parser = { // not 100% correct manner focusing on path depth and ignoring // the context, this potentially can lead to false positives. // - // XXX might be a good idea to add a tag to place the - // loaded text... + // XXX do we need the nested macro??? + // XXX should this resolve join and/or body in the context of the + // included page or the outer page (current)??? // XXX add path recursion test to data -- fail if two paths resolve // to the same context... // XXX need a way to make encode option transparent... - // XXX need a way to wrap the included page... - // - template page... - // - prefix/sufix... - // XXX store a page cache in state... // XXX do we want to load a specific slot/block??? // XXX UPDATE... include: Macro( @@ -1565,13 +1566,21 @@ module.parser = { var pageHandler = function(text){ - // XXX NOTE: if body set and contains to macro - // then the included value will not be displayed... + var content_handled = false return body ? - that.expand(page, body, state, - { content: function(){ - handler_called = true - return text = handler.call(that, page, text, state) } }) + // handle body / ... + Promise.awaitOrRun( + that.expand(page, body, state, + { content: function(){ + content_handled = true + return text = handler.call(that, page, text, state) } }), + function(text){ + // if no present we still + // need to handle the included page... + content_handled + || handler.call(that, page, text, state) + return text }) + // place as-is... : handler.call(that, page, text, state) } var resultHandler = function(pages){ diff --git a/v3/pwiki/test/parser.js b/v3/pwiki/test/parser.js index fdbf931..6d60ae9 100755 --- a/v3/pwiki/test/parser.js +++ b/v3/pwiki/test/parser.js @@ -225,8 +225,17 @@ test.Setups({ 'original overloaded', ], } }, + // content... + include_content: function(assert){ + return { + page: P, + code: [ + '[[ ]]', + '[[ '+ P.get('/page').raw +' ]]', ], } }, + // XXX + // recursion... - // XXX test path recursion: /A -> /A/A -> /A/A/A -> ... + // XXX handle test path recursion: /A -> /A/A -> /A/A/A -> ... include_recursive_a: function(assert){ return { page: P,