diff --git a/pdoc/html_helpers.py b/pdoc/html_helpers.py index 8ba63db6..51861947 100644 --- a/pdoc/html_helpers.py +++ b/pdoc/html_helpers.py @@ -275,6 +275,9 @@ def _admonition(match, module=None, limit_types=None): if limit_types and type not in limit_types: return match.group(0) + if text is None: + text = "" + if type == 'include' and module: try: return _ToMarkdown._include_file(indent, value, @@ -323,7 +326,8 @@ def admonitions(text, module, limit_types=None): See: https://python-markdown.github.io/extensions/admonition/ """ substitute = partial(re.compile(r'^(?P *)\.\. ?(\w+)::(?: *(.*))?' - r'((?:\n(?:(?P=indent) +.*| *$))*)', re.MULTILINE).sub, + r'((?:\n(?:(?P=indent) +.*| *$))*[^\r\n])*', + re.MULTILINE).sub, partial(_ToMarkdown._admonition, module=module, limit_types=limit_types)) # Apply twice for nested (e.g. image inside warning) diff --git a/pdoc/test/__init__.py b/pdoc/test/__init__.py index 8b67ab77..c98d0c8e 100644 --- a/pdoc/test/__init__.py +++ b/pdoc/test/__init__.py @@ -1568,7 +1568,22 @@ def test_reST_include(self):

1 x = 2 x = 3 -x =

''' +x =

+ + + + + + + + + + + + + +
NameValue
HelloWorld
+

Remaining.

''' mod = pdoc.Module(pdoc.import_module( os.path.join(TESTS_BASEDIR, EXAMPLE_MODULE, '_reST_include', 'test.py'))) html = to_html(mod.docstring, module=mod) diff --git a/pdoc/test/example_pkg/_reST_include/table.md b/pdoc/test/example_pkg/_reST_include/table.md new file mode 100644 index 00000000..abf0fc4f --- /dev/null +++ b/pdoc/test/example_pkg/_reST_include/table.md @@ -0,0 +1,3 @@ +| Name | Value | +| ----- | ----- | +| Hello | World | diff --git a/pdoc/test/example_pkg/_reST_include/test.py b/pdoc/test/example_pkg/_reST_include/test.py index 96c25c41..acf75900 100644 --- a/pdoc/test/example_pkg/_reST_include/test.py +++ b/pdoc/test/example_pkg/_reST_include/test.py @@ -8,4 +8,8 @@ .. include:: foo/../_include_me.py :start-after: = :end-before: 4 + +.. include:: table.md + +Remaining. """