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

Function markdownFromFile

markdown/core.py:512–538  ·  view source on GitHub ↗

Read Markdown text from a file or stream and write HTML output to a file or stream. This is a shortcut function which initializes an instance of [`Markdown`][markdown.Markdown], and calls the [`convertFile`][markdown.Markdown.convertFile] method rather than [`convert`][markdown.Mar

(**kwargs: Any)

Source from the content-addressed store, hash-verified

510
511
512def markdownFromFile(**kwargs: Any):
513 """
514 Read Markdown text from a file or stream and write HTML output to a file or stream.
515
516 This is a shortcut function which initializes an instance of [`Markdown`][markdown.Markdown],
517 and calls the [`convertFile`][markdown.Markdown.convertFile] method rather than
518 [`convert`][markdown.Markdown.convert].
519
520 Keyword arguments:
521 input (str | BinaryIO): A file name or readable object.
522 output (str | BinaryIO): A file name or writable object.
523 encoding (str): Encoding of input and output.
524 **kwargs: Any arguments accepted by the `Markdown` class.
525
526 !!! warning
527 The Python-Markdown library does ***not*** sanitize its HTML output.
528 As `markdown.markdownFromFile` writes directly to the file system, there is no
529 easy way to sanitize the output from Python code. Therefore, it is
530 recommended that the `markdown.markdownFromFile` function not be used on input
531 from an untrusted source. For more information see [Sanitizing HTML
532 Output](../../sanitization.md).
533
534 """
535 md = Markdown(**kwargs)
536 md.convertFile(kwargs.get('input', None),
537 kwargs.get('output', None),
538 kwargs.get('encoding', None))

Callers

nothing calls this directly

Calls 2

convertFileMethod · 0.95
MarkdownClass · 0.85

Tested by

no test coverage detected