diff --git a/index.html b/index.html
index 0af638f..94f8afd 100755
--- a/index.html
+++ b/index.html
@@ -121,6 +121,9 @@ var reload = () => {
}
var go = (path) => {
+ path = path.trim()
+ path = path[0] == '[' ? path.slice(1, -1) : path
+
history.pushState({
wikipath: path
},
diff --git a/wiki.js b/wiki.js
index fe3acb8..6fe84fa 100755
--- a/wiki.js
+++ b/wiki.js
@@ -27,7 +27,7 @@ var normalizePath = function(path){
var clearWikiWords = function(elem){
// clear existing...
- elem.find('.WikiWord').each(function(){
+ elem.find('.wikiword').each(function(){
$(this).attr('braced') == 'yes' ?
$(this).replaceWith(['['].concat(this.childNodes, [']']))
: $(this).replaceWith(this.childNodes)
@@ -41,11 +41,12 @@ var setWikiWords = function(text, show_brackets){
Wiki.__wiki_link__,
function(l){
return ''
- + (show_brackets && l[0] == '[' ? l.slice(1, -1) : l)
+ +'braced="'+ (show_brackets && l[0] == '[' ? 'yes' : 'no') +'" '
+ +'onclick="go($(this).text())" '
+ +'>'
+ + (!!show_brackets && l[0] == '[' ? l.slice(1, -1) : l)
+''
})}
@@ -56,6 +57,8 @@ var setWikiWords = function(text, show_brackets){
// XXX should inline macros support named args???
var macro = {
+ __include_marker__: '__include_marker__',
+
// Abstract macro syntax:
// Inline macro:
// @macro(arg ..)
@@ -78,8 +81,6 @@ var macro = {
'wikiword',
],
- context: null,
-
// Maacros...
//
// stage 1...
@@ -90,40 +91,45 @@ var macro = {
macro: {
// select filter to post-process text...
filter_args: ['name'],
- filter: function(args, text, _, filters){
+ filter: function(context, args, text, state){
var filter = args[0] || args.name
filter[0] == '-' ?
// disabled -- keep at head of list...
- filters.unshift(filter)
+ state.filters.unshift(filter)
// normal -- tail...
- : filters.push(filter)
+ : state.filters.push(filter)
return ''
},
// include page/slot...
+ //
+ // NOTE: this will render the page in the caller's context.
include_args: ['src', 'slot'],
- include: function(args){
+ include: function(context, args, _, state){
var path = args.src
- var text = this.context.get(path).text
+ var text = context.get(path).text
- return this.parse(text)
+ //return this.parse(context, text)
+ state.include.push(this.parse(context, text))
+
+ return this.__include_marker__
},
// fill/define slot (stage 1)...
slot_args: ['name'],
- slot: function(args, text, slots){
+ slot: function(context, args, text, state){
var name = args.name
- if(slots[name] == null){
- slots[name] = text
+ if(state.slots[name] == null){
+ state.slots[name] = text
// return a slot macro parsable by stage 2...
return '