mirror of
https://github.com/flynx/pWiki.git
synced 2025-12-17 00:21:40 +00:00
added full conditional comments...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
parent
8937ae5e86
commit
ca5fcf8801
@ -13,7 +13,7 @@ are likely to change, the implementation / API **will definitely** change! ;)_
|
||||
without requiring setting up and maintaining a write-convert-embed
|
||||
workflow.
|
||||
|
||||
This was a requirement on the _ImageGrid.Viewer_ project and as a
|
||||
This was a requirement on the _\ImageGrid.Viewer_ project and as a
|
||||
side-effect pWiki hosts it's own documentation too.
|
||||
|
||||
- _Pluggable storage and synchronization_ mechanisms
|
||||
|
||||
2
bootstrap.js
vendored
2
bootstrap.js
vendored
File diff suppressed because one or more lines are too long
@ -60,6 +60,29 @@ are escaped a bit differently:
|
||||
|
||||
|
||||
|
||||
### Conditional comments
|
||||
|
||||
In addition to HTML and filter-specific comments pWiki provides two types
|
||||
of conditional comments that serve two specific functions:
|
||||
|
||||
Show something in pWiki but hide it in HTML:
|
||||
```
|
||||
<!--\[pWiki[ ... ]]-->
|
||||
```
|
||||
|
||||
Show something in HTML but hide in pWiki:
|
||||
<pre>
|
||||
<pwiki-comment> ... </pwiki-comment>
|
||||
|
||||
or
|
||||
|
||||
\@pwiki-comment( ... )
|
||||
</pre>
|
||||
|
||||
|
||||
This will enable writing documents (mainly in _markdown_) that are usable
|
||||
bot from within pWiki as well as outside.
|
||||
|
||||
|
||||
## Macros
|
||||
|
||||
@ -139,9 +162,10 @@ Arguments:
|
||||
**Example:**
|
||||
|
||||
[Templates/\_css] / [bootstrap css](bootstrap/Templates/_css.html):
|
||||
```
|
||||
<!--[pWiki[```
|
||||
@source(Templates/_css)
|
||||
```
|
||||
]]-->
|
||||
|
||||
|
||||
### slot (name text)
|
||||
|
||||
19
wiki.js
19
wiki.js
@ -48,6 +48,11 @@ var setWikiWords = function(text, show_brackets, skip){
|
||||
.replace(
|
||||
Wiki.__wiki_link__,
|
||||
function(l){
|
||||
// check if wikiword is escaped...
|
||||
if(l[0] == '\\'){
|
||||
return l.slice(1)
|
||||
}
|
||||
|
||||
var path = l[0] == '[' ? l.slice(1, -1) : l
|
||||
var i = [].slice.call(arguments).slice(-2)[0]
|
||||
|
||||
@ -125,7 +130,9 @@ var macro = {
|
||||
macro: {
|
||||
"pwiki-comment": Macro('hide in pWiki',
|
||||
[],
|
||||
function(context, elem, state){ return '' }),
|
||||
function(context, elem, state){
|
||||
return ''
|
||||
}),
|
||||
now: Macro('Create a now id',
|
||||
[],
|
||||
function(context, elem, state){ return ''+Date.now() }),
|
||||
@ -570,6 +577,12 @@ var macro = {
|
||||
// get actual element content...
|
||||
var text = $('<div>').append($(e).clone()).html()
|
||||
|
||||
// conditional comment...
|
||||
if(e.nodeType == e.COMMENT_NODE
|
||||
&& /^<!--\[pWiki\[(.|\n)*\]\]-->$/.test(text)){
|
||||
text = text.slice(11, -5)
|
||||
}
|
||||
|
||||
$(e).replaceWith(_parseText(context, text, macro))
|
||||
|
||||
// node -> html-style + attrs...
|
||||
@ -1008,8 +1021,8 @@ var Wiki = {
|
||||
//__redirect_template__: 'RedirectTemplate',
|
||||
|
||||
__wiki_link__: RegExp('('+[
|
||||
'(\\./|\\.\\./|[A-Z][a-z0-9]+[A-Z/])[a-zA-Z0-9/]*',
|
||||
'\\[[^\\]]+\\]',
|
||||
'\\\\?(\\./|\\.\\./|[A-Z][a-z0-9]+[A-Z/])[a-zA-Z0-9/]*',
|
||||
'\\\\?\\[[^\\]]+\\]',
|
||||
].join('|') +')', 'g'),
|
||||
|
||||
__macro_parser__: macro,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user