From eb020436c1aae08d67ab34bbc4d37fb0cfd5773e Mon Sep 17 00:00:00 2001 From: FND Date: Sun, 1 Sep 2013 14:31:11 +0200 Subject: [PATCH] initial commit --- Makefile | 33 +++++++++++++++++++++++++++++ README | 7 +++++++ README.md | 1 + markdown_checklist/__init__.py | 37 +++++++++++++++++++++++++++++++++ test/__init__.py | 0 test/test_main.py | 38 ++++++++++++++++++++++++++++++++++ 6 files changed, 116 insertions(+) create mode 100644 Makefile create mode 100644 README create mode 120000 README.md create mode 100644 markdown_checklist/__init__.py create mode 100644 test/__init__.py create mode 100644 test/test_main.py diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..a92f80b --- /dev/null +++ b/Makefile @@ -0,0 +1,33 @@ +.PHONY: test lint coverage clean + +readme: + python -c "import markdown_checklist as cl; print cl.__doc__.strip()" > README + +test: clean + py.test -s --tb=short test + +lint: + find . -name "*.py" -not -path "./venv/*" | while read filepath; do \ + pep8 --ignore=E128,E261 $$filepath; \ + done + #upyflakes $$filepath; \ + #pylint --reports=n --include-ids=y $$filepath; \ + +coverage: clean + # option #1: figleaf + find . test -name "*.py" > coverage.lst + figleaf `which py.test` test + figleaf2html -f coverage.lst + # option #2: coverage + coverage run `which py.test` test + coverage html + # reports + coverage report + @echo "[INFO] additional reports in \`html/index.html\` (figleaf) and" \ + "\`htmlcov/index.html\` (coverage)" + +clean: + find . -name "*.pyc" -print0 | xargs -0 rm || true + rm -rf html .figleaf coverage.lst # figleaf + rm -rf htmlcov .coverage # coverage + rm -rf test/__pycache__ # pytest diff --git a/README b/README new file mode 100644 index 0000000..2531665 --- /dev/null +++ b/README @@ -0,0 +1,7 @@ +Markdown Checklist + +a [Python Markdown](http://pythonhosted.org/Markdown/) extension for lists of +tasks with checkboxes + +inspired by +[GitHub task lists](https://github.com/blog/1375-task-lists-in-gfm-issues-pulls-comments) diff --git a/README.md b/README.md new file mode 120000 index 0000000..100b938 --- /dev/null +++ b/README.md @@ -0,0 +1 @@ +README \ No newline at end of file diff --git a/markdown_checklist/__init__.py b/markdown_checklist/__init__.py new file mode 100644 index 0000000..d6e0a30 --- /dev/null +++ b/markdown_checklist/__init__.py @@ -0,0 +1,37 @@ +""" +Markdown Checklist + +a [Python Markdown](http://pythonhosted.org/Markdown/) extension for lists of +tasks with checkboxes + +inspired by +[GitHub task lists](https://github.com/blog/1375-task-lists-in-gfm-issues-pulls-comments) +""" + +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), + '' % (list_prefix, checked) diff --git a/test/__init__.py b/test/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/test/test_main.py b/test/test_main.py new file mode 100644 index 0000000..4220e51 --- /dev/null +++ b/test/test_main.py @@ -0,0 +1,38 @@ +import markdown + +from markdown_checklist import ChecklistExtension + + +def test_checkbox(): + source = """ +Hello World +=========== + +* [ ] foo +* [x] bar +* [ ] baz + +lorem ipsum + """.strip() + + html = markdown.markdown(source) + assert html == """ +

Hello World

+ +

lorem ipsum

+ """.strip() + + html = markdown.markdown(source, extensions=[ChecklistExtension()]) + assert html == """ +

Hello World

+ +

lorem ipsum

+ """.strip()