Tables in `.. include::`ed markdown files merge with remaining docstring
howamith opened this issue · 2 comments
howamith commented
Expected Behavior
When pulling in a markdown table via .. include::
reStructuredText directive, any remaining content within that docstring simply follows on after said table.
Actual Behavior
The remaining content gets included within the table from the .. include::
ed markdown table.
Steps to Reproduce
- Extract the contents of pdoc3-test.zip and open a terminal within the top level directory.
- Install
pdoc3
if it isn't already installed. I was usingpdoc3
in avenv
when I discovered this, but I'd imagine having it installed globally won't affect things. - Run
pdoc --html --output-dir doc package --force
- Observe
doc/package/index.html. You'll notice that everything in the top-level docstring from
package/init.pyafter the
.. include::ed markdown table from
package/table.md` is included in the rendered table, as opposed to after the table, as expected.
Additional info
- pdoc version: discovered in 0.9.2, also present in 0.10.0.
- Workaround: add an empty HTML tag of some form (tested with
span
) after the table.
kernc commented
From the top of the head, I think this regex that extracts reST directives:
Lines 325 to 328 in 4aa70de
might "eat up" all the trailing newlines, and therefore the content following appears to be attached to its previous paragraph without a clear break.
Can you check whether adding a suffix "\n"
(or two) here resolves the issue?
Lines 278 to 281 in 4aa70de
Care to do a PR?
howamith commented
Adding a single "\n"
to the end of what _ToMarkdown._include_file()
returns does indeed fix the issue :)
Yes, happy to submit a PR!