mirror of
https://github.com/flynx/pWiki.git
synced 2026-07-13 20:10:57 +00:00
...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
parent
d967a15a5d
commit
e7dc0194ad
@ -677,6 +677,7 @@ module.BaseParser = {
|
|||||||
|
|
||||||
// resolve stage II macros and merge results...
|
// resolve stage II macros and merge results...
|
||||||
//
|
//
|
||||||
|
// XXX BUG: sync/async paths seem to diverge...
|
||||||
resolve: function(page, ast, state={}){
|
resolve: function(page, ast, state={}){
|
||||||
var that = this
|
var that = this
|
||||||
ast = typeof(ast) != 'object' ?
|
ast = typeof(ast) != 'object' ?
|
||||||
@ -704,7 +705,12 @@ module.BaseParser = {
|
|||||||
prev = '' }
|
prev = '' }
|
||||||
if(args.length > 0){
|
if(args.length > 0){
|
||||||
elems.push(args.shift()) } } }
|
elems.push(args.shift()) } } }
|
||||||
|
var unpack = function(elem){
|
||||||
|
// XXX
|
||||||
|
}
|
||||||
|
|
||||||
|
// XXX can ast be a promise???
|
||||||
|
// XXX elems can be unresolved -- need a merge strategy for them...
|
||||||
for(var elem of ast){
|
for(var elem of ast){
|
||||||
// nesting...
|
// nesting...
|
||||||
while(elem && elem.value){
|
while(elem && elem.value){
|
||||||
@ -714,6 +720,11 @@ module.BaseParser = {
|
|||||||
elem = elem(state) } }
|
elem = elem(state) } }
|
||||||
if(elem == null){
|
if(elem == null){
|
||||||
continue }
|
continue }
|
||||||
|
// XXX do a delayed merge...
|
||||||
|
// ...but for this we need to also apply the rest of this iteration to the result...
|
||||||
|
if(elem.resolving){
|
||||||
|
console.log('!!!!!!!!!!!!!!!!!!!')
|
||||||
|
}
|
||||||
// atomic values...
|
// atomic values...
|
||||||
if(typeof(elem) != 'object'){
|
if(typeof(elem) != 'object'){
|
||||||
merge(elem)
|
merge(elem)
|
||||||
@ -725,11 +736,12 @@ module.BaseParser = {
|
|||||||
continue }
|
continue }
|
||||||
// expand ast...
|
// expand ast...
|
||||||
if(elem instanceof Array){
|
if(elem instanceof Array){
|
||||||
//merge(...this.resolve(page, elem, state))
|
// XXX this can containe promises...
|
||||||
merge(...this.resolve(page, elem, state))
|
merge(...this.resolve(page, elem, state))
|
||||||
continue }
|
continue }
|
||||||
// expand .body attribute...
|
// expand .body attribute...
|
||||||
if((elem.attrs ?? {}).body instanceof Array){
|
if((elem.attrs ?? {}).body instanceof Array){
|
||||||
|
// XXX this can containe promises...
|
||||||
elem.attrs.body = this.resolve(page, elem.attrs.body, state) }
|
elem.attrs.body = this.resolve(page, elem.attrs.body, state) }
|
||||||
// nested macro with no value set -- skip...
|
// nested macro with no value set -- skip...
|
||||||
if(this.macros[elem.name] instanceof Array){
|
if(this.macros[elem.name] instanceof Array){
|
||||||
@ -1527,7 +1539,6 @@ module.parser = {
|
|||||||
delete state.include_stack
|
delete state.include_stack
|
||||||
delete state.recursive }
|
delete state.recursive }
|
||||||
// cache the final result...
|
// cache the final result...
|
||||||
// XXX wrap??
|
|
||||||
cache[src] = pages
|
cache[src] = pages
|
||||||
return pages }
|
return pages }
|
||||||
|
|
||||||
|
|||||||
@ -198,7 +198,7 @@ test.Setups({
|
|||||||
return this.include(assert, '/page') },
|
return this.include(assert, '/page') },
|
||||||
include_include_page: function(assert){
|
include_include_page: function(assert){
|
||||||
return this.include(assert, '/includePage', 'Page') },
|
return this.include(assert, '/includePage', 'Page') },
|
||||||
/* XXX
|
/* XXX parser.resolve(..) does not handle promises correctly yet...
|
||||||
include_async: function(assert){
|
include_async: function(assert){
|
||||||
return this.include(assert, '/async/page') },
|
return this.include(assert, '/async/page') },
|
||||||
//*/
|
//*/
|
||||||
@ -256,6 +256,8 @@ test.Tests({
|
|||||||
'\n\t in: "'+ input +'"',
|
'\n\t in: "'+ input +'"',
|
||||||
'\n\t out: "'+ res +'"',
|
'\n\t out: "'+ res +'"',
|
||||||
'\n\texpected: "'+ expect +'"') } },
|
'\n\texpected: "'+ expect +'"') } },
|
||||||
|
//asyncParse: async function(assert, state){
|
||||||
|
// return await this.parse(assert, state) },
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user