markdown-text-decorator 3.2.0
Text Decorator Extension for Python-Markdown.
License: MIT
Requires Python: >=3.7

[CommonMark Spec]: https://spec.commonmark.org/0.30/
[HTML tags]: https://developer.mozilla.org/en-US/docs/Web/HTML
[CSS]: https://developer.mozilla.org/en-US/docs/Web/CSS
[Python-Markdown HP]: https://python-markdown.github.io/
[Python-Markdown]: https://pypi.org/project/Markdown/
[Registries priority]: https://python-markdown.github.io/extensions/api/#registries

[delete]: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/del
[insert]: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/ins
[mark]: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/mark
[overline]: https://developer.mozilla.org/en-US/docs/Web/CSS/text-decoration#examples
[ruby]: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/rt#examples
[strikethrough]: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/s
[subscript]: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/sub
[superscript]: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/sup
[underline]: https://developer.mozilla.org/en-US/docs/Web/CSS/text-decoration#examples
[underoverline]: https://developer.mozilla.org/en-US/docs/Web/CSS/text-decoration#examples

# Text Decorator Extension for Python-Markdown

[![Downloads](https://pepy.tech/badge/markdown-text-decorator)](https://pepy.tech/project/markdown-text-decorator) [![Downloads](https://pepy.tech/badge/markdown-text-decorator/month)](https://pepy.tech/project/markdown-text-decorator) [![Downloads](https://pepy.tech/badge/markdown-text-decorator/week)](https://pepy.tech/project/markdown-text-decorator) 


This extension add Text Decorate handler to [Python-Markdown].


## Spec

This extension supports following expressions.

|Type           |Markdown        |HTML                                                                                 |
|:--------------|:---------------|:------------------------------------------------------------------------------------|
|[delete]       |`--text--`      |`<del>text</del>`                                                                    |
|[insert]       |`++text++`      |`<ins>text</ins>`                                                                    |
|[mark]         |`!!text!!`      |`<mark>text</mark>`                                                                  |
|[overline]     |`===text===`    |`<span class="overline" style="...">text</span>`                                     |
|[ruby]         |`{text:rt-text}`|`<ruby>text<rt>rt-text</rt></ruby>`                                                  |
|[strikethrough]|`~~text~~`      |`
text
`                                                                        |
|[subscript]    |`^text^`        |`<sub>text</sub>`                                                                    |
|[superscript]  |`^^text^^`      |`<sup>text</sup>`                                                                    |
|[underline]    |`=text=`        |`<span class="underline" style="...">text</span>`                                    |
|[underoverline]|`==text==`      |`<span class="underoverline" style="...">text</span>`                                |

### Extension Param

|Name    |Type|Default|Description                                                                                                               |
|:-------|:--:|:-----:|:-------------------------------------------------------------------------------------------------------------------------|
|priority|int |100    |When you use other extensions, Try to adjust this param. <br /> * Higher value will be prioritized proccessing. <br/>Ref) [Registries priority]|

## Installation

```bash
python3 -m pip install markdown_text_decorator
```

## Usage

### Sample Code

```python
from markdown import Markdown

MARKDOWN_EXTENSIONS = [
    "markdown_text_decorator"
]

MARKDOWN_EXTENSION_CONFS={
    "markdown_text_decorator": { "priority": 90 }
}

md2html = Markdown(extensions=MARKDOWN_EXTENSIONS,
                   extension_configs=MARKDOWN_EXTENSION_CONFS)

markdown_input = """

# Markdown Text Decoration Expression

~~This is~~ strikethrough ~~line~~

++This is++ insert ++line++ 

--This is-- delete --line--

^^This is^^ superscript ^^line^^

^This is^ subscript ^line^

!!This is!! mark !!line!!

=This is= underline =line=

==This is== underoverline ==line==

===This is=== overline ===line===

{ Markdown Text Decorator : mɑ́ːkdàun tékst dékərèitər }

{ 日本語: !!Japanese!! } { 英語: !!English!! }

# Python-Markdown Standard Expression 

This is nomal line

*This is* italic-1 *line*

_This is_ italic-2 _line_

**This is** bold-1 **line**

__This is__ bold-2 __line__

***This is*** bold+italic-1 ***line***

___This is___ bold+italic-2 ___line___

**_This is_** bold+italic-3 **_line_**

"""

html_output = md2html.convert(markdown_input)

print(html_output)

```

### Sample Output

```html
<h1>Markdown Text Decoration Expression</h1>
<p>
This is
 strikethrough 
line
</p>
<p><ins>This is</ins> insert <ins>line</ins> </p>
<p><del>This is</del> delete <del>line</del></p>
<p><sup>This is</sup> superscript <sup>line</sup></p>
<p><sub>This is</sub> subscript <sub>line</sub></p>
<p><mark>This is</mark> mark <mark>line</mark></p>
<p><span class="underline" style="text-decoration: underline">This is</span> underline <span class="underline" style="text-decoration: underline">line</span></p>
<p><span class="underoverline" style="text-decoration: underline overline">This is</span> underoverline <span class="underoverline" style="text-decoration: underline overline">line</span></p>
<p><span class="overline" style="text-decoration: overline">This is</span> overline <span class="overline" style="text-decoration: overline">line</span></p>
<p><ruby>Markdown Text Decorator<rt>mɑ́ːkdàun tékst dékərèitər</rt></ruby></p>
<p><ruby>日本語<rt><mark>Japanese</mark></rt></ruby> <ruby>英語<rt><mark>English</mark></rt></ruby></p>
<h1>Python-Markdown Standard Expression</h1>
<p>This is nomal line</p>
<p><em>This is</em> italic-1 <em>line</em></p>
<p><em>This is</em> italic-2 <em>line</em></p>
<p><strong>This is</strong> bold-1 <strong>line</strong></p>
<p><strong>This is</strong> bold-2 <strong>line</strong></p>
<p><strong><em>This is</em></strong> bold+italic-1 <strong><em>line</em></strong></p>
<p><strong><em>This is</em></strong> bold+italic-2 <strong><em>line</em></strong></p>
<p><strong><em>This is</em></strong> bold+italic-3 <strong><em>line</em></strong></p>
```

### Test Result

```text
MarkdownTextDecoratorTest
----------------------------------------------------------------------
test_bold_italic_p1 (__main__.MarkdownStandardTextDecoratorTestCase)
test for bold_italic pattern 1 ... ok
test_bold_italic_p2 (__main__.MarkdownStandardTextDecoratorTestCase)
test for bold_italic pattern 2 ... ok
test_bold_italic_p3 (__main__.MarkdownStandardTextDecoratorTestCase)
test for bold_italic pattern 3 ... ok
test_bold_p1 (__main__.MarkdownStandardTextDecoratorTestCase)
test for bold pattern 1 ... ok
test_bold_p2 (__main__.MarkdownStandardTextDecoratorTestCase)
test for bold pattern 2 ... ok
test_italic_p1 (__main__.MarkdownStandardTextDecoratorTestCase)
test for italic pattern 1 ... ok
test_italic_p2 (__main__.MarkdownStandardTextDecoratorTestCase)
test for italic pattern 2 ... ok
test_normal (__main__.MarkdownStandardTextDecoratorTestCase)
test for normal ... ok
test_all (__main__.MarkdownTextDecoratorTestCase)
test for all at once ... ok
test_delete (__main__.MarkdownTextDecoratorTestCase)
test for delete ... ok
test_insert (__main__.MarkdownTextDecoratorTestCase)
test for insert ... ok
test_mark (__main__.MarkdownTextDecoratorTestCase)
test for mark ... ok
test_overline (__main__.MarkdownTextDecoratorTestCase)
test for overline ... ok
test_ruby (__main__.MarkdownTextDecoratorTestCase)
test for ruby ... ok
test_strikethrough (__main__.MarkdownTextDecoratorTestCase)
test for strikethrough ... ok
test_subscript (__main__.MarkdownTextDecoratorTestCase)
test for subscript ... ok
test_superscript (__main__.MarkdownTextDecoratorTestCase)
test for superscript ... ok
test_underline (__main__.MarkdownTextDecoratorTestCase)
test for underline ... ok
test_underoverline (__main__.MarkdownTextDecoratorTestCase)
test for underoverline ... ok

----------------------------------------------------------------------
Ran 19 tests in 0.020s
```


## CHANGE LOG

### v3.2.0

Add Extension param "priority".

### v3.1.1

Fix bug.

### v3.1.0

Refactor codes and update README.

### v3.0.1

Add unittest for Checking markdown_text_decorator does not destruct [Python-Markdown] standard text decoration.
- Italic, Bold, Italic+Bold.

### v3.0.0

Support overline, underline and underoverline.

Add unittest for them.

### v2.0.0

Support ruby and add unittest for ruby.

### v1.2.0

Support mark and add unittest for mark.

### v1.1.1

Add unittest for strikethrough, insert, delete, superscript and subscript.

### v1.1.0

Support superscript and subscript.

### v1.0.1

Support multi-pairs in one line release.

### v1.0.0

Initial Release.

## Reference

- [CommonMark Spec]
- [Python-Markdown HP]
- [HTML tags]
- [CSS]