WikklyText A wikitext server and rendering library


files/feed-icon-14x14.png Recently Edited Valid XHTML 1.0 Strict
MarkupReference edit
frank, 01 March 2008 (created 05 October 2007)
Tags: markup help -rss
This is the WikklyText user documentation (version 1.5.0).

You can generate this help file by placing <<help>> inside any wiki text.


Contents

Formatting


Bold Italic Strikethrough Underline
Superscript Subscript Comments Inline styling
Links Images HTML-markup NoWiki
Inline code Block code Block-Indent Line-Indent
Lists Headings Definitions Tables
Bold
Markup'' ... ''
Examplehere is ''bold text''
Resulthere is bold text
Italic
Markup// ... //
Examplehere is //italic text//
Resulthere is italic text
Strikethrough
Markup-- ... --
Examplehere is --strikethrough text--
Resulthere is strikethrough text
Underlined
Markup__ ... __
Examplehere is __underlined text__
Resulthere is underlined text
Superscript
Markup^^ ... ^^
Examplehere is ^^superscript text^^
Resulthere is superscript text
Subscript
Markup~~ ... ~~
Examplehere is ~~subscript text~~
Resulthere is subscript text
Comments
Markup/% ... %/
Example/% A comment produces no output %/
Result
CaveatsComments are not allowed to nest.
Markup
/***
...
***/
Example
/***
The comment markers are removed. Inner text
''is'' //processed// __normally__.
***/
Result The comment markers are removed. Inner text is processed normally.
CaveatsComments are not allowed to nest.
Markup
<!---
...
--->
Example
<!---
The comment markers are removed. Inner text
''is'' //processed// __normally__.
--->
Result The comment markers are removed. Inner text is processed normally.
CaveatsComments are not allowed to nest.
Highlighted
Markup@@ ... @@
ExampleHere is @@highlighted text@@
ResultHere is highlighted text
Applying CSS classes
Markup {{class{ ... }}}
Example Here is {{grayout{grayed-out text}}} with CSS
ResultHere is grayed-out text with CSS
More on Classes
Classes are flowed down into inner elements by appending them after any classes applied previously. This is especially useful when you want to override implicit styling:
A link using implicit styling: 
* http://wikklytext.com

A link using my styling to override: 
* {{test_overline{http://wikklytext.com}}}


Result:

A link using implicit styling: A link using my styling to override:
Inline CSS styles (with @@style; ...)
Markup @@styles; ... 
Example@@color: green; font-style: italic; hello world@@
Result hello world
CaveatsNot available in Safe Mode
Inline styling (with old-style color() statement)
Markup@@color(color): ... @@
Exampletesting @@color(green): green text@@
Resulttesting green text
CaveatsNot available in Safe Mode
Inline-styling (with old-style bgcolor() statement)
Markup@@bgcolor(color): ... @@
Exampletesting @@bgcolor(yellow): yellow background@@
CaveatsNot available in Safe Mode
Resulttesting yellow background
Link
Markup[[Link Text|URL]]
ExampleHere is a [[link to wikklytext.com|http://wikklytext.com]]
ResultHere is a link to wikklytext.com
Image (no link)
Markup[img[file]]
Example[img[css/img_link_www.png]]
Resultcss/img_link_www.png
Bare URLs are turned into links as well:
Markuphttp:// ..., file:/// ..., ftp:// ..., etc.
Examplehttp://boodebr.org/python, mailto:nobody@nowhere.com
Resulthttp://boodebr.org/python, mailto:nobody@nowhere.com
Image (with link)
Markup[img[file][URL]]
Example[img[css/img_link_www.png][http://wikklytext.com]]
Resultcss/img_link_www.png
Raw HTML
Markup<html> ... </html>
Example
<html>Raw <b>HTML</b>, all <i>wiki markup</i> {{{ is }}} ignored}}</html>
ResultRaw HTML, all wiki markup {{{ is }}​} ignored}}
CaveatsHTML blocks are not allowed to nest.
This markup is not available in Safe Mode.
NoWiki
Markup<nowiki> ... </nowiki>
Example
<nowiki><nowiki>, ignores <b>all</b> &nbsp;&#32; //markup//</nowiki>
Result<nowiki>, ignores <b>all</b> &nbsp;&#32; //markup//
Caveatsnowiki blocks are not allowed to nest.
Line-break
Markup<br> or <br/>
ExampleHere is a<br>break and<br/>another break
ResultHere is a
break and
another break
Dash
Markup--
ExampleAnd then -- eureka!
ResultAnd then — eureka!
Separator
Markup----
(On a line by itself.)
Example----
Result
HTML Entities
Markup&ENTITY;, &NNN;, &#xHH
Example&Pi; <br> 1 &#43; 2 &#x3d; 3
ResultΠ
1 + 2 = 3
NULL-dot
Markup.
(On a line by itself.)
Example.
Result
This is a WikklyText extension. The NULL-dot allows you to spread your text out for readability without causing blank lines to be inserted.
NOP
Markup&#x200b;
ExampleHel&#x200b;lo Wo&#x200b;rld
ResultHello World
This is a WikklyText extension. The NOP sequence is always removed from the final markup. It allows you to break-up sequences that would otherwise be identified as markup, where no other escaping methods work.
Inline code
Markup {{{ ... }}} 
ExampleHere is an {{{inline code}}} sample
ResultHere is an inline code sample
CaveatsCode blocks are not allowed to nest.
Code Blocks
Markup
{{{
   ...
   ...
}}}
Example
{{{
for i in range(20):
    print i
    print i*10
}}}
Result
for i in range(20):
   print i
   print i*10
CaveatsCode blocks are not allowed to nest.
Markup
/*{{{*/
...
...
/*}}}*/
Example
/*{{{*/
Here is a
block of code.
/*}}}*/
Result
Here is a
block of code.
CaveatsCode blocks are not allowed to nest.
Markup
//{{{
...
...
//}}}
Example
//{{{
Here is a
block of code.
//}}}
Result
Here is a
block of code.
CaveatsCode blocks are not allowed to nest.
Markup
<!--{{{-->
...
...
<!--}}}-->
Example
<!--{{{-->
Here is a
block of code.
<!--}}}-->
Result
Here is a
block of code.
CaveatsCode blocks are not allowed to nest.
Block-Indent
Markup
<<<
   ...
<<<
Example
<<< 
A block-ident indents the inner wiki text, preserving
all other formatting. For example, here is a list:

* One
* Two
** Two.A
** Two.B
* Three
<<<
Result
A block-ident indents the inner wiki text, preserving all other formatting. For example, here is a list:

  • One
  • Two
    • Two.A
    • Two.B
  • Three
Line-Indent
Markup
> ...
>> ...
>>> ...
> ...
Example
> Level one<br>
> here
>> Level two<br>
>> here
>>> Level three<br>
>>> here
> Level one<br>
> here
Result
Level one
here
Level two
here
Level three
here
Level one
here
Numbered list
Markup
# ... 1st level ...
## ... 2nd level ...
### ... 3rd level ...
Example
/% Leading spaces are optional %/
# Item One
  ## Item Two
    ### Item three
# Item Four
Result
  1. Item One
    1. Item Two
      1. Item three
  2. Item Four
Unnumbered list
Markup
* ... 1st level ...
** ... 2nd level ...
*** ... 3rd level ...
Example
/% Leading spaces are optional %/
* Item One
  ** Item Two
    *** Item three
* Item Four
Result
  • Item One
    • Item Two
      • Item three
  • Item Four
Headings
Markup
!1st level
!!2nd level
!!!3rd level
Example
!Heading, level 1

!!Heading, level 2

!!!Heading, level 3

!!!!Heading, level 4

!!!!!Heading, level 5

!!!!!!Heading, level 6
Result

Heading, level 1


Heading, level 2


Heading, level 3


Heading, level 4


Heading, level 5

Heading, level 6
Definition List
Markup
;Term
:Definition
Example
;Term 1
:This is the definition of Term 1
;Term 2
:This is the definition of Term 2
Result
Term 1
This is the definition of Term 1
Term 2
This is the definition of Term 2


Tables


Use | to separate columns and ! to mark header cells.

|!a|!b|!c|
|!d|e|f|
|!g|h|i|
abc
def
ghi
For column spans, put > in the skipped columns:

|!a|!b|!c|
|!d|>|colspan=2|
|!g|h|i|
abc
dcolspan=2
ghi
For row spans, put ~ in the skipped rows:

|!a|!b|!c|
|!d|rowspan=3|f|
|!g|~|i|
|!j|~|l|
abc
drowspan=3f
gi
jl
You can add a caption by adding a row like this (note there is no trailing '|'):

|A Table Caption|c


Example:

|!aaaaaaaa|!bbbbbbbb|!ccccccccc|
|!d|e|f|
|!g|h|i|
|A Table Caption|c


Result:

A Table Caption
aaaaaaaabbbbbbbbccccccccc
def
ghi
Coloring cells with bgcolor():

|a|b|c|
|bgcolor(yellow):yellow here|>|bgcolor(#ff0000):red here|
|>|>|bgcolor(green): @@color: white; font-weight: bold;bold white on green by mixing styles@@ |
abc
yellow herered here
bold white on green by mixing styles


Text Justification in Table Cells


Text justification follows TiddlyWiki's rules on leading/trailing spaces:
  • Leading spaces: Right justify
  • Trailing spaces: Left justify
  • Leading and trailing spaces: Center justify
  • No spaces:
    • Header cell: Center justify
    • Normal cell: Left justify
  • Leading spaces on bgcolor(), if used: No effect on calculation

Example

|aaaaaaaaaaaaaaaaaaa|bbbbbbbbbbbbbbbbb|cccccccccccccccccccc|
|!left header |>| !center header |
| !right header|>|!center header|
|left text | center text | right text|
|>|>|left text|
| bgcolor(#008800):left text |bgcolor(#008800): center text |bgcolor(#008800): right text|
|>|>|  bgcolor(#008800):left text|


Result
aaaaaaaaaaaaaaaaaaabbbbbbbbbbbbbbbbbcccccccccccccccccccc
left header center header
right headercenter header
left text center text right text
left text
left text center text right text
left text


Unicode and Multibyte character sets


WikklyText fully supports multilingual content using both traditional multibyte character sets as well as Unicode. See multilanguage examples for details.

Macros


Calling a Macro
Markup<<macroname arg1 arg2 ...>>
Example<<echos aaa "bbb" 'ccc' """ddd""" '''eee''' <quote>"fff"</quote>>>
Resultaaa bbb ccc ddd eee "fff"
Writing Macros

See coremacros.py in the WikklyText distribution for complete examples of macros.

You can also define macros inside your wikitexts like this:

<?py
def mytable(context, width, height):
    # args are Elements - convert .text part
    width = int(width.text)
    height = int(height.text)
    txt = 'A %d by %d table\n' % (width,height)
    
    for i in range(height):
        # row
        for j in range(width):
            txt += '|%d' % (i*width + j + 1)
            
        txt += '|\n'
        
    return txt
?>
/% call it ... %/
<<mytable 4 10>>


Inside a macro, the following globals are always available:
Element, SubElement From ElementTree
Text Convenience to make a <Text> node.
Usage: Text("some text")
WikError If you need to raise an Exception, use this type.
FS_CWD The (physical) location of your wikitext.

If you need to open a file relative to your wikitext location, do:
open(os.path.join(FS_CWD,filename), ...)
When writing inline code, <?py and ?> must be the first and last things on a line (although the code can span multiple lines).



Differences between TiddlyWiki & WikklyText


There are probably more differences than I've listed here, these are just the ones I've noted to date. Most are due to personal preference in situations where I don't like something TiddlyWiki does. See the footnotes for details, if you are interested.

ItemTiddlyWikiWikklyText
Allows leading spaces in listitems
* # ; :
NO YES1
Allows leading spaces in separators
----
NO YES1
Allows leading spaces in bgcolor() NO YES2
Allow extra spaces inside @@ .. @@ NO YES2
Effect of a single linebreak characterBreaks paragraphParagraph continues flowing until double linebreak3

Use <<set $REFLOW 0>> to get TiddlyWiki behavior
Maximum header depth5; extra "!" chars are shown6; extra "!" chars are hidden4
CamelWords are automatic links YES YES
Anchors within document NO YES5
Output FormatsTiddlyWiki

All-in-one self-contained wiki
XML, HTML, Drupal plugin, or standalone Wiki

Modular library useful in any number of situations, plus a wiki server.
Image float left/right YES NO9
In tables: Classes, THEAD, TFOOT YES NO9
Use {{class{ to set styles for tables and elements.
Macros
Macro language Javascript Python
How macros work ...Create DOM elements directly in wikiReturn etree.Elements or strings (that are reparsed for wiki content)
Arg quotingunquoted, ', "unquoted, ', ", ''', """, <quote> .. </quote>6
Arg: "aaa"bbb'ccc'Two args (aaa and bbb'ccc')One arg (aaabbbccc)
Auto-concatenation of adjacent strings7
Nested macro calls? PARTIAL10 YES8
Thread-safe storage for data persistence across macro calls? NO YES
Python/C style escapes in argument strings? NO YES
Footnotes:
  1. I like my wiki source texts to be indented the same as they will render in HTML. Also, many editors (like jEdit) auto-indent by default, and it is harder to delete the indents than leave them in.
  2. No particular reason, just to be flexible.
  3. This could be argued either way - TiddlyWiki's way is more WYSIWYG, but I prefer to be able to write a long paragraph without having to put it all on one line.
  4. 6 levels are supported because that is what HTML defines as the maximum.
  5. You can create document anchors like this:
    • Create anchor: [[#anchor_name]]
    • Link to anchor: [[Link text|#anchor_name]]
  6. I say, the more quoting methods the better, and this was inspired by Python's triple-quoted strings. The extension <quote> ... </quote> comes in handy especially when you are quoting Python code in a macro call that already contains the other quote types.
    NOTE: Unlike Python, Single-vs-Triple strings are not special. They are both allowed to contain embedded newlines, etc.
  7. Similar to Python and the C-preprocessor, cramming strings together works.
  8. The only time they cause a problem is if a macro returns text containing << that is then parsed as another macro call. This limitation will be corrected in WikklyText 2.x
  9. Will likely be added to WikklyText at some point.
  10. As I understand it, TiddlyWiki somewhat supports nested macros with an extended call syntax, but WikklyText supports nesting like this:
    <<one <<two <<three>> >> >>
    ... where <<two gets the returned value from <<three>> as an input arg.

Built-in Macros

closeAll
Usage<<closeAll>>
DescriptionThis only exists for compatibility with TiddlyWiki texts.

It does not do anything.
Example<<closeAll>>
Result


codebox
Usage<<codebox title arg [arg ...]>>
DescriptionLike a regular code box, except with a title.
Example
<<codebox "A Title" '''
for i in range(10):
    print i'''>>
Result
A Title
for i in range(10):
    print i


debug (Full Mode only)
Usage<<debug arg arg ...>>
DescriptionPrints arguments to stdout - does not become part of document.
ExampleNo example, to prevent console noise.
Result


div (Full Mode only)
Usage<<div class style id text>>
DescriptionCreate a block element (like <div>).
Example<<div "foo" "color:green; border: 1px solid red;" "id123" "I am //italic// here">>
Result
I am italic here
NotesGenerally speaking, this is meant to be used to create empty elements that are subsequently populated via Javascript. However, the text argument will be evaluated as wikitext so you can insert content directly, if desired.

Use an empty string to leave an attribute undefined.


echo
Usage<<echo arg arg ...>>
DescriptionEcho back input arguments. Arguments are wikified just as if they were inline.
Example<<echo "//Hello//-" world '''-__macro__'''>>
ResultHello-world-macro


echos
Usage<<echos arg arg ...>>
DescriptionLike echo but adds a space between arguments.
Example<<echos "AAA" BBB '''CCC'''>>
ResultAAA BBB CCC


get
Usage<<get name>>
DescriptionGet the wikitext stored in the named variable (from an earlier call to <<set>>).
Example<<set TestVar "Some __text__ ''here''">>

<<get TestVar>>
ResultSome text here


help
Usage<<help>>
DescriptionGenerates this help text.
Example<<help>>
ResultYou're looking at it!


if_full_mode
Usage<<if_full_mode arg arg ...>>
DescriptionIf running in Full Mode, return wikified args, else return nothing.
Example<<if_full_mode "Hello ''Full Mode''">>
ResultHello Full Mode


if_safe_mode
Usage<<if_safe_mode arg arg ...>>
DescriptionIf running in Safe Mode, return wikified args, else return nothing.
Example<<if_safe_mode "Hello ''Safe Mode''">>
Result


include (Full Mode only)
Usage<<include filename>>
DescriptionInclude the entire contents of a file (contents will be parsed as wiki text).
The included file is allowed to have a different text encoding than the current file.
Example
''An ASCII encoded file:'' <<include "doc/mbsamples/english.txt">>
''An ISO-8859-7 (Greek) encoded file:'' <<include "doc/mbsamples/greek.txt">>
ResultAn ASCII encoded file: English (ASCII): Hello world!
An ISO-8859-7 (Greek) encoded file: Greek (ISO-8859-7): Γεια σου, κόσμε!



include_code (Full Mode only)
Usage<<include_pyfunc filename title>>
DescriptionInclude a file as a block of code (as if it were included inside {{{ .. }}}). Searches in sys.path and '.' if absolute path not given. title is the title for the box. If not given it defaults to filename.
Example<<include_code doc/sample.py>>
ResultERROR - No such file or resource "doc/sample.py"


include_pyfunc (Full Mode only)
Usage<<include_pyfunc modulename funcname title>>
DescriptionInclude the source code for a single Python function from the named module. Module must be in sys.path or '.'. title is the title for the box. If not given it defaults to modulename.funcname().
Example<<include_pyfunc atexit register>>
Result
atexit.register()
def register(func, *targs, **kargs):
    """register a function to be executed upon normal program termination

    func - function to be called at exit
    targs - optional arguments to pass to func
    kargs - optional keyword arguments to pass to func
    """
    _exithandlers.append((func, targs, kargs))


include_pymod (Full Mode only)
Usage<<include_pymod modulename title>>
DescriptionInclude the source code for a Python module. Module must be in sys.path or '.'. title is the title for the box. If not given it defaults to modulename.
Example<<include_pymod statvfs "A Title">>
Result
A Title
"""Constants for interpreting the results of os.statvfs() and os.fstatvfs()."""

# Indices for statvfs struct members in the tuple returned by
# os.statvfs() and os.fstatvfs().

F_BSIZE   = 0           # Preferred file system block size
F_FRSIZE  = 1           # Fundamental file system block size
F_BLOCKS  = 2           # Total number of file system blocks (FRSIZE)
F_BFREE   = 3           # Total number of free blocks
F_BAVAIL  = 4           # Free blocks available to non-superuser
F_FILES   = 5           # Total number of file nodes
F_FFREE   = 6           # Total number of free file nodes
F_FAVAIL  = 7           # Free nodes available to non-superuser
F_FLAG    = 8           # Flags (see your local statvfs man page)
F_NAMEMAX = 9           # Maximum file name length


indent
Usage<<indent arg arg ...>>
DescriptionDo a block indent, preserving all other formatting. Functionally, this is the same as:
{{indent{ ... }}}

... but sometimes a macro is more convenient.
ExampleNext line<br><<indent 'is indented'>>
ResultNext line
is indented


info
This is an alias for <<infobox>>.
Example<<info "Hello title" Hello " " content>>
Result
Hello title
Hello content


infobox
Usage<<infobox title content [...]>>
<<infobox content>>
DescriptionFirst form: Create an information box with a title.
Second form: Create a box with no title.
Example<<infobox "A Title" AA BB CC " and //italic text//">>
<<infobox "This box has no title and uses a ''different'' __style__.">>
Result
A Title
AABBCC and italic text

This box has no title and uses a different style.


note
Usage<<note text>>
DescriptionCreate a simple note box without a title.
Example<<note "Here is a note with //italic text// and ''bold text''.">>
Result
Here is a note with italic text and bold text.


py_add_path (Full Mode only)
Usage<<py_add_path path>>
DescriptionAdd the given path to sys.path. This is useful when you want to use include_code, include_pyfunc or include_pymod on a module in an arbitrary location.
Example<<set TestVar "Some __text__ ''here''">>
ResultNo return value.


set
Usage<<set name arg arg ... >>
DescriptionCreate a named variable containing the given wiki text. The text is evaluated (just as if it was inline) and stored. It can be retrieved later with get().

NOTE: Names beginning with $ are reserved for system use.
Example<<set TestVar "Some __text__ ''here''">>
ResultNo return value.


span (Full Mode only)
Usage<<span class style id text>>
DescriptionCreate an inline element (like <span>).
Example<<span "foo" "color:red; font-weight: bold;" "id456" "I am //italic// here">>
ResultI am italic here
NotesGenerally speaking, this is meant to be used to create empty elements that are subsequently populated via Javascript. However, the text argument will be evaluated as wikitext so you can insert content directly, if desired.

Use an empty string to leave an attribute undefined.


version
Usage<<version>>
DescriptionGet the WikklyText version number.
Example<<version>>
Result1.5.0


warn
This is an alias for <<warnbox>>.
Example<<warn "Hello title" Hello " " content>>
Result
Hello title
Hello content


warnbox
Usage<<warnbox title content [...]>>
<<warnbox content>>
DescriptionFirst form: Create an warning box with a title.
Second form: Create a box with no title.
Example<<warnbox "A Title" AA BB CC " and //italic text//">>
<<warnbox "This box has no title and uses a ''different'' __style__.">>
Result
A Title
AABBCC and italic text

This box has no title and uses a different style.