mirror of
https://github.com/flynx/pWiki.git
synced 2025-12-18 00:51:38 +00:00
fixed several macro bugs...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
parent
a52b043f18
commit
09dce66dde
35
wiki.js
35
wiki.js
@ -156,6 +156,8 @@ var macro = {
|
|||||||
slot: function(context, args, text, state){
|
slot: function(context, args, text, state){
|
||||||
var name = args.name
|
var name = args.name
|
||||||
|
|
||||||
|
text = this.parse(context, text, state, true)
|
||||||
|
|
||||||
if(state.slots[name] == null){
|
if(state.slots[name] == null){
|
||||||
state.slots[name] = text
|
state.slots[name] = text
|
||||||
// return a slot macro parsable by stage 2...
|
// return a slot macro parsable by stage 2...
|
||||||
@ -233,13 +235,13 @@ var macro = {
|
|||||||
|
|
||||||
return res
|
return res
|
||||||
},
|
},
|
||||||
parse: function(context, text, state){
|
parse: function(context, text, state, skip_post){
|
||||||
var that = this
|
var that = this
|
||||||
state = state || {
|
state = state || {}
|
||||||
filters: [],
|
state.filters = state.filters || []
|
||||||
slots: {},
|
state.slots = state.slots || {}
|
||||||
include: [],
|
state.include = state.include || []
|
||||||
}
|
|
||||||
|
|
||||||
var _parse = function(context, text, macro){
|
var _parse = function(context, text, macro){
|
||||||
return text.replace(that.__macro__pattern__, function(match){
|
return text.replace(that.__macro__pattern__, function(match){
|
||||||
@ -259,9 +261,6 @@ var macro = {
|
|||||||
// macro stage 1...
|
// macro stage 1...
|
||||||
text = _parse(context, text, this.macro)
|
text = _parse(context, text, this.macro)
|
||||||
|
|
||||||
// macro stage 2...
|
|
||||||
text = _parse(context, text, this.post_macro)
|
|
||||||
|
|
||||||
// filter stage....
|
// filter stage....
|
||||||
state.filters
|
state.filters
|
||||||
.concat(this.__filters__)
|
.concat(this.__filters__)
|
||||||
@ -304,10 +303,16 @@ var macro = {
|
|||||||
return $('<span>')
|
return $('<span>')
|
||||||
.addClass('include')
|
.addClass('include')
|
||||||
.attr('src', page.path)
|
.attr('src', page.path)
|
||||||
.html(page.text)[0]
|
// XXX need to pass the state.slots to parser...
|
||||||
|
.html(page.parse({ slots: state.slots }, true))[0]
|
||||||
.outerHTML
|
.outerHTML
|
||||||
})
|
})
|
||||||
|
|
||||||
|
// macro stage 2...
|
||||||
|
if(!skip_post){
|
||||||
|
text = _parse(context, text, this.post_macro)
|
||||||
|
}
|
||||||
|
|
||||||
return text
|
return text
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
@ -677,12 +682,16 @@ var Wiki = {
|
|||||||
this.__wiki_data[l].links = this.links
|
this.__wiki_data[l].links = this.links
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
|
parse: function(state, skip_post){
|
||||||
|
// special case: if we are getting ./raw then do not parse text...
|
||||||
|
return this.title == 'raw' ? this.raw
|
||||||
|
: macro.parse(this, this.raw, state, skip_post)
|
||||||
|
},
|
||||||
// XXX not sure if this should return special function result as-is...
|
// XXX not sure if this should return special function result as-is...
|
||||||
// ...might be better to just special-case the 'raw' in path...
|
// ...might be better to just special-case the 'raw' in path...
|
||||||
get text(){
|
get text(){
|
||||||
// special case: if we are getting ./raw then do not parse text...
|
return this.parse() },
|
||||||
return this.title == 'raw' ? this.raw
|
|
||||||
: macro.parse(this, this.raw) },
|
|
||||||
|
|
||||||
|
|
||||||
// NOTE: this is set by setting .text
|
// NOTE: this is set by setting .text
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user