Output Markdown :param str mdcontent: Markdown string :param bool lstrip: Whether to remove the leading whitespace in each line of ``mdcontent``. The number of the whitespace to remove will be decided cleverly. :param dict options: Configuration when parsing Markdown.
(mdcontent: str, lstrip: bool = True, options: Dict[str, Union[str, bool]] = None,
sanitize: bool = True,
scope: str = None, position: int = OutputPosition.BOTTOM, **kwargs)
| 533 | |
| 534 | |
| 535 | def put_markdown(mdcontent: str, lstrip: bool = True, options: Dict[str, Union[str, bool]] = None, |
| 536 | sanitize: bool = True, |
| 537 | scope: str = None, position: int = OutputPosition.BOTTOM, **kwargs) -> Output: |
| 538 | """ |
| 539 | Output Markdown |
| 540 | |
| 541 | :param str mdcontent: Markdown string |
| 542 | :param bool lstrip: Whether to remove the leading whitespace in each line of ``mdcontent``. |
| 543 | The number of the whitespace to remove will be decided cleverly. |
| 544 | :param dict options: Configuration when parsing Markdown. |
| 545 | PyWebIO uses `marked <https://marked.js.org/>`_ library to parse Markdown, |
| 546 | the parse options see: https://marked.js.org/using_advanced#options (Only supports members of string and boolean type) |
| 547 | :param bool sanitize: Whether to use `DOMPurify <https://github.com/cure53/DOMPurify>`_ to filter the content to prevent XSS attacks. |
| 548 | :param int scope, position: Those arguments have the same meaning as for `put_text()` |
| 549 | |
| 550 | When using Python triple quotes syntax to output multi-line Markdown in a function, |
| 551 | you can indent the Markdown text to keep a good code format. |
| 552 | PyWebIO will cleverly remove the indent for you when show the Markdown:: |
| 553 | |
| 554 | # good code format |
| 555 | def hello(): |
| 556 | put_markdown(r\""" # H1 |
| 557 | This is content. |
| 558 | \""") |
| 559 | |
| 560 | .. versionchanged:: 1.5 |
| 561 | Enable `lstrip` by default. |
| 562 | Deprecate `strip_indent`. |
| 563 | """ |
| 564 | if 'strip_indent' in kwargs: |
| 565 | import warnings |
| 566 | |
| 567 | # use stacklevel=2 to make the warning refer to put_markdown() call |
| 568 | warnings.warn("`strip_indent` parameter is deprecated in `put_markdown()`", DeprecationWarning, stacklevel=2) |
| 569 | |
| 570 | if lstrip: |
| 571 | mdcontent = _left_strip_multiple_line_string_literal(mdcontent) |
| 572 | |
| 573 | spec = _get_output_spec('markdown', content=mdcontent, options=options, sanitize=sanitize, |
| 574 | scope=scope, position=position) |
| 575 | return Output(spec) |
| 576 | |
| 577 | |
| 578 | class span_: |
no test coverage detected
searching dependent graphs…