mirror of
https://github.com/flynx/pWiki.git
synced 2025-10-29 10:00:08 +00:00
bugfix: no pattern macros do not falsly detect recursion...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
parent
2c8f0bd59e
commit
8e3ed10a9d
16
pwiki2.js
16
pwiki2.js
@ -21,9 +21,7 @@
|
|||||||
* - an async REPL???
|
* - an async REPL???
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
* XXX BUG: macro is broken...
|
* XXX BUG: macro's join does not seem to work...
|
||||||
* this will fail:
|
|
||||||
* p.pwiki.parse('<macro src="/test/*">@source(./path)</macro>')
|
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
@ -1196,6 +1194,7 @@ object.Constructor('Page', BasePage, {
|
|||||||
return }
|
return }
|
||||||
// parse arg values...
|
// parse arg values...
|
||||||
src = await this.parse(src, state)
|
src = await this.parse(src, state)
|
||||||
|
var full = this.get(src).path
|
||||||
|
|
||||||
handler = handler
|
handler = handler
|
||||||
?? function(){
|
?? function(){
|
||||||
@ -1208,17 +1207,17 @@ object.Constructor('Page', BasePage, {
|
|||||||
// handle recursion...
|
// handle recursion...
|
||||||
var parent_seen = state[key]
|
var parent_seen = state[key]
|
||||||
var seen = state[key] =
|
var seen = state[key] =
|
||||||
(state[key] ?? [this.location]).slice()
|
state[key]
|
||||||
|
?? []
|
||||||
// recursion detected...
|
// recursion detected...
|
||||||
// XXX RECURSION revise this...
|
if(seen.includes(full)){
|
||||||
if(seen.includes(src)){
|
|
||||||
if(!recursive){
|
if(!recursive){
|
||||||
throw new Error(
|
throw new Error(
|
||||||
macro +': recursion detected: '
|
macro +': recursion detected: '
|
||||||
+ seen.concat([src]).join(' -> ')) }
|
+ seen.concat([full]).join(' -> ')) }
|
||||||
// have the 'recursive' arg...
|
// have the 'recursive' arg...
|
||||||
return this.parse(recursive, state) }
|
return this.parse(recursive, state) }
|
||||||
seen.push(src)
|
seen.push(full)
|
||||||
|
|
||||||
// load the included page...
|
// load the included page...
|
||||||
var res = await handler.call(this)
|
var res = await handler.call(this)
|
||||||
@ -1563,7 +1562,6 @@ object.Constructor('Page', BasePage, {
|
|||||||
// NOTE: writing to .raw is the same as writing to .text...
|
// NOTE: writing to .raw is the same as writing to .text...
|
||||||
// NOTE: when matching multiple pages this will return a list...
|
// NOTE: when matching multiple pages this will return a list...
|
||||||
get raw(){ return (async function(){
|
get raw(){ return (async function(){
|
||||||
var that = this
|
|
||||||
var data = await this.data
|
var data = await this.data
|
||||||
// no data...
|
// no data...
|
||||||
// NOTE: if we hit this it means that nothing was resolved,
|
// NOTE: if we hit this it means that nothing was resolved,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user