mirror of
https://github.com/flynx/pWiki.git
synced 2026-01-04 17:11:09 +00:00
added macro quoting + readme...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
parent
51cf555609
commit
71a8830800
22
README.md
22
README.md
@ -1,2 +1,20 @@
|
|||||||
# pWiki
|
# Portable Wiki (pWiki)
|
||||||
Portable Wiki
|
|
||||||
|
Project goals:
|
||||||
|
- Provide a simple embeddable Wiki
|
||||||
|
This enables a zero-workflow app documentation, i.e. documentation that
|
||||||
|
can be created, edited, tweaked and updated in-app without requiring
|
||||||
|
setting up and maintaining a write-convert-embed workflow.
|
||||||
|
|
||||||
|
- Provide pluggable storage and synchronization
|
||||||
|
|
||||||
|
- Implement a Wiki/note _portable_ app
|
||||||
|
- a simple and functional note/todo/outline app
|
||||||
|
- an external/portable Wiki editor, as an alternative for in-app
|
||||||
|
documentation editor with ability to seamlesly synchronize with
|
||||||
|
the target app.
|
||||||
|
- a stand-alone testing platform for project components
|
||||||
|
|
||||||
|
General Documentation:
|
||||||
|
- WikiPath
|
||||||
|
- WikiMacros / [bootstrap/WikiMacros.tpl]
|
||||||
|
|||||||
@ -31,6 +31,12 @@ glob('bootstrap/**/*.tpl')
|
|||||||
+'\n\n'
|
+'\n\n'
|
||||||
+'var Bootstrap = ' + JSON.stringify(bootstrap)
|
+'var Bootstrap = ' + JSON.stringify(bootstrap)
|
||||||
|
|
||||||
|
if(!bootstrap.WikiHome && fs.existsSync('README.md')){
|
||||||
|
bootstrap.WikiHome = {
|
||||||
|
text: fs.readFileSync('README.md').toString(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
console.log('Writing:', 'bootstrap.js')
|
console.log('Writing:', 'bootstrap.js')
|
||||||
fs.writeFileSync('bootstrap.js', txt)
|
fs.writeFileSync('bootstrap.js', txt)
|
||||||
})
|
})
|
||||||
|
|||||||
43
wiki.js
43
wiki.js
@ -102,7 +102,7 @@ var macro = {
|
|||||||
__macro__pattern__:
|
__macro__pattern__:
|
||||||
[[
|
[[
|
||||||
// @macro(arg ..)
|
// @macro(arg ..)
|
||||||
'@([a-zA-Z-_]+)\\(([^)]*)\\)'
|
'\\\\?@([a-zA-Z-_]+)\\(([^)]*)\\)'
|
||||||
].join('|'), 'mg'],
|
].join('|'), 'mg'],
|
||||||
|
|
||||||
// default filters...
|
// default filters...
|
||||||
@ -289,7 +289,16 @@ var macro = {
|
|||||||
|
|
||||||
// Post macros...
|
// Post macros...
|
||||||
//
|
//
|
||||||
|
// XXX this is disabled for now, see end of .parse(..)
|
||||||
post_macro: {
|
post_macro: {
|
||||||
|
'*': Macro('cleanup...',
|
||||||
|
[],
|
||||||
|
function(context, elem, state, parse, match){
|
||||||
|
if(match != null){
|
||||||
|
return match[0] == '\\' ? match.slice(1) : match
|
||||||
|
}
|
||||||
|
return elem
|
||||||
|
}),
|
||||||
/*
|
/*
|
||||||
_slot: Macro('',
|
_slot: Macro('',
|
||||||
['name'],
|
['name'],
|
||||||
@ -432,14 +441,22 @@ var macro = {
|
|||||||
|
|
||||||
var _parseText = function(context, text, macro){
|
var _parseText = function(context, text, macro){
|
||||||
return text.replace(pattern, function(match){
|
return text.replace(pattern, function(match){
|
||||||
|
// quoted macro...
|
||||||
|
if(match[0] == '\\' && macro['*'] == null){
|
||||||
|
return match.slice(1)
|
||||||
|
//return match
|
||||||
|
}
|
||||||
|
|
||||||
// XXX parse match...
|
// XXX parse match...
|
||||||
var d = match.match(/@([a-zA-Z-_:]*)\(([^)]*)\)/)
|
var d = match.match(/@([a-zA-Z-_:]*)\(([^)]*)\)/)
|
||||||
|
|
||||||
var name = d[1]
|
var name = d[1]
|
||||||
|
|
||||||
if(name in macro){
|
if(name in macro || '*' in macro){
|
||||||
var elem = $('<'+name+'/>')
|
var elem = $('<'+name+'/>')
|
||||||
|
|
||||||
|
name = name in macro ? name : '*'
|
||||||
|
|
||||||
// format positional args....
|
// format positional args....
|
||||||
var a = d[2]
|
var a = d[2]
|
||||||
.split(/((['"]).*?\2)|\s+/g)
|
.split(/((['"]).*?\2)|\s+/g)
|
||||||
@ -449,16 +466,18 @@ var macro = {
|
|||||||
.map(function(e){ return /^(['"]).*\1$/.test(e) ? e.slice(1, -1) : e })
|
.map(function(e){ return /^(['"]).*\1$/.test(e) ? e.slice(1, -1) : e })
|
||||||
|
|
||||||
// add the attrs to the element...
|
// add the attrs to the element...
|
||||||
a.forEach(function(e, i){
|
name != '*'
|
||||||
var k = ((macro[name] || {}).macro_args || [])[i]
|
&& a.forEach(function(e, i){
|
||||||
k && elem.attr(k, e)
|
var k = ((macro[name] || {}).macro_args || [])[i]
|
||||||
})
|
k && elem.attr(k, e)
|
||||||
|
})
|
||||||
|
|
||||||
// call macro...
|
// call macro...
|
||||||
var res = macro[name]
|
var res = macro[name]
|
||||||
.call(that, context, elem, state,
|
.call(that, context, elem, state,
|
||||||
function(elem, c){
|
function(elem, c){
|
||||||
return _parse(c || context, elem, macro) })
|
return _parse(c || context, elem, macro) },
|
||||||
|
match)
|
||||||
|
|
||||||
return res instanceof jQuery ?
|
return res instanceof jQuery ?
|
||||||
// merge html of the returned set of elements...
|
// merge html of the returned set of elements...
|
||||||
@ -602,12 +621,14 @@ var macro = {
|
|||||||
})
|
})
|
||||||
|
|
||||||
// post-macro...
|
// post-macro...
|
||||||
this.post_macro
|
// XXX for some odd reason this clears the backslash from
|
||||||
&& _parse(context, parsed, this.post_macro)
|
// quoted macros in raw fields...
|
||||||
|
//this.post_macro
|
||||||
|
// && _parse(context, parsed, this.post_macro)
|
||||||
}
|
}
|
||||||
|
|
||||||
// XXX shuld we get rid of the rot span???
|
// XXX shuld we get rid of the root span???
|
||||||
return parsed
|
return parsed.contents()
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user