Creole Plugin

creole plugin by Gina Häußge, Michael Klier
Creole is an initiative to bring a common basic set of wiki markup to different wiki engines. (previous author: Esther Brunner)

Last updated on 2008-02-12. Provides Syntax.
Compatible with DokuWiki 2006-11-06.

Tagged with creole, syntax, wiki.

Download plugin-creole.tgz

Description

The Creole 0.3 Specs (2006-12-19) are very close to the syntax used by DokuWiki. Only those elements differ:

This Plugin will interpret Creole elements that are not understood by DokuWiki. If the markup collides (as with the header level order), by default DokuWiki's standard markup takes precedence.1) With the exception of the changed behaviour for linebreaks, all your existing wiki pages will look the same.

If you use this plugin to support the Creole syntax, you might want to list your wiki at http://www.wikicreole.org/wiki/WikisSupportingCreole

Components

Listblock

Creole style ordered and unordered lists use a slightly different markup:

Creole (and DokuWiki):

* Item 1          (  * Item 1     )
** Item 1.1       (    * Item 1.1 )
* Item 2          (  * Item 2     )

Output:

  • Item 1
    • Item 1.1
  • Item 2

Creole (and DokuWiki):

# Item 1          (  - Item 1     )
## Item 1.1       (    - Item 1.1 )
# Item 2          (  - Item 2     )

Output:

  1. Item 1
    1. Item 1.1
  2. Item 2

Headings

In Creole, the header ordering is just the other way round. If you have set the markup precedence option to DokuWiki (default), this plugin will assume headers are DokuWiki style if there are equal signs after the title. In Creole, closing (right-side) equal signs are optional. So if omit them, headers are interpreted as Creole.

Creole (and DokuWiki):

= Level 1        (====== Level 1 ======)
== Level 2       (===== Level 2 =====  )
=== Level 3      (==== Level 3 ====    )
==== Level 4     (=== Level 4 ===      )
===== Level 5    (== Level 5 ==        )

Output:

Level 1

Level 2

Level 3

Level 4

Level 5

Linebreaks

DokuWiki does not care about (single) line breaks. Creole, however, does treat line breaks in the source as line breaks in the output.

This component is mainly the same as Chris Smith's linebreak plugin. Thanks!

Preformatted

Creole:

{{{
//This// does **not** get [[formatted]]
}}}

Some examples of markup are: {{{** <i>this</i> ** }}}

Output:

//This// does **not** get [[formatted]]

Some examples of markup are: ** <i>this</i> **

Tables

Creole (and DokuWiki):

|Heading Col 1  |Heading Col 2 |   (^Heading Col 1  ^Heading Col 2 ^)
|Cell 1.1       |Cell 1.2      |   (|Cell 1.1       |Cell 1.2      |)
|Cell 2.1       |Cell 2.2      |   (|Cell 2.1       |Cell 2.2      |)

Output:

Heading Col 1 Heading Col 2
Cell 1.1 Cell 1.2
Cell 2.1 Cell 2.2

The difference to DokuWiki is that in Creole there's no special markup for header cells and no cell alignment. In turn, in Creole the ending pipe is optional.

Bugs

Please report bugs at the Bug tracker.

Further Resources

Todo

  • make toolbar work
  • update to Creole 1.0 specs

Discussion

Very nice! The image notation in the Creole Markup however conflicts with the syntax for plugins in DokuWiki. If DokuWiki is planning to change at some point in time to Creole, it might be wise to switch to the proposed 'internal markup' style «x» for plugins. For anyone to use this plugin, a modification of the toolbar would be needed; do I have to change the toolbar manually or could the plugin be able to override the inserted syntax? Also, is there any converter for existing wiki pages? — Niklas 2006-12-19 09:16

I don't know if a plugin can override the toolbar code, but I hard-coded reversed headings some time ago using these tips. With the Creole plugin installed, all you have to change is the headings section in toolbar.php (to get an idea: look here.
As for the converter: I once thought about writing a little script, but then decided to make it by hand. But if you want to do so. It should be relatively easy: Just go trough the text of each of your pages (with old syntax) and replace each occurrence of a headline with a unique symbol (like '======' → 'XXXH1XXX', '=====' → 'XXXH2XXX' …). Then you go through the text again and replace your unique identifiers with the new syntax ('XXXH1XXX' → '==', 'XXXH2XXX → '===' …). By going through the text twice, you avoid conflicts of old and new headline syntax.
As for the other syntax changes: You don't have to change anything, as DW understands both old and new syntax for lists and no-wiki. — konstantin baierer 2006-12-19 15:47
Good point about the replacement. The reverse header tags page is only semi-useful to me: I really don't want to patch a single line of code, I only want to use plugins that can be installed via the plugin manager. The reason is that even though I am setting up the wiki and hacking around is no problem at akk, I won't be the one maintaining it in the future, so I should and will not assume that the future maintainer will be able to cope with actual source code. Niklas 2006-12-19 23:32
Hi Niklas and Konstantin. With an additional event hook in inc/toolbar.php, it would finally be possible for plugins to modify the toolbar. Let's ask Andi and the other developers whether they are open for this idea. — Esther Brunner 2006-12-20 00:53
As I had to make a fresh installation today, I wrote that script mentioned above in Perl. It reverses all header tags from DokuWiki to Creole notation for a file given as argument.
#!/usr/bin/perl -w
# revheaders
# Convert DokuWiki headers to Creole headers
 
foreach (@ARGV) {
    $original = $metaformat = '';
    $filename = $_;
    open WIKIPAGE, ("<$filename");
    while (<WIKIPAGE>){
        $original .= $_;
        $_ =~ s/^======(.*)+?(======)/Xh1hX$1/g;
        $_ =~ s/^=====(.*)+?(=====)/Xh2hX$1/g;
        $_ =~ s/^====(.*)+?(====)/Xh3hX$1/g;
        $_ =~ s/^===(.*)+?(===)/Xh4hX$1/g;
        $_ =~ s/^==(.*)+?(==)/Xh5hX$1/g;
        $metaformat.= $_;
    }
    $metaformat =~ s/^Xh1hX(.*)/==$1==/gm;
    $metaformat =~ s/^Xh2hX(.*)/===$1===/gm;
    $metaformat =~ s/^Xh3hX(.*)/====$1====/gm;
    $metaformat =~ s/^Xh4hX(.*)/=====$1=====/gm;
    $metaformat =~ s/^Xh5hX(.*)/======$1======/gm;
    open BACKUP, ">$filename.BAK";
    print BACKUP $original;
    open WIKIPAGE, (">$filename");
    print WIKIPAGE $metaformat;
}
The original file is overwritten, a backup is made to oldname.BAK.
If you want to convert a single file, just type perl revheaders FILENAME. To rename a whole directory, go to the base of it and type find . -regex '.*txt' | xargs perl revheaders. That will convert all .txt-files in this and all subsequent folders. If you want to undo your changes, just run the script again with the same file(s). It's especially useful to mass rename the built-in wiki pages in /inc/lang/. — konstantin baierer 2007-03-31 22:27

Thank you, for this very nice plugin. — Rick Companje 2007-12-20 17:52

Wanted to point out that going to Creole 1.0 is not a big leap. I wrote a couple additions for the Creole 1.0 Additions of subscript ( ,, )and strikeout ( – ). Took a couple minutes, can't get superscript to work ( ^^ ) regardless of sort, always get intercepted as a table. even updated the toolbar to support the new syntax. – Brian Hartvigsen 2008-02-23 13:27

I actually got superscript and the new table header syntax working. The later is probably a dirty hack, but it works ;-)Brian Hartvigsen 2008-02-23 13:27
Nice, if you don't mind sharing your work patches are always welcome. Just got the mail :-). — Michael Klier 2008-02-24 11:42
1) You can change the markup precedence to Creole with the config manager, if you want full Creole support.
 
plugin/creole.txt · Last modified: 2009/01/03 01:43 by 70.103.232.219
 

Except where otherwise noted, content on this wiki is licensed under the following license: CC Attribution-Noncommercial-Share Alike 3.0 Unported

Imprint Recent changes RSS feed Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki
WikiForumIRCBugsDarcsXRefTranslate