playing with the parser...

Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
Alex A. Naanou 2016-10-28 23:28:50 +03:00
parent 52cdbcc63d
commit c60569e021
2 changed files with 50 additions and 35 deletions

View File

@ -259,7 +259,7 @@ Replaced with current page title.
**`$INDEX`**
Replaced with current page index in pattern selection.
Replaced with current page index in pattern matching.

View File

@ -474,6 +474,7 @@ module = {
// /SomePage/SomePage
// or any path matching:
// /\/(SomePage\/)+/
// XXX slow when lots of pages need to be included...
parse: function(context, text, state, skip_post, pattern){
var that = this
@ -551,16 +552,22 @@ module = {
// #text / comment node -> parse the @... macros...
if(e.nodeType == e.TEXT_NODE || e.nodeType == e.COMMENT_NODE){
// get actual element content...
var text = $('<div>').append($(e).clone()).html()
var text = e.nodeValue
// conditional comment...
if(e.nodeType == e.COMMENT_NODE
&& /^<!--\s*\[pWiki\[(.|\n)*\]\]\s*-->$/.test(text)){
text = text
if(e.nodeType == e.COMMENT_NODE){
text = /^<!--\s*\[pWiki\[(.|\n)*\]\]\s*-->$/.test(text) ?
text
.replace(/^<!--\s*\[pWiki\[/, '')
.replace(/\]\]\s*-->$/, '')
: ('<!--'+ text +'-->')
}
/*
var t = _parseText(context, text, macro)
text != t
&& $(e).replaceWith(t)
//*/
$(e).replaceWith(_parseText(context, text, macro))
// node -> html-style + attrs...
@ -627,9 +634,14 @@ module = {
// filter stage...
_filter(state.filters.concat(this.__filters__), this.filter)
// XXX DEBUG...
var t = Date.now()
console.log('>>>', context.path())
// merge includes...
parsed
.html(parsed.html().replace(include_marker, function(){
.html(parsed.html()
.replace(include_marker, function(){
var page = state.include.shift()
var elem = $(page.shift())
page = page.pop()
@ -660,6 +672,9 @@ module = {
}).join('\n')
}))
// XXX DEBUG...
console.log('<<<', context.path(),'TIME:', Date.now() - t)
// post processing...
if(!skip_post){
// fill slots...