Skip to content

Tilde

Overview

New in 12.0

Tilde was rewritten from the ground up. Some subtle difference may be observed compared to older versions, but these changes were made to align better with expected nesting conventions in the majority of parsers and to improve performance.

Tilde optionally adds two different features which are syntactically built around the ~ character: delete which inserts <del></del> tags and subscript which inserts <sub></sub> tags.

The Tilde extension can be included in Python Markdown by using the following:

import markdown
md = markdown.Markdown(extensions=['pymdownx.tilde'])

Tip

PyMdown Extensions uses one delimiter processor for emphasis, deletions, insertions, subscripts, superscripts and marks via BetterEm, Tilde, Caret, and Mark. This allows all delimiter to be parsed simultaneously providing the best nesting logic. So for best results, pair Tilde with BetterEm.

import markdown
md = markdown.Markdown(extensions=['pymdownx.betterem', 'pymdownx.tilde'])

Delete

To wrap content in a delete tag, simply surround the text with double ~. You can also enable smart_delete in the options. Smart behavior of delete models that of BetterEm.

Delete
~~Delete me~~

Delete me

Subscript

To denote a subscript, you can surround the desired content in single ~. It uses Pandoc style logic, so if your subscript needs to have spaces, you must escape the spaces.

Subscript
CH~3~CH~2~OH

text~a\ subscript~

CH3CH2OH

texta subscript

If desired, the Pandoc requirement of "no spaces", unless they are escaped, can be disabled via the no_space option.

Superscript
text~a subscript~

texta subscript

New in 12.0

no_space is new in 12.0.

Options

Option Type Default Description
smart_delete bool False Use smart logic with delete characters.
delete bool True Enable delete feature.
subscript bool True Enable subscript feature.
no_space bool True Enable Pandoc style requirement of "no unescaped spaces".