ryanfox / sphinx-markdown-tables

A markdown table plugin for Sphinx
GNU General Public License v3.0
59 stars 15 forks source link

Use 'escape' safe mode, so that characters such as '<' or '>' are correctly escaped before conversion. #6

Closed Laefy closed 6 years ago

ryanfox commented 6 years ago

Thanks for the feedback, but I don't think this is a great idea: safe_mode is already deprecated by markdown: https://github.com/Python-Markdown/markdown/blob/de9cc42f2d8bc29d8f16058a6ae65a434caab7d6/docs/change_log/release-2.6.md#safe_mode-deprecated

Laefy commented 6 years ago

Ok, thanks for the link. What about adding the part of code they propose ?

from markdown.extensions import Extension

class EscapeHtml(Extension): def extendMarkdown(self, md, md_globals): del md.preprocessors['html_block'] del md.inlinePatterns['html']

Because currently, if you pass this text to a Markdown converter (such as dillinger) : A D
B C
E <F>

the second cell shows "<i>D</i>", not "D", and the last cell shows "<F>", not "".

Laefy commented 6 years ago

After looking at it closer, it seems that by default, the recommonmark parser also treat <...> as html tags. Docs I've found on Markdown also seem to go this way. The only way to make it be parsed as < is to put a space after it, or to escape it with <. So this pull request does not seem to be justified. Thanks and sorry !