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