Trace: • page
The New Page
This is the new page
<html> <body> blah </body> </html>
Another test. The following content was created by an OpenOffice macro:
Iannz DokuWiki macro
Try the demo
The demo will:
- Create a new document that is the equivalent of this document in DokuWiki format. See http://www.splitbrain.org/dokuwiki/wiki:dokuwiki;
- Insert that string into a new document;
- Copy the contents of the new document;
- (Close the new document - currently the closing has been commented out).
Click this button .
What gets converted
Character Formatting
Bold, italics, underline, strike-through, mono spaced fonts, superscript and subscript all get mapped to DokuWiki equivalents. Any other character formatting is lost. The conversion is not as elegant as it could be as it will produce for “bold bold & italic”:
**bold **//**bold & italic**// rather than **bold //bold & italic//**.
Paragraph formatting
Outline levels
Outline levels 1-5 get mapped the DokuWiki equivalents. Higher outline levels are ignored although if the style uses the above character formats they should get transferred across. Any formatting within an outline level 1-5 paragraph is ignored.
Bulleted and numbered lists
Bulleted and numbered lists get transferred to the DokuWiki equivalent, with the level of the list determining the amount of indentation. As there is no choice of bullets or numbering schemes in DokuWiki the lists are very simple indeed.
I suspect that breaks in numbered lists will simply restart at 1 in DokuWiki.
Bottom border
If a paragraph is formatted with a bottom border then a DokuWiki horizontal line will be inserted.
Other paragraph formatting
All other paragraph formatting is ignored.
Frames which are anchored to or as characters
The name of the frame will be inserted into the DokuWiki command: {{wiki:FrameName}}
, where FrameName is the name of the frame as shown in the navigator. If the frame has no name then it is ignored. You will need to upload the graphic file manually, using your browser. See http://software.newsforge.com/article.pl?sid=05/01/06/1511255&tid=130&tid=93&tid=13.
Tables
Simple tables should transfer OK. Where there is more than one paragraph in the cell, it is the alignment of the last paragraph that determines the alignment for the cell. Horizontally merged cells should work ok. The tables do not look pretty in the DokuWiki format but seem to render ok in DokuWiki itself.
Cells with paragraph style “Table Heading” will get prefixed with “^” so that they get rendered as headings.
Heading One | Heading Two |
This too is a heading. | But this is not. |
Links
Hyperlinks should get transferred - this probably needs improving. Currently any formatting within a hyperlink will cause the hyperlink to be repeated in the DokuWiki document.
So that it is possible to copy a rendered page from a DokuWiki site, any hyperlinks that have “doku.php?id=” in them will be treated as internal links. I don't check to convert double square brackets to literals so anything in double square brackets should simply go into the DokuWiki document - beware if you don't have your double square brackets matched the rendering will not work as expected.
Quotes
Smart quotes get converted to ordinary quotes.
Anything else
Anything else is simply ignored.
Literals
I have tried to check for formatting commands within the document so that they get converted to literals. One that I haven't checked for is spaces at the start of a paragraph, so paragraphs with spaces at the start should be rendered literally. Nor have I checked for the literals themseleves the double percentage signs.
Code
Any paragraphs with a style name that includes the text “code” will be enclosed with ”<code xxx> … </code>” tags. Where xxx can correspond to one of, if the corresponding string appears in the style name after the text “code” : “actionscript”, “ada”, “apache”, “asm”, “asp”, “bash”, “caddcl”, “cadlisp”, “c_mac”, “cpp”, “csharp”, “css”, “delphi”, “html4strict”, “javascript”, “java”, “lisp”, “lua”, “nsis”, “objc”, “oobas”, “pascal”, “perl”, “php-brief”, “php”, “python”, “qbasic”, “smarty”, “sql”, “vbnet”, “vb”, “visualfoxpro”, “xml”, or “c”.
E.g. Paragraph style name = “code_oobas” will produce the tags ”<code oobas> … </code>”.
sub HelloWorld msgbox "Hello World" end sub
So that text can be copied from DokuWiki rendered web pages into Writer and then the macro run, the paragraph style name “Preformatted Text” will also assign the tags ”<code oobas> … </code>”. I chose “oobas” as the default as that is what I mostly use .
For programmers
There is also a sub called Folders, that converts all ”.html” files in the specified directory tree to DokuWiki txt files. I suggest only running this on a copy of your files, and to check it for your needs first. The files that I was converting had very few graphics so I haven't worried about automating them other than the process mentioned above.
Installing
Adding the library
This is so that the macro will be available for use when required
- Tools > Macros > Macro… > Organizer > Libraries
- Ensure that sOffice is selected for Application/Document
- Click Append…
- Navigate to where this file is stored and select it, click Open
- Uncheck “Standard” but ensure “modDokuWiki” is checked
- If updating from an old version check “Replace existing libraries”
- Close, Close
Adding a menu entry
This is so that the macro integrates with OpenOffice.org Writer so that it appears seamlessly a part of it.
- Tools > Configure… > Menu
- Select desired location in the top list box (”~Copy” is probably a good place)
- In the category list box: Click the + next to “OpenOffice.org BASIC Macros” (towards bottom of list), the plus next to “dokuWiki”, then click “DokuWiki”.
- In the function list box: Click “DokuWiki”
- Click the New button (top right of dialog)
- Click OK
Thanks
Thanks to Dmitri Popov for requesting this macro and being patient with me while I worked on other things. And Andreas Gohr for writing DokuWiki in the first place.
Copyright
Copyright © 2004 Ian Laurenson
Anyone may run the code associated with this document. If you wish to modify or distribute this document and or its code, then you are granted a license to do so under the terms of the Gnu Lesser General Public License. See: http://www.gnu.org/licenses/lgpl.html.
Author contact
Send comments, bug fixes, change requests etc to hillview@paradise.net.nz