MCPcopy Index your code
hub / github.com/Python-Markdown/markdown / set_output_format

Method set_output_format

markdown/core.py:279–298  ·  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

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.

Callers 1

__init__Method · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected