Anpassungen für neue Moin Version
This commit is contained in:
parent
8117b6a1e2
commit
eb469fe356
10 changed files with 617 additions and 345 deletions
2
doku.php
2
doku.php
|
@ -13,7 +13,7 @@
|
||||||
|
|
||||||
if ('cli' != php_sapi_name()) die();
|
if ('cli' != php_sapi_name()) die();
|
||||||
|
|
||||||
define('DOKU_INC', '/usr/share/dokuwiki/');
|
define('DOKU_INC', '/home/caddy/wikifarm/dokuwiki/dokuwiki/');
|
||||||
require_once DOKU_INC.'inc/init.php';
|
require_once DOKU_INC.'inc/init.php';
|
||||||
require_once DOKU_INC.'inc/common.php';
|
require_once DOKU_INC.'inc/common.php';
|
||||||
require_once DOKU_INC.'inc/cliopts.php';
|
require_once DOKU_INC.'inc/cliopts.php';
|
||||||
|
|
BIN
doku.pyc
Normal file
BIN
doku.pyc
Normal file
Binary file not shown.
10
moin2doku.py
10
moin2doku.py
|
@ -9,9 +9,10 @@
|
||||||
# Version: 1.0
|
# Version: 1.0
|
||||||
|
|
||||||
import sys, os, os.path, re, codecs
|
import sys, os, os.path, re, codecs
|
||||||
|
sys.path.insert(1,'/home/caddy/.conda/envs/moinmoin/lib/python2.7/site-packages/MoinMoin/support')
|
||||||
import getopt
|
import getopt
|
||||||
from MoinMoin import user, wikiutil
|
from MoinMoin import user, wikiutil
|
||||||
from MoinMoin.request import RequestCLI
|
from MoinMoin.web.contexts import ScriptContext as RequestCLI
|
||||||
from MoinMoin.logfile import editlog
|
from MoinMoin.logfile import editlog
|
||||||
from MoinMoin.Page import Page
|
from MoinMoin.Page import Page
|
||||||
from shutil import copyfile, copystat
|
from shutil import copyfile, copystat
|
||||||
|
@ -40,8 +41,8 @@ def init_dirs(output_dir):
|
||||||
mkdir(metadir)
|
mkdir(metadir)
|
||||||
|
|
||||||
def readfile(filename):
|
def readfile(filename):
|
||||||
with open(filename, 'r') as f:
|
f = open(filename, 'r')
|
||||||
text = f.read()
|
text = f.read()
|
||||||
return unicode(text.decode('utf-8'))
|
return unicode(text.decode('utf-8'))
|
||||||
|
|
||||||
def writefile(filename, content, overwrite=False):
|
def writefile(filename, content, overwrite=False):
|
||||||
|
@ -50,7 +51,7 @@ def writefile(filename, content, overwrite=False):
|
||||||
os.makedirs(dir);
|
os.makedirs(dir);
|
||||||
|
|
||||||
if os.path.exists(filename) and overwrite == False:
|
if os.path.exists(filename) and overwrite == False:
|
||||||
raise OSError, 'File already exists: %s' % filename
|
raise (OSError, 'File already exists: %s' % filename)
|
||||||
|
|
||||||
# ensure it's a list
|
# ensure it's a list
|
||||||
if not isinstance(content, (list, tuple)):
|
if not isinstance(content, (list, tuple)):
|
||||||
|
@ -294,6 +295,7 @@ else:
|
||||||
# get list of all pages in wiki
|
# get list of all pages in wiki
|
||||||
# hide underlay dir temporarily
|
# hide underlay dir temporarily
|
||||||
underlay_dir = request.rootpage.cfg.data_underlay_dir
|
underlay_dir = request.rootpage.cfg.data_underlay_dir
|
||||||
|
print(underlay_dir)
|
||||||
request.rootpage.cfg.data_underlay_dir = None
|
request.rootpage.cfg.data_underlay_dir = None
|
||||||
pages = request.rootpage.getPageList(user = '', exists = not convert_attic, filter = filter)
|
pages = request.rootpage.getPageList(user = '', exists = not convert_attic, filter = filter)
|
||||||
pages = dict(zip(pages, pages))
|
pages = dict(zip(pages, pages))
|
||||||
|
|
|
@ -7,13 +7,13 @@
|
||||||
#
|
#
|
||||||
# Author: Elan Ruusamäe <glen@pld-linux.org>
|
# Author: Elan Ruusamäe <glen@pld-linux.org>
|
||||||
# Version: 1.0
|
# Version: 1.0
|
||||||
|
#from MoinMoin.web.request import Request as RequestCLI
|
||||||
from MoinMoin import wikimacro, wikiutil
|
from MoinMoin.web.contexts import ScriptContext
|
||||||
|
from MoinMoin import wikiutil
|
||||||
from MoinMoin.Page import Page
|
from MoinMoin.Page import Page
|
||||||
from MoinMoin.parser.wiki import Parser
|
from MoinMoin.parser.text_moin_wiki import Parser
|
||||||
|
|
||||||
from text_dokuwiki import Formatter
|
from text_dokuwiki import Formatter
|
||||||
from MoinMoin.request import RequestCLI
|
|
||||||
|
|
||||||
import sys
|
import sys
|
||||||
import StringIO
|
import StringIO
|
||||||
|
@ -37,7 +37,7 @@ def moin2doku(pagename, text):
|
||||||
|
|
||||||
return unicode(output.getvalue().decode('utf-8'))
|
return unicode(output.getvalue().decode('utf-8'))
|
||||||
|
|
||||||
request = RequestCLI()
|
request = ScriptContext()
|
||||||
formatter = Formatter(request)
|
formatter = Formatter(request)
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
@ -47,6 +47,6 @@ if __name__ == "__main__":
|
||||||
else:
|
else:
|
||||||
inputfile = 'syntaxreference.txt'
|
inputfile = 'syntaxreference.txt'
|
||||||
|
|
||||||
with open(inputfile, 'r') as f:
|
f = open(inputfile, 'r')
|
||||||
text = f.read()
|
text = f.read()
|
||||||
print moin2doku('test', text)
|
print moin2doku('test', text)
|
||||||
|
|
BIN
moinformat.pyc
Normal file
BIN
moinformat.pyc
Normal file
Binary file not shown.
238
output.txt
Normal file
238
output.txt
Normal file
|
@ -0,0 +1,238 @@
|
||||||
|
|
||||||
|
|
||||||
|
<file>#pragma section-numbers off
|
||||||
|
#acl All:admin,read,write,delete,revert
|
||||||
|
#language en</file>
|
||||||
|
This page tries to use each supported markup element at least once.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<file>'''Index'''
|
||||||
|
[[TableOfContents(2)]]</file>
|
||||||
|
**Index**
|
||||||
|
|
||||||
|
[[:TableOfContents(2)|TableOfContents(2)]]
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
====== Headers ======
|
||||||
|
|
||||||
|
|
||||||
|
===== Header 2 =====
|
||||||
|
|
||||||
|
|
||||||
|
==== Header 3 ====
|
||||||
|
|
||||||
|
|
||||||
|
=== Header 4 ===
|
||||||
|
|
||||||
|
|
||||||
|
== Header 5 ==
|
||||||
|
|
||||||
|
|
||||||
|
====== Font styles ======
|
||||||
|
|
||||||
|
|
||||||
|
<file>Normal text, ''emphasized'', '''strong''', __underline__, ,,subscript,,, ^superscript^, `typewriter` and {{{typewriter</file>
|
||||||
|
.}}}
|
||||||
|
|
||||||
|
Normal text, //emphasized//, **strong**, __underline__, <sub>subscript</sub>, <sup>superscript</sup>, ''typewriter'' and ''typewriter''.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
===== Syntax Highlighting =====
|
||||||
|
|
||||||
|
* <code >
|
||||||
|
# python code
|
||||||
|
print code.colorize("abc", 1 + 1)</code>
|
||||||
|
|
||||||
|
|
||||||
|
====== Hyperlinks ======
|
||||||
|
|
||||||
|
|
||||||
|
===== Internal =====
|
||||||
|
|
||||||
|
|
||||||
|
<file> * MoinMoin
|
||||||
|
* MoinMoin/TextFormatting
|
||||||
|
* MoinMoin/InstallDocs
|
||||||
|
* ../InstallDocs
|
||||||
|
* /SubPage
|
||||||
|
* Self:InterWiki</file>
|
||||||
|
|
||||||
|
* [[:MoinMoin|MoinMoin]]
|
||||||
|
* [[:MoinMoin:TextFormatting|MoinMoin/TextFormatting]]
|
||||||
|
* [[:MoinMoin:InstallDocs|MoinMoin/InstallDocs]]
|
||||||
|
* [[:InstallDocs|../InstallDocs]]
|
||||||
|
* [[:test:SubPage|/SubPage]]
|
||||||
|
* [[:InterWiki|InterWiki]]
|
||||||
|
|
||||||
|
|
||||||
|
<file>[#anchorname Anchor Link]</file>
|
||||||
|
[#anchorname Anchor Link]
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
===== External =====
|
||||||
|
|
||||||
|
|
||||||
|
<file> * http://moinmoin.wikiwikiweb.de/
|
||||||
|
* [http://moinmoin.wikiwikiweb.de/]
|
||||||
|
* [http://moinmoin.wikiwikiweb.de/ MoinMoin Wiki]
|
||||||
|
* [http://moinmoin.wikiwikiweb.de/wiki/classic/img/moinmoin.png]
|
||||||
|
* http://moinmoin.wikiwikiweb.de/wiki/classic/img/moinmoin.png
|
||||||
|
* [http://moinmoin.wikiwikiweb.de/wiki/classic/img/moinmoin.png moinmoin.png]
|
||||||
|
* MeatBall:InterWiki
|
||||||
|
* wiki:MeatBall/InterWiki
|
||||||
|
* [wiki:MeatBall/InterWiki]
|
||||||
|
* [wiki:MeatBall/InterWiki InterWiki page on MeatBall]
|
||||||
|
* [file://servername/full/path/to/file/filename%20with%20spaces.txt Click here to read filename with spaces.txt]
|
||||||
|
* me@privacy.net</file>
|
||||||
|
|
||||||
|
* [[http://moinmoin.wikiwikiweb.de/|http://moinmoin.wikiwikiweb.de/]]
|
||||||
|
* [[[http://moinmoin.wikiwikiweb.de/|http://moinmoin.wikiwikiweb.de/]]]
|
||||||
|
* [[[http://moinmoin.wikiwikiweb.de/|http://moinmoin.wikiwikiweb.de/]] [[:MoinMoin|MoinMoin]] Wiki]
|
||||||
|
* [[[http://moinmoin.wikiwikiweb.de/wiki/classic/img/moinmoin.png|http://moinmoin.wikiwikiweb.de/wiki/classic/img/moinmoin.png]]]
|
||||||
|
* [[http://moinmoin.wikiwikiweb.de/wiki/classic/img/moinmoin.png|http://moinmoin.wikiwikiweb.de/wiki/classic/img/moinmoin.png]]
|
||||||
|
* [[[http://moinmoin.wikiwikiweb.de/wiki/classic/img/moinmoin.png|http://moinmoin.wikiwikiweb.de/wiki/classic/img/moinmoin.png]] moinmoin.png]
|
||||||
|
* [[MeatBall>InterWiki|InterWiki]]
|
||||||
|
* wiki:[[:MeatBall:InterWiki|MeatBall/InterWiki]]
|
||||||
|
* [wiki:[[:MeatBall:InterWiki|MeatBall/InterWiki]]]
|
||||||
|
* [wiki:[[:MeatBall:InterWiki|MeatBall/InterWiki]] [[:InterWiki|InterWiki]] page on [[:MeatBall|MeatBall]]]
|
||||||
|
* [[[file://servername/full/path/to/file/filename%20with%20spaces.txt|file://servername/full/path/to/file/filename%20with%20spaces.txt]] Click here to read filename with spaces.txt]
|
||||||
|
* [[mailto:me@privacy.net|me@privacy.net]]
|
||||||
|
|
||||||
|
|
||||||
|
===== Escaping WikiNames =====
|
||||||
|
|
||||||
|
|
||||||
|
<file>Wiki''''''Name
|
||||||
|
Wiki``Name</file>
|
||||||
|
Wiki****Name Wiki''''Name
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
====== Blockquote ======
|
||||||
|
|
||||||
|
|
||||||
|
<file> This is indented
|
||||||
|
Even more</file>
|
||||||
|
|
||||||
|
* This is indented
|
||||||
|
* Even more
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
====== Bullet list ======
|
||||||
|
|
||||||
|
|
||||||
|
<file> * item 1
|
||||||
|
|
||||||
|
* item 2, with gap
|
||||||
|
* item 3
|
||||||
|
* item 3.1</file>
|
||||||
|
|
||||||
|
* item 1
|
||||||
|
* item 2, with gap
|
||||||
|
* item 3
|
||||||
|
* item 3.1
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
====== Numbered list ======
|
||||||
|
|
||||||
|
|
||||||
|
<file> 1. item 1
|
||||||
|
i. item 1
|
||||||
|
i. item 2</file>
|
||||||
|
|
||||||
|
- item 1
|
||||||
|
- item 1
|
||||||
|
- item 2
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<file> 1. item 2
|
||||||
|
a. item 1
|
||||||
|
a. item 2</file>
|
||||||
|
|
||||||
|
- item 2
|
||||||
|
- item 1
|
||||||
|
- item 2
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
====== Descriptions + Definitions ======
|
||||||
|
|
||||||
|
|
||||||
|
<file> Term:: Description
|
||||||
|
Label:: Definition</file>
|
||||||
|
<gloss><label>Term</label><item>Description </item><label>Label</label><item>Definition </item></gloss>
|
||||||
|
|
||||||
|
====== Code display ======
|
||||||
|
|
||||||
|
* <file>line 1
|
||||||
|
indented 4 characters</file>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
====== Tables ======
|
||||||
|
|
||||||
|
|
||||||
|
===== General table layout and HTML like options =====
|
||||||
|
|
||||||
|
|
||||||
|
<file> ||cell 1||cell2||cell 3||</file>
|
||||||
|
|
||||||
|
*
|
||||||
|
|cell 1|cell2|cell 3|
|
||||||
|
|
||||||
|
|
||||||
|
====== Rules ======
|
||||||
|
|
||||||
|
|
||||||
|
<file>--- (not a rule)
|
||||||
|
----
|
||||||
|
-----
|
||||||
|
------
|
||||||
|
-------
|
||||||
|
--------
|
||||||
|
---------
|
||||||
|
----------
|
||||||
|
-------------------------------------------- (not thicker than 10)</file>
|
||||||
|
--- (not a rule)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
-
|
||||||
|
|
||||||
|
|
||||||
|
--
|
||||||
|
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
|
||||||
|
----
|
||||||
|
|
||||||
|
|
||||||
|
----
|
||||||
|
|
||||||
|
|
||||||
|
----
|
||||||
|
|
||||||
|
|
||||||
|
----
|
||||||
|
(not thicker than 10)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
====== Macros ======
|
||||||
|
|
||||||
|
|
||||||
|
<file>[[Anchor(anchorname)]]
|
||||||
|
'''[[PageCount]]''' pages</file>
|
||||||
|
[[:Anchor(anchorname)|Anchor(anchorname)]] **[[:PageCount|PageCount]]** pages
|
||||||
|
|
||||||
|
|
22
standalone.py
Normal file
22
standalone.py
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
from MoinMoin.server.standalone import StandaloneConfig, run
|
||||||
|
|
||||||
|
import sys
|
||||||
|
# Path of the directory where wikiconfig.py is located.
|
||||||
|
# YOU NEED TO CHANGE THIS TO MATCH YOUR SETUP.
|
||||||
|
sys.path.insert(0, 'home/caddy/wikifarm/var/wikifarm/config')
|
||||||
|
|
||||||
|
# Path to MoinMoin package, needed if you installed with --prefix=PREFIX
|
||||||
|
# or if you did not use setup.py.
|
||||||
|
sys.path.insert(0, '/usr/local/lib/python2.4/site-packages')
|
||||||
|
|
||||||
|
# Path of the directory where farmconfig.py is located (if different).
|
||||||
|
sys.path.insert(0, '/home/caddy/wikifarm/var/wikifarm/config')
|
||||||
|
|
||||||
|
class Config(StandaloneConfig):
|
||||||
|
docs = '/home/caddy/wikifarm/var/wikifarm'
|
||||||
|
user = 'http'
|
||||||
|
group = 'http'
|
||||||
|
port = 80
|
||||||
|
|
||||||
|
run(Config)
|
||||||
|
|
|
@ -182,4 +182,4 @@ line 1
|
||||||
'''[[PageCount]]''' pages
|
'''[[PageCount]]''' pages
|
||||||
}}}
|
}}}
|
||||||
[[Anchor(anchorname)]]
|
[[Anchor(anchorname)]]
|
||||||
'''[[PageCount]]''' pages
|
'''[[PageCount]]''' pages
|
674
text_dokuwiki.py
674
text_dokuwiki.py
|
@ -1,15 +1,15 @@
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
# Setup VIM: ex: noet ts=2 sw=2 :
|
# Setup VIM: ex: noet ts=2 sw=2 :
|
||||||
"""
|
"""
|
||||||
MoinMoin - Dokuwiki Formatter
|
MoinMoin - Dokuwiki Formatter
|
||||||
|
|
||||||
@copyright: 2000, 2001, 2002 by Jürgen Hermann <jh@web.de>
|
@copyright: 2000, 2001, 2002 by Jürgen Hermann <jh@web.de>
|
||||||
@copyright: 2011-2012 Elan Ruusamäe <glen@delfi.ee>
|
@copyright: 2011-2012 Elan Ruusamäe <glen@delfi.ee>
|
||||||
@license: GNU GPL, see COPYING for details.
|
@license: GNU GPL, see COPYING for details.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from xml.sax import saxutils
|
from xml.sax import saxutils
|
||||||
from MoinMoin.formatter.base import FormatterBase
|
from MoinMoin.formatter import FormatterBase
|
||||||
from MoinMoin import config
|
from MoinMoin import config
|
||||||
from MoinMoin.Page import Page
|
from MoinMoin.Page import Page
|
||||||
from types import *
|
from types import *
|
||||||
|
@ -17,330 +17,340 @@ from types import *
|
||||||
# TODO: let base class MoinMoin/formatter/base.py handle not implemented methods
|
# TODO: let base class MoinMoin/formatter/base.py handle not implemented methods
|
||||||
|
|
||||||
class Formatter(FormatterBase):
|
class Formatter(FormatterBase):
|
||||||
"""
|
"""
|
||||||
Send Dokuwiki formatted data.
|
Send Dokuwiki formatted data.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
hardspace = ' '
|
hardspace = ' '
|
||||||
# hardspace = ' '
|
# hardspace = ' '
|
||||||
|
|
||||||
def __init__(self, request, **kw):
|
def __init__(self, request, **kw):
|
||||||
apply(FormatterBase.__init__, (self, request), kw)
|
apply(FormatterBase.__init__, (self, request), kw)
|
||||||
self._current_depth = 1
|
self._current_depth = 1
|
||||||
self._base_depth = 0
|
self._base_depth = 0
|
||||||
self.in_pre = 0
|
self.in_pre = 0
|
||||||
self.in_table = 0
|
self.in_table = 0
|
||||||
self._text = None # XXX does not work with links in headings!!!!!
|
self._text = None # XXX does not work with links in headings!!!!!
|
||||||
|
|
||||||
self.list_depth = 0
|
self.list_depth = 0
|
||||||
self.list_type = ' '
|
self.list_type = ' '
|
||||||
|
|
||||||
def _escape(self, text, extra_mapping={"'": "'", '"': """}):
|
def _escape(self, text, extra_mapping={"'": "'", '"': """}):
|
||||||
return saxutils.escape(text, extra_mapping)
|
return saxutils.escape(text, extra_mapping)
|
||||||
|
|
||||||
def startDocument(self, pagename):
|
def startDocument(self, pagename):
|
||||||
encoding = config.charset
|
encoding = config.charset
|
||||||
return '<?xml version="1.0" encoding="%s"?>\n<s1 title="%s">' % (
|
return '<?xml version="1.0" encoding="%s"?>\n<s1 title="%s">' % (
|
||||||
encoding, self._escape(pagename))
|
encoding, self._escape(pagename))
|
||||||
|
|
||||||
def endDocument(self):
|
def endDocument(self):
|
||||||
result = ""
|
result = ""
|
||||||
while self._current_depth > 1:
|
while self._current_depth > 1:
|
||||||
result += "</s%d>" % self._current_depth
|
result += "</s%d>" % self._current_depth
|
||||||
self._current_depth -= 1
|
self._current_depth -= 1
|
||||||
return result + '</s1>'
|
return result + '</s1>'
|
||||||
|
|
||||||
def lang(self, on, lang_name):
|
def lang(self, on, lang_name):
|
||||||
return ('<div lang="">' % lang_name, '</div>')[not on]
|
return ('<div lang="">' % lang_name, '</div>')[not on]
|
||||||
|
|
||||||
def sysmsg(self, on, **kw):
|
def sysmsg(self, on, **kw):
|
||||||
return ('<sysmsg>', '</sysmsg>')[not on]
|
return ('<sysmsg>', '</sysmsg>')[not on]
|
||||||
|
|
||||||
def rawHTML(self, markup):
|
def rawHTML(self, markup):
|
||||||
return '<html>' + markup + '</html>'
|
#return '<html>' + markup + '</html>'
|
||||||
|
return ''
|
||||||
def pagelink(self, on, pagename='', page=None, **kw):
|
|
||||||
if on:
|
def pagelink(self, on, pagename='', page=None, **kw):
|
||||||
return '[[:' + ":".join(pagename.split("/")) + "|"
|
if on:
|
||||||
else:
|
return '[[:' + ":".join(pagename.split("/")) + "|"
|
||||||
return ']]'
|
else:
|
||||||
|
return ']]'
|
||||||
def interwikilink(self, on, interwiki='', pagename='', **kw):
|
|
||||||
if on:
|
def interwikilink(self, on, interwiki='', pagename='', **kw):
|
||||||
if interwiki == 'Self':
|
if on:
|
||||||
return self.pagelink(on, pagename, **kw)
|
if interwiki == 'Self':
|
||||||
return '[[%s>%s|' % (interwiki, pagename)
|
return self.pagelink(on, pagename, **kw)
|
||||||
else:
|
return '[[%s>%s|' % (interwiki, pagename)
|
||||||
return ']]'
|
else:
|
||||||
|
return ']]'
|
||||||
def url(self, on, url='', css=None, **kw):
|
|
||||||
return ('[[%s|' % (self._escape(url)), ']]')[not on]
|
def url(self, on, url='', css=None, **kw):
|
||||||
|
return ('[[%s|' % (self._escape(url)), ']]')[not on]
|
||||||
def attachment_link(self, url, text, **kw):
|
|
||||||
return '{{%s|%s}}' % (url, text)
|
def attachment_link(self, on, url=None, querystr=None, **kw):
|
||||||
|
return '{{ %s | %s }}' % (url, querystr)
|
||||||
def attachment_image(self, url, **kw):
|
|
||||||
return '{{%s|}}' % (url,)
|
def attachment_image(self, url, **kw):
|
||||||
|
return '{{%s|}}' % (url,)
|
||||||
def attachment_drawing(self, url, text, **kw):
|
|
||||||
return '{{%s|%s}}' % (url, text)
|
def attachment_drawing(self, url, text, **kw):
|
||||||
|
return '{{%s|%s}}' % (url, text)
|
||||||
def text(self, text, **kw):
|
|
||||||
self._did_para = 0
|
def text(self, text, **kw):
|
||||||
if self._text is not None:
|
self._did_para = 0
|
||||||
self._text.append(text)
|
if self._text is not None:
|
||||||
return text
|
self._text.append(text)
|
||||||
|
return text
|
||||||
def rule(self, size=0, **kw):
|
|
||||||
# size not supported
|
def rule(self, size=0, **kw):
|
||||||
if size >= 4:
|
# size not supported
|
||||||
return '----\n'
|
if size >= 4:
|
||||||
else:
|
return '----\n'
|
||||||
return '-' * size + '\n'
|
else:
|
||||||
|
return '-' * size + '\n'
|
||||||
def icon(self, type):
|
|
||||||
return '<icon type="%s" />' % type
|
def icon(self, type):
|
||||||
|
return '<icon type="%s" />' % type
|
||||||
def strong(self, on, **kw):
|
|
||||||
return ['**', '**'][not on]
|
def strong(self, on, **kw):
|
||||||
|
return ['**', '**'][not on]
|
||||||
def emphasis(self, on, **kw):
|
|
||||||
return ['//', '//'][not on]
|
def emphasis(self, on, **kw):
|
||||||
|
return ['//', '//'][not on]
|
||||||
def highlight(self, on, **kw):
|
|
||||||
return ['**', '**'][not on]
|
def highlight(self, on, **kw):
|
||||||
|
return ['**', '**'][not on]
|
||||||
def number_list(self, on, type=None, start=None, **kw):
|
|
||||||
# list type not supported
|
def number_list(self, on, type=None, start=None, **kw):
|
||||||
if on:
|
# list type not supported
|
||||||
self.list_depth += 1
|
if on:
|
||||||
self.list_type = '-'
|
self.list_depth += 1
|
||||||
else:
|
self.list_type = '-'
|
||||||
self.list_depth -= 1
|
else:
|
||||||
self.list_type = ' '
|
self.list_depth -= 1
|
||||||
|
self.list_type = ' '
|
||||||
return ['', '\n'][on]
|
|
||||||
|
return ['', '\n'][on]
|
||||||
def bullet_list(self, on, **kw):
|
|
||||||
if on:
|
def bullet_list(self, on, **kw):
|
||||||
self.list_depth += 1
|
if on:
|
||||||
self.list_type = '*'
|
self.list_depth += 1
|
||||||
else:
|
self.list_type = '*'
|
||||||
self.list_depth -= 1
|
else:
|
||||||
self.list_type = ' '
|
self.list_depth -= 1
|
||||||
|
self.list_type = ' '
|
||||||
return ['', '\n'][on]
|
|
||||||
|
return ['', '\n'][on]
|
||||||
def listitem(self, on, **kw):
|
|
||||||
# somewhy blockquote uses "listitem" call
|
def listitem(self, on, **kw):
|
||||||
return [(' ' * self.list_depth * 2) + self.list_type + ' ', '\n'][not on]
|
# somewhy blockquote uses "listitem" call
|
||||||
|
return [(' ' * self.list_depth * 2) + self.list_type + ' ', '\n'][not on]
|
||||||
def code(self, on, **kw):
|
|
||||||
""" `typewriter` or {{{typerwriter}}, for code blocks i hope codeblock works """
|
def code(self, on, **kw):
|
||||||
return ["''", "''"][not on]
|
""" `typewriter` or {{{typerwriter}}, for code blocks i hope codeblock works """
|
||||||
|
return ["''", "''"][not on]
|
||||||
def sup(self, on, **kw):
|
|
||||||
return ['<sup>', '</sup>'][not on]
|
def sup(self, on, **kw):
|
||||||
|
return ['<sup>', '</sup>'][not on]
|
||||||
def sub(self, on, **kw):
|
|
||||||
return ['<sub>', '</sub>'][not on]
|
def sub(self, on, **kw):
|
||||||
|
return ['<sub>', '</sub>'][not on]
|
||||||
def strike(self, on, **kw):
|
|
||||||
return ['<del>', '</del>'][not on]
|
def strike(self, on, **kw):
|
||||||
|
return ['<del>', '</del>'][not on]
|
||||||
def preformatted(self, on, **kw):
|
|
||||||
FormatterBase.preformatted(self, on)
|
def preformatted(self, on, **kw):
|
||||||
result = ''
|
FormatterBase.preformatted(self, on)
|
||||||
if self.in_p:
|
result = ''
|
||||||
result = self.paragraph(0)
|
if self.in_p:
|
||||||
return result + ['<file>', '</file>\n'][not on]
|
result = self.paragraph(0)
|
||||||
|
return result + ['<file>', '</file>\n'][not on]
|
||||||
def paragraph(self, on, **kw):
|
|
||||||
FormatterBase.paragraph(self, on)
|
def paragraph(self, on, **kw):
|
||||||
if self.in_table or self.list_depth:
|
FormatterBase.paragraph(self, on)
|
||||||
return ''
|
if self.in_table or self.list_depth:
|
||||||
return ['', '\n\n'][not on]
|
return ''
|
||||||
|
return ['', '\n\n'][not on]
|
||||||
def linebreak(self, preformatted=1):
|
|
||||||
return ['\n', '\\\n'][not preformatted]
|
def linebreak(self, preformatted=1):
|
||||||
|
return ['\n', '\\\n'][not preformatted]
|
||||||
def heading(self, on, depth, **kw):
|
|
||||||
# heading depth reversed in dokuwiki
|
def heading(self, on, depth, **kw):
|
||||||
heading_depth = 7 - depth
|
# heading depth reversed in dokuwiki
|
||||||
|
heading_depth = 7 - depth
|
||||||
if on:
|
|
||||||
return u'%s ' % (u'=' * heading_depth)
|
if on:
|
||||||
else:
|
return u'%s ' % (u'=' * heading_depth)
|
||||||
return u' %s\n' % (u'=' * heading_depth)
|
else:
|
||||||
|
return u' %s\n' % (u'=' * heading_depth)
|
||||||
def table(self, on, attrs={}, **kw):
|
|
||||||
if on:
|
def table(self, on, attrs={}, **kw):
|
||||||
self.in_table = 1
|
if on:
|
||||||
else:
|
self.in_table = 1
|
||||||
self.in_table = 0
|
else:
|
||||||
return ''
|
self.in_table = 0
|
||||||
|
return ''
|
||||||
def table_row(self, on, attrs={}, **kw):
|
|
||||||
return ['\n', '|'][not on]
|
def table_row(self, on, attrs={}, **kw):
|
||||||
|
return ['\n', '|'][not on]
|
||||||
def table_cell(self, on, attrs={}, **kw):
|
|
||||||
return ['|', ''][not on]
|
def table_cell(self, on, attrs={}, **kw):
|
||||||
|
return ['|', ''][not on]
|
||||||
def anchordef(self, id):
|
|
||||||
# not supported
|
def anchordef(self, id):
|
||||||
return ''
|
# not supported
|
||||||
|
return ''
|
||||||
def anchorlink(self, on, name='', **kw):
|
|
||||||
# kw.id not supported, we hope the anchor matches existing heading on page
|
def anchorlink(self, on, name='', **kw):
|
||||||
return ('[[#', ']]') [not on]
|
# kw.id not supported, we hope the anchor matches existing heading on page
|
||||||
|
return ('[[#', ']]') [not on]
|
||||||
def underline(self, on, **kw):
|
|
||||||
return ['__', '__'][not on]
|
def underline(self, on, **kw):
|
||||||
|
return ['__', '__'][not on]
|
||||||
def definition_list(self, on, **kw):
|
|
||||||
result = ''
|
def definition_list(self, on, **kw):
|
||||||
if self.in_p:
|
result = ''
|
||||||
result = self.paragraph(0)
|
if self.in_p:
|
||||||
return result + ['<gloss>', '</gloss>'][not on]
|
result = self.paragraph(0)
|
||||||
|
return result + ['<gloss>', '</gloss>'][not on]
|
||||||
def definition_term(self, on, compact=0, **kw):
|
|
||||||
return ['<label>', '</label>'][not on]
|
def definition_term(self, on, compact=0, **kw):
|
||||||
|
return ['<label>', '</label>'][not on]
|
||||||
def definition_desc(self, on, **kw):
|
|
||||||
return ['<item>', '</item>'][not on]
|
def definition_desc(self, on, **kw):
|
||||||
|
return ['<item>', '</item>'][not on]
|
||||||
def image(self, src=None, **kw):
|
|
||||||
valid_attrs = ['src', 'width', 'height', 'alt', 'title']
|
def image(self, src=None, **kw):
|
||||||
|
valid_attrs = ['src', 'width', 'height', 'alt', 'title']
|
||||||
url = src
|
|
||||||
if '?' in url:
|
url = src
|
||||||
url += '&'
|
if '?' in url:
|
||||||
else:
|
url += '&'
|
||||||
url += '?'
|
else:
|
||||||
|
url += '?'
|
||||||
attrs = {}
|
|
||||||
for key, value in kw.items():
|
attrs = {}
|
||||||
if key in valid_attrs:
|
for key, value in kw.items():
|
||||||
attrs[key] = value
|
if key in valid_attrs:
|
||||||
|
attrs[key] = value
|
||||||
# TODO: finish this
|
|
||||||
if attrs.has_key('width'):
|
# TODO: finish this
|
||||||
url += attrs['width']
|
if attrs.has_key('width'):
|
||||||
|
url += attrs['width']
|
||||||
return '{{' + url + '}}'
|
|
||||||
|
return '{{' + url + '}}'
|
||||||
def code_area(self, on, code_id, code_type='code', show=0, start=-1, step=-1):
|
|
||||||
syntax = ''
|
def code_area(self, on, code_id, code_type='code', show=0, start=-1, step=-1,msg=None):
|
||||||
# switch for Python: http://simonwillison.net/2004/may/7/switch/
|
syntax = ''
|
||||||
try:
|
# switch for Python: http://simonwillison.net/2004/may/7/switch/
|
||||||
syntax = {
|
try:
|
||||||
'ColorizedPython': 'python',
|
syntax = {
|
||||||
'ColorizedPascal': 'pascal',
|
'ColorizedPython': 'python',
|
||||||
'ColorizedJava': 'java',
|
'ColorizedPascal': 'pascal',
|
||||||
'ColorizedCPlusPlus': 'cpp',
|
'ColorizedJava': 'java',
|
||||||
}[code_type]
|
'ColorizedCPlusPlus': 'cpp',
|
||||||
except KeyError:
|
}[code_type]
|
||||||
pass
|
except KeyError:
|
||||||
|
pass
|
||||||
return ('<code %s>' % syntax , '</code>')[not on]
|
|
||||||
|
return ('<code %s>' % syntax , '</code>')[not on]
|
||||||
def code_line(self, on):
|
|
||||||
return ('', '\n')[on]
|
def code_line(self, on):
|
||||||
|
return ('', '\n')[on]
|
||||||
def code_token(self, on, tok_type):
|
|
||||||
# not supported
|
def code_token(self, on, tok_type):
|
||||||
return ''
|
# not supported
|
||||||
|
return ''
|
||||||
def comment(self, text):
|
|
||||||
# real comments (lines with two hash marks)
|
def comment(self, text):
|
||||||
if text[0:2] == '##':
|
# real comments (lines with two hash marks)
|
||||||
return "/* %s */\n" % text[2:].strip()
|
if text[0:2] == '##':
|
||||||
|
#return "/* %s */\n" % text[2:].strip()
|
||||||
# Some kind of Processing Instruction
|
return ''
|
||||||
# http://moinmo.in/HelpOnProcessingInstructions
|
|
||||||
tokens = text.lstrip('#').split(None, 1)
|
# Some kind of Processing Instruction
|
||||||
if tokens[0] in ('language', 'format', 'refresh'):
|
# http://moinmo.in/HelpOnProcessingInstructions
|
||||||
return ''
|
tokens = text.lstrip('#').split(None, 1)
|
||||||
|
if tokens[0] in ('language', 'format', 'refresh'):
|
||||||
if tokens[0] == 'acl':
|
return ''
|
||||||
# TODO: fill acl.auth.php
|
|
||||||
return ''
|
if tokens[0] == 'acl':
|
||||||
|
# TODO: fill acl.auth.php
|
||||||
if tokens[0] == 'deprecated':
|
return ''
|
||||||
return '<note warning>This page is deprecated</note>\n'
|
|
||||||
|
if tokens[0] == 'deprecated':
|
||||||
if tokens[0] == 'redirect':
|
return '<note warning>This page is deprecated</note>\n'
|
||||||
return text + "\n"
|
|
||||||
|
if tokens[0] == 'redirect':
|
||||||
if tokens[0] == 'pragma':
|
return text + "\n"
|
||||||
# TODO: can do 'description' via 'meta' dokuwiki plugin
|
|
||||||
return "/* pragma: %s */\n" % " ".join(tokens[1:])
|
if tokens[0] == 'pragma':
|
||||||
|
# TODO: can do 'description' via 'meta' dokuwiki plugin
|
||||||
return "/* %s */\n" % text.lstrip('#')
|
#return "/* pragma: %s */\n" % " ".join(tokens[1:])
|
||||||
|
return ''
|
||||||
def macro(self, macro_obj, name, args):
|
|
||||||
def email(args):
|
#return "/* %s */\n" % text.lstrip('#')
|
||||||
mail = args.replace(' AT ', '@')
|
return ''
|
||||||
mail = mail.replace(' DOT ', '.')
|
|
||||||
return '[[%s|%s]]' % (mail, args)
|
|
||||||
|
def macro(self, macro_obj, name, args,markup):
|
||||||
# function which will just do what parent class would
|
def email(args):
|
||||||
def inherit(args):
|
mail = args.replace(' AT ', '@')
|
||||||
return apply(FormatterBase.macro, (self, macro_obj, name, args))
|
mail = mail.replace(' DOT ', '.')
|
||||||
|
return '[[%s|%s]]' % (mail, args)
|
||||||
try:
|
|
||||||
lookup = {
|
def showAttachedFiles(args):
|
||||||
'BR' : '\\\\',
|
args = args.split(',')
|
||||||
'MailTo' : email,
|
return self.attachment_link(1,url=args[0].strip(),querystr=args[1].strip())
|
||||||
'GetText' : args,
|
|
||||||
'ShowSmileys' : inherit,
|
# function which will just do what parent class would
|
||||||
}[name]
|
def inherit(args):
|
||||||
except KeyError:
|
return apply(FormatterBase.macro, (self, macro_obj, name, args))
|
||||||
lookup = '/* UndefinedMacro: %s(%s) */' % (name, args)
|
|
||||||
|
try:
|
||||||
if type(lookup) == FunctionType:
|
lookup = {
|
||||||
text = lookup(args)
|
'BR' : '\\\\',
|
||||||
else:
|
'MailTo' : email,
|
||||||
text = lookup
|
'GetText' : args,
|
||||||
return text
|
'ShowSmileys' : inherit,
|
||||||
|
'ShowAttachedFiles' : showAttachedFiles
|
||||||
def smiley(self, text):
|
}[name]
|
||||||
try:
|
except KeyError:
|
||||||
# https://www.dokuwiki.org/devel:smileys.conf
|
lookup = '/* UndefinedMacro: %s(%s) */' % (name, args)
|
||||||
return {
|
|
||||||
# note: reverse sorted so that longer smileys get matched first
|
if type(lookup) == FunctionType:
|
||||||
'X-(' : ':-X',
|
text = lookup(args)
|
||||||
'{X}' : ':!:',
|
else:
|
||||||
'{*}' : '<ubu>',
|
text = lookup
|
||||||
'(./)' : u'✓',
|
return text
|
||||||
':))' : ':-P',
|
|
||||||
':-))' : ':-P',
|
def smiley(self, text):
|
||||||
':-?' : ':-P',
|
try:
|
||||||
':o' : ':-o',
|
# https://www.dokuwiki.org/devel:smileys.conf
|
||||||
'{OK}' : ':!:',
|
return {
|
||||||
'{o}' : '<circ>',
|
# note: reverse sorted so that longer smileys get matched first
|
||||||
'{i}' : ':!:',
|
'X-(' : ':-X',
|
||||||
':D' : ':-D',
|
'{X}' : ':!:',
|
||||||
'B)' : '8-)',
|
'{*}' : '<ubu>',
|
||||||
'B-)' : '8-)',
|
'(./)' : u'✓',
|
||||||
'{3}' : '<3>',
|
':))' : ':-P',
|
||||||
'{2}' : '<2>',
|
':-))' : ':-P',
|
||||||
'{1}' : '<1>',
|
':-?' : ':-P',
|
||||||
'(!)' : ':!:',
|
':o' : ':-o',
|
||||||
'/!\\' : ':!:',
|
'{OK}' : ':!:',
|
||||||
':\\' : ':-\\',
|
'{o}' : '<circ>',
|
||||||
':))' : ':-)',
|
'{i}' : ':!:',
|
||||||
':)' : ':-)',
|
':D' : ':-D',
|
||||||
':(' : ':-(',
|
'B)' : '8-)',
|
||||||
':-))' : ':-)',
|
'B-)' : '8-)',
|
||||||
':-)' : ':-)',
|
'{3}' : '<3>',
|
||||||
':-(' : ':-(',
|
'{2}' : '<2>',
|
||||||
';)' : ';-)',
|
'{1}' : '<1>',
|
||||||
'|)' : ':-|',
|
'(!)' : ':!:',
|
||||||
'|-)' : ':-|',
|
'/!\\' : ':!:',
|
||||||
'>:>' : '^_^',
|
':\\' : ':-\\',
|
||||||
'<!>' : ':!:',
|
':))' : ':-)',
|
||||||
'<:(' : ':-?',
|
':)' : ':-)',
|
||||||
}[text]
|
':(' : ':-(',
|
||||||
except KeyError:
|
':-))' : ':-)',
|
||||||
return text
|
':-)' : ':-)',
|
||||||
|
':-(' : ':-(',
|
||||||
|
';)' : ';-)',
|
||||||
|
'|)' : ':-|',
|
||||||
|
'|-)' : ':-|',
|
||||||
|
'>:>' : '^_^',
|
||||||
|
'<!>' : ':!:',
|
||||||
|
'<:(' : ':-?',
|
||||||
|
}[text]
|
||||||
|
except KeyError:
|
||||||
|
return text
|
||||||
|
|
BIN
text_dokuwiki.pyc
Normal file
BIN
text_dokuwiki.pyc
Normal file
Binary file not shown.
Loading…
Reference in a new issue