Commit de70e460 authored by Robin Sonnabend's avatar Robin Sonnabend
Browse files

Implement rendering in DokuWiki-Syntax for #157

parent 7318ac61
...@@ -618,8 +618,11 @@ class Todo(DatabaseModel): ...@@ -618,8 +618,11 @@ class Todo(DatabaseModel):
escape_tex(self.get_state_tex()) escape_tex(self.get_state_tex())
) )
def render_wikitext(self, current_protocol=None): def render_wikitext(self, current_protocol=None, use_dokuwiki=False):
return "'''{}:''' {}: {} - {}".format( bold = "'''"
if use_dokuwiki:
bold = "**"
return "{0}{1}:{0} {2}: {3} - {4}".format(bold,
"Neuer Todo" if self.is_new(current_protocol) else "Todo", "Neuer Todo" if self.is_new(current_protocol) else "Todo",
self.who, self.who,
self.description, self.description,
......
...@@ -34,6 +34,7 @@ class RenderType(Enum): ...@@ -34,6 +34,7 @@ class RenderType(Enum):
wikitext = 1 wikitext = 1
plaintext = 2 plaintext = 2
html = 3 html = 3
dokuwiki = 4
def _not_implemented(self, render_type): def _not_implemented(self, render_type):
return NotImplementedError("The rendertype {} has not been implemented for {}.".format(render_type.name, self.__class__.__name__)) return NotImplementedError("The rendertype {} has not been implemented for {}.".format(render_type.name, self.__class__.__name__))
...@@ -179,6 +180,8 @@ class Text: ...@@ -179,6 +180,8 @@ class Text:
return self.text return self.text
elif render_type == RenderType.html: elif render_type == RenderType.html:
return self.text return self.text
elif render_type == RenderType.dokuwiki:
return self.text
else: else:
raise _not_implemented(self, render_type) raise _not_implemented(self, render_type)
...@@ -270,6 +273,20 @@ class Tag: ...@@ -270,6 +273,20 @@ class Tag:
return '<sup id="#fnref{0}"><a href="#fn{0}">Fn</a></sup>'.format( return '<sup id="#fnref{0}"><a href="#fn{0}">Fn</a></sup>'.format(
footnote_hash(self.values[0])) footnote_hash(self.values[0]))
return "[{}: {}]".format(self.name, ";".join(self.values)) return "[{}: {}]".format(self.name, ";".join(self.values))
elif render_type == RenderType.dokuwiki:
if self.name == "url":
return self.values[0]
elif self.name == "todo":
if not show_private:
return ""
return self.todo.render_wikitext(current_protocol=protocol,
use_dokuwiki=True)
elif self.name == "beschluss":
return "**{}:** {}".format(self.name.capitalize(), ";".join(self.values))
elif self.name == "footnote":
return "(({}))".format(self.values[0])
else:
return "**{}:** {}".format(self.name.capitalize(), ";".join(self.values))
else: else:
raise _not_implemented(self, render_type) raise _not_implemented(self, render_type)
...@@ -332,6 +349,8 @@ class Remark(Element): ...@@ -332,6 +349,8 @@ class Remark(Element):
return "{}: {}".format(RenderType.plaintex) return "{}: {}".format(RenderType.plaintex)
elif render_type == RenderType.html: elif render_type == RenderType.html:
return "<p>{}: {}</p>".format(self.name, self.value) return "<p>{}: {}</p>".format(self.name, self.value)
elif render_type == RenderType.dokuwiki:
return r"{}: {}\\".format(self.name, self.value)
else: else:
raise _not_implemented(self, render_type) raise _not_implemented(self, render_type)
...@@ -413,7 +432,7 @@ class Fork(Element): ...@@ -413,7 +432,7 @@ class Fork(Element):
return r"\textit{[An dieser Stelle wurde intern protokolliert.]}" return r"\textit{[An dieser Stelle wurde intern protokolliert.]}"
else: else:
return "\n".join([escape_tex(name_line), begin_line, content_lines, end_line]) return "\n".join([escape_tex(name_line), begin_line, content_lines, end_line])
elif render_type == RenderType.wikitext: elif render_type == RenderType.wikitext or render_type == RenderType.dokuwiki:
title_line = "{0} {1} {0}".format("=" * (level + 2), name_line) title_line = "{0} {1} {0}".format("=" * (level + 2), name_line)
content_parts = [] content_parts = []
for child in self.children: for child in self.children:
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment