Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
this required restructuring the package to separate metadata from functionality
- Loading branch information
Showing
5 changed files
with
64 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
*.pyc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import re | ||
|
||
from markdown.extensions import Extension | ||
from markdown.preprocessors import Preprocessor | ||
|
||
|
||
class ChecklistExtension(Extension): | ||
|
||
def extendMarkdown(self, md, md_globals): | ||
md.preprocessors.add('checklist', ChecklistPreprocessor(md), | ||
'<reference') | ||
|
||
|
||
class ChecklistPreprocessor(Preprocessor): | ||
|
||
pattern = re.compile(r'^([*-]) \[([ Xx])\]') | ||
|
||
def run(self, lines): | ||
return [self._transform_line(line) for line in lines] | ||
|
||
def _transform_line(self, line): | ||
return self.pattern.sub(self._replacer, line) | ||
|
||
def _replacer(self, match): | ||
list_prefix, state = match.groups() | ||
checked = ' checked' if state != ' ' else '' | ||
return '%s <input type="checkbox" disabled%s>' % (list_prefix, checked) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import os | ||
|
||
from setuptools import setup, find_packages | ||
|
||
from markdown_checklist import (__version__ as VERSION, __author__ as AUTHOR, | ||
__license__ as LICENSE, __doc__ as DESC) | ||
|
||
|
||
META = { | ||
'name': 'markdown-checklist', | ||
'url': 'https://github.com/FND/markdown-checklist', | ||
'version': VERSION, | ||
'description': 'Python Markdown extension for task lists with checkboxes', | ||
'long_description': DESC.strip(), | ||
'license': LICENSE, | ||
'author': AUTHOR, | ||
'author_email': '', | ||
'maintainer': 'FND', | ||
'packages': find_packages(exclude=['test']), | ||
'platforms': 'Posix; MacOS X; Windows', | ||
'include_package_data': True, | ||
'zip_safe': False, | ||
'install_requires': ['markdown'], | ||
'extras_require': { | ||
'testing': ['pytest'], | ||
'coverage': ['figleaf', 'coverage'] | ||
} | ||
} | ||
|
||
|
||
if __name__ == '__main__': | ||
setup(**META) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters