liran-funaro / sphinx-markdown-builder

A Sphinx extension to add markdown generation support.
https://pypi.org/project/sphinx-markdown-builder
MIT License
41 stars 19 forks source link

needtable rst element results in unwanted anchor just before table #5

Closed flynneva closed 1 year ago

flynneva commented 1 year ago

Describe the bug

When using needtables in the source rst file, the resulting md table has an anchor (<a></a>) directly before the table, with no empty line between it and the table.

This causes issues later on for markdown parsers, and ideally all anchors should have a new/blank line directly after it.

Even with setting both anchor settings to False for this plugin the markdown still has an anchor in it.

To Reproduce Steps to reproduce the behavior:

  1. Create an rst file with a needtable
  2. Convert it to markdown with this plugin
  3. See anchor in markdown, just before table

Expected behavior

Either the anchor settings for this plugin can be used to complete remove these anchors from being generated, or there is a new empty line between it and the table.

Environment (please complete the following information):

Additional context Add any other context about the problem here.

flynneva commented 1 year ago

Same thing happens for some .png images we have as well (generated from needpie elements from sphinx-needs), an anchor element is generated directly before it, even though we don't want it to.

flynneva commented 1 year ago

Editing line 448 of the translators.py file by adding two line returns at the end fixes this issue for me:

        content = f'<a id="{escape_html_quote(anchor)}"></a>\n\n'
liran-funaro commented 1 year ago

This issue seems to touch multiple bugs, but also some issues with needtables.

I've pushed a new commit that addresses the following:

Regarding the unwanted anchors, it seems that needtables explicitly add these anchors. I can't ignore it. From sphinx-markdown-builder point-of-view, this is identical to the user adding anchors to its RST file. The configuration flags allow you to implicitly add anchors to sections and function signatures. They do not affect explicit anchors.

You can install the latest commit and see if it solved this issue for you. If it solves it, I'll upload a new version.

pip uninstall sphinx-markdown-builder
pip install git+https://github.com/liran-funaro/sphinx-markdown-builder.git@main
flynneva commented 1 year ago

@liran-funaro I've confirmed that your latest commit works 👍🏼 thanks so much for the quick work / conclusion here.

liran-funaro commented 1 year ago

@flynneva Great! I uploaded the new version: https://pypi.org/project/sphinx-markdown-builder/0.6.5/