Skip to content

Commit 5a4cacc

Browse files
committed
support ~~strikethrough~~ and ++underscores++
1 parent f722347 commit 5a4cacc

File tree

7 files changed

+72
-3
lines changed

7 files changed

+72
-3
lines changed

README.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,7 @@ to get ``IMGUR_CLIENT_ID`` and ``IMGUR_API_KEY``.
126126

127127
# Custom markdown extensions.
128128
'draceditor.extensions.urlize',
129+
'draceditor.extensions.del_ins', # ~~strikethrough~~ and ++underscores++
129130
'draceditor.extensions.mention', # require for mention
130131
'draceditor.extensions.emoji', # require for emoji
131132
]

draceditor/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# -*- coding: utf-8 -*-
22

3-
__VERSION__ = '1.1.4'
3+
__VERSION__ = '1.1.5'
44
__AUTHOR__ = 'Agus Makmun (Summon Agus)'
55
__AUTHOR_EMAIL__ = '[email protected]'

draceditor/extensions/del_ins.py

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
#! /usr/bin/env python
2+
3+
4+
'''
5+
Del/Ins Extension for Python-Markdown
6+
=====================================
7+
Wraps the inline content with ins/del tags.
8+
Usage
9+
-----
10+
>>> import markdown
11+
>>> src = """This is ++added content++ and this is ~~deleted content~~"""
12+
>>> html = markdown.markdown(src, ['del_ins'])
13+
>>> print(html)
14+
<p>This is <ins>added content</ins> and this is <del>deleted content</del>
15+
</p>
16+
Dependencies
17+
------------
18+
* [Markdown 2.0+](http://www.freewisdom.org/projects/python-markdown/)
19+
Copyright
20+
---------
21+
2011, 2012 [The active archives contributors](http://activearchives.org/)
22+
All rights reserved.
23+
This software is released under the modified BSD License.
24+
See LICENSE.md for details.
25+
'''
26+
27+
28+
import markdown
29+
from markdown.inlinepatterns import SimpleTagPattern
30+
31+
32+
DEL_RE = r"(\~\~)(.+?)(\~\~)"
33+
INS_RE = r"(\+\+)(.+?)(\+\+)"
34+
35+
36+
class DelInsExtension(markdown.extensions.Extension):
37+
"""Adds del_ins extension to Markdown class."""
38+
39+
def extendMarkdown(self, md, md_globals):
40+
"""Modifies inline patterns."""
41+
md.inlinePatterns.add('del', SimpleTagPattern(DEL_RE, 'del'), '<not_strong')
42+
md.inlinePatterns.add('ins', SimpleTagPattern(INS_RE, 'ins'), '<not_strong')
43+
44+
45+
def makeExtension(configs={}):
46+
return DelInsExtension(configs=dict(configs))
47+
48+
49+
if __name__ == "__main__":
50+
import doctest
51+
doctest.testmod()

draceditor/settings.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141

4242
# Custom markdown extensions.
4343
'draceditor.extensions.urlize',
44+
'draceditor.extensions.del_ins', # ~~strikethrough~~ and ++underscores++
4445
'draceditor.extensions.mention', # to parse markdown mention
4546
'draceditor.extensions.emoji', # to parse markdown emoji
4647
]

draceditor/static/js/draceditor.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* Name : DracEditor v1.1.4
2+
* Name : DracEditor v1.1.5
33
* Created by : Agus Makmun (Summon Agus)
44
* Release date : 5-Jan-2017
55
* Official : https://dracos-linux.org

draceditor/templates/draceditor/guide.html

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,20 @@
4343
<td>Command+B</td>
4444
<td><strong>Bold</strong></td>
4545
</tr>
46+
<tr>
47+
<td>++Underscores++</td>
48+
<td>&mdash;</td>
49+
<td>&mdash;</td>
50+
<td>&mdash;</td>
51+
<td><ins>Underscores</ins></td>
52+
</tr>
53+
<tr>
54+
<td>~~Strikethrough~~</td>
55+
<td>&mdash;</td>
56+
<td>&mdash;</td>
57+
<td>&mdash;</td>
58+
<td><del>Strikethrough</del></td>
59+
</tr>
4660
<tr>
4761
<td># Heading 1</td>
4862
<td>Heading 1<br> =========</td>
@@ -52,7 +66,7 @@
5266
</tr>
5367
<tr>
5468
<td>## Heading 2</td>
55-
<td>Heading 2<br> ---------</td>
69+
<td>Heading 2<br> -----------</td>
5670
<td>Ctrl+Alt+2</td>
5771
<td>Command+Option+2</td>
5872
<td><h2>Heading 2</h2></td>

upload.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
# ./upload.sh pypi
55
if [ "$1" == "pypi" ]; then
66
python setup.py sdist upload -r pypi
7+
cd ../organization/dracos-markdown-editor
8+
git fetch upstream && git merge upstream/master && git push
79
fi
810

911
if [ "$1" == "git" ]; then

0 commit comments

Comments
 (0)