3 from __future__
import absolute_import
4 from __future__
import division
5 from __future__
import print_function
6 from __future__
import unicode_literals
15 return self.__class__()
20 def parseAndAdd(self, text):
21 text =
Parser(text, self).parse()
24 def addRaw(self, text):
25 raise Exception(
'Not yet implemented.')
27 def addLine(self, text):
28 raise Exception(
'Not yet implemented.')
30 def addLinebreak(self):
31 raise Exception(
'Not yet implemented.')
33 def addHeader(self, text):
34 raise Exception(
'Not yet implemented.')
36 def addEmphasis(self, text):
37 raise Exception(
'Not yet implemented.')
39 def addList(self, textList):
40 raise Exception(
'Not yet implemented.')
42 def addLink(self, text, url):
43 raise Exception(
'Not yet implemented.')
45 def addCode(self, text):
46 raise Exception(
'Not yet implemented.')
48 def addCodeLink(self, text):
49 raise Exception(
'Not yet implemented.')
51 def addTable(self, table):
52 raise Exception(
'Not yet implemented.')
55 raise Exception(
'Not yet implemented.')
59 def addRaw(self, text):
60 self.
content +=
"{text}".format(text=text)
62 def addLine(self, text, new_line=False):
63 self.
content +=
"{line}{text}\n".format(line=(
'\n' if new_line
else ''),
66 def addLinebreak(self):
69 def addHeader(self, text, h=1):
70 self.
addLine(
"{header} {text}".format(header=h *
'#', text=text),
True)
72 def addEmphasis(self, text, s=1):
73 self.
addRaw(
"{stars}{text}{stars}".format(stars=s *
'*', text=text))
75 def addList(self, textList):
77 self.
addLine(
"- {text}".format(text=text),
True)
80 def addLink(self, text, url):
81 self.
addRaw(
"[{text}]({url})".format(text=text, url=url))
83 def addCodeLink(self, path, options=None):
84 self.
addRaw(
"({path})".format(path=path))
86 def addCode(self, text, inline=False):
88 self.
content +=
"`{text}`".format(text=text)
90 self.
addRaw(
"\n\n```\n{text}```\n\n".format(text=text))
92 def addTable(self, table, noTitle=False):
94 assert(len(table) > 1)
96 table.insert(0, [
' ' for i
in range(len(table[0]))])
97 self.
addLine(
' | '.join(table[0]))
98 self.
addLine(
' | '.join([
'----' for i
in range(len(table[0]))]))