Skip to content

mdx_steroids.kill_tags»

The mdx_steroids.kill_tags removes requested HTML elements from final HTML output.

Installation»

pip install --user --upgrade git+https://github.com/twardoch/markdown-steroids.git

Docs»

Options»

  • The kill option allows to specify a list of CSS selectors or (when using the “!” prefix), XPath selectors.
    Elements matching to these selectors will be completely removed from the final HTML.

  • The kill_known option allows to remove (if true) or keep (if false) certain hardcoded selectors.

  • The kill_empty option allows to specify a list of simple element tags which will be removed if they’re empty.

  • The normalize option will pass the final HTML through BeautifulSoup if true.

  mdx_steroids.kill_tags:
    normalize: false  # Do not use BeautifulSoup for post-processing
    kill:             # List of CSS selectors or (with "!" prefix) XPath selectors to delete
      - "!//pre[@class and contains(concat(' ', normalize-space(@class), ' '), ' highlight ') and code[@class and
      contains(concat(' ', normalize-space(@class), ' '), ' language-del ')]]"
      - del
    kill_known: false # Do not remove some hardcoded "known" selectors
    kill_empty:       # List of HTML tags (simple) to be removed if they’re empty
      - p
      - div

Example»

This assumes the pymdownx.tilde extension being used, and the above configuration.

Input Markdown 1»

This is an example where a portion of inline text has been surrounded with ~~ on each side, which will be visible in the Github wiki preview~~ but will be deleted from the final HTML~~. And this is another example where a portion of inline text has been surrounded with the HTML tag del on each side.

This is an example where a portion of inline text has
been surrounded with `~~` on each side, which will
be visible in the Github wiki preview~~ but will
be deleted from the final HTML~~. And this is another
example where a portion of inline text has been
surrounded with the HTML tag `del` on each
side<del> and it also will be deleted from the
final HTML</del>.

Output HTML 1»

This is an example where a portion of inline text has been surrounded with ~~ on each side, which will be visible in the Github wiki preview . And this is another example where a portion of inline text has been surrounded with the HTML tag del on each side.

<p>This is an example where a portion of inline text has been surrounded with <code>~~</code> on each side,
which will be visible in the Github wiki preview . And this is another example where a portion of inline text has
been surrounded with the HTML tag <code>del</code> on each side. </p>

Input Markdown 2»

This is a visible paragraph before the special del block.

  • this is a list item that will be visible

  • this is another list item that will be visible

    This is a visible paragraph before the special del block.

    ```del
    ## This heading from details will be deleted

    This can be an arbitrarily long set of paragraphs.
    This can be an arbitrarily long set of paragraphs.

    * this is a list item that will be deleted

    * this is another list item that will be deleted
    ```

    * this is a list item that will be visible

    * this is another list item that will be visible

Output HTML 2»

This is a visible paragraph before the special del block.

  • this is a list item that will be visible

  • this is another list item that will be visible

<p>This is a visible paragraph before the special del block. </p>
<ul>
<li>
<p>this is a list item that will be visible</p>
</li>
<li>
<p>this is another list item that will be visible</p>
</li>
</ul>

Copyright © 2017 Adam Twardoch adam+github@twardoch.com
License: BSD 3-clause