MCPcopy Create free account
hub / github.com/Python-Markdown/markdown / set_output_format

Method set_output_format

markdown/core.py:292–311  ·  view source on GitHub ↗

Set the output format for the class instance. Arguments: format: Must be a known value in `Markdown.output_formats`.

(self, format: str)

Source from the content-addressed store, hash-verified

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

Callers 1

__init__Method · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected