Convert Markdown to HTML.
| 177 | |
| 178 | |
| 179 | class Markdown: |
| 180 | """Convert Markdown to HTML.""" |
| 181 | |
| 182 | def __init__(self, |
| 183 | extensions=[], |
| 184 | extension_configs={}, |
| 185 | safe_mode = False, |
| 186 | output_format=DEFAULT_OUTPUT_FORMAT): |
| 187 | """ |
| 188 | Creates a new Markdown instance. |
| 189 | |
| 190 | Keyword arguments: |
| 191 | |
| 192 | * extensions: A list of extensions. |
| 193 | If they are of type string, the module mdx_name.py will be loaded. |
| 194 | If they are a subclass of markdown.Extension, they will be used |
| 195 | as-is. |
| 196 | * extension-configs: Configuration setting for extensions. |
| 197 | * safe_mode: Disallow raw html. One of "remove", "replace" or "escape". |
| 198 | * output_format: Format of output. Supported formats are: |
| 199 | * "xhtml1": Outputs XHTML 1.x. Default. |
| 200 | * "xhtml": Outputs latest supported version of XHTML (currently XHTML 1.1). |
| 201 | * "html4": Outputs HTML 4 |
| 202 | * "html": Outputs latest supported version of HTML (currently HTML 4). |
| 203 | Note that it is suggested that the more specific formats ("xhtml1" |
| 204 | and "html4") be used as "xhtml" or "html" may change in the future |
| 205 | if it makes sense at that time. |
| 206 | |
| 207 | """ |
| 208 | |
| 209 | self.safeMode = safe_mode |
| 210 | self.registeredExtensions = [] |
| 211 | self.docType = "" |
| 212 | self.stripTopLevelTags = True |
| 213 | |
| 214 | # Preprocessors |
| 215 | self.preprocessors = odict.OrderedDict() |
| 216 | self.preprocessors["html_block"] = \ |
| 217 | preprocessors.HtmlBlockPreprocessor(self) |
| 218 | self.preprocessors["reference"] = \ |
| 219 | preprocessors.ReferencePreprocessor(self) |
| 220 | # footnote preprocessor will be inserted with "<reference" |
| 221 | |
| 222 | # Block processors - ran by the parser |
| 223 | self.parser = blockparser.BlockParser() |
| 224 | self.parser.blockprocessors['empty'] = \ |
| 225 | blockprocessors.EmptyBlockProcessor(self.parser) |
| 226 | self.parser.blockprocessors['indent'] = \ |
| 227 | blockprocessors.ListIndentProcessor(self.parser) |
| 228 | self.parser.blockprocessors['code'] = \ |
| 229 | blockprocessors.CodeBlockProcessor(self.parser) |
| 230 | self.parser.blockprocessors['hashheader'] = \ |
| 231 | blockprocessors.HashHeaderProcessor(self.parser) |
| 232 | self.parser.blockprocessors['setextheader'] = \ |
| 233 | blockprocessors.SetextHeaderProcessor(self.parser) |
| 234 | self.parser.blockprocessors['hr'] = \ |
| 235 | blockprocessors.HRProcessor(self.parser) |
| 236 | self.parser.blockprocessors['olist'] = \ |
no outgoing calls
no test coverage detected