diff --git a/index.html b/index.html index 94f8afd..37505e7 100755 --- a/index.html +++ b/index.html @@ -25,7 +25,7 @@ var reload = () => { $('.title').text(Wiki.title) // process text... - var text = Wiki.text + var text = Wiki.raw var editing = $('.text').prop('contenteditable') != 'true' var filters = [] var slots = {} @@ -52,7 +52,7 @@ var reload = () => { if(macro == 'include' && args.length == 1){ w = Object.create(Wiki) w.location = args[0] - return w.text + return w.raw } if(macro == 'attr' @@ -86,7 +86,7 @@ var reload = () => { if(macro == 'include' && args.src != null){ w = Object.create(Wiki) w.location = args.src - return w.text + return w.raw } // XXX need content... diff --git a/wiki.js b/wiki.js index 6fe84fa..bed7381 100755 --- a/wiki.js +++ b/wiki.js @@ -28,26 +28,30 @@ var normalizePath = function(path){ var clearWikiWords = function(elem){ // clear existing... elem.find('.wikiword').each(function(){ - $(this).attr('braced') == 'yes' ? + $(this).attr('bracketed') == 'yes' ? $(this).replaceWith(['['].concat(this.childNodes, [']'])) : $(this).replaceWith(this.childNodes) }) return elem } -var setWikiWords = function(text, show_brackets){ - return text +var setWikiWords = function(text, show_brackets, skip){ + skip = skip || [] + skip = skip instanceof Array ? skip : [skip] + return text // set new... .replace( Wiki.__wiki_link__, function(l){ - return '' - + (!!show_brackets && l[0] == '[' ? l.slice(1, -1) : l) - +'' + return skip.indexOf(l) < 0 ? + ('' + + (!!show_brackets && l[0] == '[' ? l.slice(1, -1) : l) + +'') + : l })} @@ -106,18 +110,40 @@ var macro = { // include page/slot... // // NOTE: this will render the page in the caller's context. - include_args: ['src', 'slot'], + // NOTE: included pages are rendered completely independently + // from the including page. + // + // XXX do we need to control the rendering of nested pages??? + // ...currently I do not think so... + // ...if required this can be done via global and local + // filters... (now filters are only local) + // XXX do we need to render just one slot??? (slot arg) + include_args: ['src'], include: function(context, args, _, state){ var path = args.src - var text = context.get(path).text - - //return this.parse(context, text) - state.include.push(this.parse(context, text)) + // XXX not sure if we need to render the source page relative + // to this or as-is... + state.include + //.push(this.parse(context, context.get(path).raw)) + .push(context.get(path).text) return this.__include_marker__ }, + /* + // NOTE: this is similar to include, the difference is that this + // includes the page source to the current context while + // include works in an isolated context + // XXX currently this will not parse the target... + source_args: ['src'], + source: function(context, args, _, state){ + var path = args.src + + return context.get(path).raw + }, + //*/ + // fill/define slot (stage 1)... slot_args: ['name'], slot: function(context, args, text, state){ @@ -135,8 +161,7 @@ var macro = { }, }, // stage 2... - // XXX rename... - macro2: { + post_macro: { slot_args: ['name'], slot: function(context, args, text, state){ var name = args.name @@ -152,13 +177,9 @@ var macro = { // Filters... // - // NOTE: a filter should be applicable multiple times without any - // side effects... - // XXX is this good??? + // Signature: + // filter(text) -> html // - // XXX this is preliminary... - // XXX add wikiword... - // filter(text) -> html filter: { default: 'html', @@ -167,7 +188,8 @@ var macro = { json: 'text', text: function(context, text){ return $('