Set the output format for the class instance. Arguments: format: Must be a known value in `Markdown.output_formats`.
(self, format: str)
| 284 | return self |
| 285 | |
| 286 | def set_output_format(self, format: str) -> Markdown: |
| 287 | """ |
| 288 | Set the output format for the class instance. |
| 289 | |
| 290 | Arguments: |
| 291 | format: Must be a known value in `Markdown.output_formats`. |
| 292 | |
| 293 | """ |
| 294 | self.output_format = format.lower().rstrip('145') # ignore number |
| 295 | try: |
| 296 | self.serializer = self.output_formats[self.output_format] |
| 297 | except KeyError as e: |
| 298 | valid_formats = list(self.output_formats.keys()) |
| 299 | valid_formats.sort() |
| 300 | message = 'Invalid Output Format: "%s". Use one of %s.' \ |
| 301 | % (self.output_format, |
| 302 | '"' + '", "'.join(valid_formats) + '"') |
| 303 | e.args = (message,) + e.args[1:] |
| 304 | raise |
| 305 | return self |
| 306 | |
| 307 | # Note: the `tag` argument is type annotated `Any` as ElementTree uses many various objects as tags. |
| 308 | # As there is no standardization in ElementTree, the type of a given tag is unpredictable. |