Skip to main content

A Python-Markdown extension to ignore html comments opened by three dashes.

Project description

mkdcomments

Original plugin was created by ryneeverett.

A Python-Markdown preprocessor extension to ignore html comments opened by three dashes and any whitespace prior to them. I believe pandoc has similar functionality.

<!-- This is a standard html comment which will remain in the output. -->
<!--- This is a markdown comment which this extension removes. -->

Installation

pip install python-markdown-comments

Example

>>> import markdown
>>> from python_markdown_comments import CommentsExtension
>>> comments = CommentsExtension()
>>> markdowner = markdown.Markdown(extensions=[comments])
>>> markdowner.convert("""\
... blah blah blah  <!--- inline comment -->
...
... <!---multiline comment
... multiline comment
... multiline comment-->
...
... even more text.""")
u'<p>blah blah blah</p>\n<p>even more text.</p>'

Infrequently Asked Questions

How can I write about markdown comments without them being removed?

In order to render markdown comments, you must *(a)*use them in an html block (which are not processed as markdown) and *(b)*escape the brackets so the browser won't think they're html comments. E.g.:

<pre>
&lt;!--- meta markdown comment --&gt;
</pre>

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for python-markdown-comments, version 1.1.0
Filename, size File type Python version Upload date Hashes
Filename, size python_markdown_comments-1.1.0-py3-none-any.whl (3.5 kB) File type Wheel Python version py3 Upload date Hashes View
Filename, size python-markdown-comments-1.1.0.tar.gz (3.6 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page