| 56 | |
| 57 | |
| 58 | class Markdown(Formatter): |
| 59 | def addRaw(self, text): |
| 60 | self.content += "{text}".format(text=text) |
| 61 | |
| 62 | def addLine(self, text, new_line=False): |
| 63 | self.content += "{line}{text}\n".format(line=('\n' if new_line else ''), |
| 64 | text=text) |
| 65 | |
| 66 | def addLinebreak(self): |
| 67 | self.content += "\n" |
| 68 | |
| 69 | def addHeader(self, text, h=1): |
| 70 | self.addLine("{header} {text}".format(header=h * '#', text=text), True) |
| 71 | |
| 72 | def addEmphasis(self, text, s=1): |
| 73 | self.addRaw("{stars}{text}{stars}".format(stars=s * '*', text=text)) |
| 74 | |
| 75 | def addList(self, textList): |
| 76 | for text in textList: |
| 77 | self.addLine("- {text}".format(text=text), True) |
| 78 | self.addLinebreak() |
| 79 | |
| 80 | def addLink(self, text, url): |
| 81 | self.addRaw("[{text}]({url})".format(text=text, url=url)) |
| 82 | |
| 83 | def addCodeLink(self, path, options=None): |
| 84 | self.addRaw("({path})".format(path=path)) |
| 85 | |
| 86 | def addCode(self, text, inline=False): |
| 87 | if (inline): |
| 88 | self.content += "`{text}`".format(text=text) |
| 89 | else: |
| 90 | self.addRaw("\n\n```\n{text}```\n\n".format(text=text)) |
| 91 | |
| 92 | def addTable(self, table, noTitle=False): |
| 93 | self.addLinebreak() |
| 94 | assert(len(table) > 1) |
| 95 | if noTitle: |
| 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]))])) |
| 99 | for row in table[1:]: |
| 100 | self.addLine(' | '.join(row)) |
| 101 | self.addLinebreak() |
| 102 | |
| 103 | def addBreak(self): |
| 104 | self.addLine('\n---\n', True) |
no outgoing calls
no test coverage detected
searching dependent graphs…