Skip to content

Commit

Permalink
support ~~strikethrough~~ and ++underscores++
Browse files Browse the repository at this point in the history
  • Loading branch information
agusmakmun committed Jan 13, 2017
1 parent f722347 commit 5a4cacc
Show file tree
Hide file tree
Showing 7 changed files with 72 additions and 3 deletions.
1 change: 1 addition & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ to get ``IMGUR_CLIENT_ID`` and ``IMGUR_API_KEY``.

# Custom markdown extensions.
'draceditor.extensions.urlize',
'draceditor.extensions.del_ins', # ~~strikethrough~~ and ++underscores++
'draceditor.extensions.mention', # require for mention
'draceditor.extensions.emoji', # require for emoji
]
Expand Down
2 changes: 1 addition & 1 deletion draceditor/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-

__VERSION__ = '1.1.4'
__VERSION__ = '1.1.5'
__AUTHOR__ = 'Agus Makmun (Summon Agus)'
__AUTHOR_EMAIL__ = 'agus@python.web.id'
51 changes: 51 additions & 0 deletions draceditor/extensions/del_ins.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
#! /usr/bin/env python


'''
Del/Ins Extension for Python-Markdown
=====================================
Wraps the inline content with ins/del tags.
Usage
-----
>>> import markdown
>>> src = """This is ++added content++ and this is ~~deleted content~~"""
>>> html = markdown.markdown(src, ['del_ins'])
>>> print(html)
<p>This is <ins>added content</ins> and this is <del>deleted content</del>
</p>
Dependencies
------------
* [Markdown 2.0+](http://www.freewisdom.org/projects/python-markdown/)
Copyright
---------
2011, 2012 [The active archives contributors](http://activearchives.org/)
All rights reserved.
This software is released under the modified BSD License.
See LICENSE.md for details.
'''


import markdown
from markdown.inlinepatterns import SimpleTagPattern


DEL_RE = r"(\~\~)(.+?)(\~\~)"
INS_RE = r"(\+\+)(.+?)(\+\+)"


class DelInsExtension(markdown.extensions.Extension):
"""Adds del_ins extension to Markdown class."""

def extendMarkdown(self, md, md_globals):
"""Modifies inline patterns."""
md.inlinePatterns.add('del', SimpleTagPattern(DEL_RE, 'del'), '<not_strong')
md.inlinePatterns.add('ins', SimpleTagPattern(INS_RE, 'ins'), '<not_strong')


def makeExtension(configs={}):
return DelInsExtension(configs=dict(configs))


if __name__ == "__main__":
import doctest
doctest.testmod()
1 change: 1 addition & 0 deletions draceditor/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@

# Custom markdown extensions.
'draceditor.extensions.urlize',
'draceditor.extensions.del_ins', # ~~strikethrough~~ and ++underscores++
'draceditor.extensions.mention', # to parse markdown mention
'draceditor.extensions.emoji', # to parse markdown emoji
]
Expand Down
2 changes: 1 addition & 1 deletion draceditor/static/js/draceditor.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Name : DracEditor v1.1.4
* Name : DracEditor v1.1.5
* Created by : Agus Makmun (Summon Agus)
* Release date : 5-Jan-2017
* Official : https://dracos-linux.org
Expand Down
16 changes: 15 additions & 1 deletion draceditor/templates/draceditor/guide.html
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,20 @@
<td>Command+B</td>
<td><strong>Bold</strong></td>
</tr>
<tr>
<td>++Underscores++</td>
<td>&mdash;</td>
<td>&mdash;</td>
<td>&mdash;</td>
<td><ins>Underscores</ins></td>
</tr>
<tr>
<td>~~Strikethrough~~</td>
<td>&mdash;</td>
<td>&mdash;</td>
<td>&mdash;</td>
<td><del>Strikethrough</del></td>
</tr>
<tr>
<td># Heading 1</td>
<td>Heading 1<br> =========</td>
Expand All @@ -52,7 +66,7 @@
</tr>
<tr>
<td>## Heading 2</td>
<td>Heading 2<br> ---------</td>
<td>Heading 2<br> -----------</td>
<td>Ctrl+Alt+2</td>
<td>Command+Option+2</td>
<td><h2>Heading 2</h2></td>
Expand Down
2 changes: 2 additions & 0 deletions upload.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
# ./upload.sh pypi
if [ "$1" == "pypi" ]; then
python setup.py sdist upload -r pypi
cd ../organization/dracos-markdown-editor
git fetch upstream && git merge upstream/master && git push
fi

if [ "$1" == "git" ]; then
Expand Down

0 comments on commit 5a4cacc

Please sign in to comment.