commit
c26d59de08
@ -19,6 +19,7 @@ Changelog for Isso
|
|||||||
- Add optionnal gravatar support
|
- Add optionnal gravatar support
|
||||||
- Add nofollow noopener on links inside comments
|
- Add nofollow noopener on links inside comments
|
||||||
- Add Dockerfile
|
- Add Dockerfile
|
||||||
|
- Upgraded to Misaka 2
|
||||||
- Some tests/travis/documentation improvements and fixes + pep8
|
- Some tests/travis/documentation improvements and fixes + pep8
|
||||||
- Improvement on german translation
|
- Improvement on german translation
|
||||||
|
|
||||||
|
@ -89,5 +89,8 @@ In chronological order:
|
|||||||
* @benjhess
|
* @benjhess
|
||||||
* Optionnal gravatar support
|
* Optionnal gravatar support
|
||||||
|
|
||||||
|
* Steffen Prince @sprin
|
||||||
|
* Upgrade to Misaka 2
|
||||||
|
|
||||||
* [Your name or handle] <[email or website]>
|
* [Your name or handle] <[email or website]>
|
||||||
* [Brief summary of your changes]
|
* [Brief summary of your changes]
|
||||||
|
@ -29,7 +29,7 @@ class TestHTML(unittest.TestCase):
|
|||||||
self.assertEqual(convert(input), expected)
|
self.assertEqual(convert(input), expected)
|
||||||
|
|
||||||
def test_github_flavoured_markdown(self):
|
def test_github_flavoured_markdown(self):
|
||||||
convert = html.Markdown(extensions=("fenced_code", ))
|
convert = html.Markdown(extensions=("fenced-code", ))
|
||||||
|
|
||||||
# without lang
|
# without lang
|
||||||
_in = textwrap.dedent("""\
|
_in = textwrap.dedent("""\
|
||||||
|
@ -2,7 +2,6 @@
|
|||||||
|
|
||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
import operator
|
|
||||||
import pkg_resources
|
import pkg_resources
|
||||||
|
|
||||||
from distutils.version import LooseVersion as Version
|
from distutils.version import LooseVersion as Version
|
||||||
@ -10,8 +9,6 @@ from distutils.version import LooseVersion as Version
|
|||||||
HTML5LIB_VERSION = Version(pkg_resources.get_distribution("html5lib").version)
|
HTML5LIB_VERSION = Version(pkg_resources.get_distribution("html5lib").version)
|
||||||
HTML5LIB_SIMPLETREE = Version("0.95")
|
HTML5LIB_SIMPLETREE = Version("0.95")
|
||||||
|
|
||||||
from isso.compat import reduce
|
|
||||||
|
|
||||||
import html5lib
|
import html5lib
|
||||||
from html5lib.sanitizer import HTMLSanitizer
|
from html5lib.sanitizer import HTMLSanitizer
|
||||||
from html5lib.serializer import HTMLSerializer
|
from html5lib.serializer import HTMLSerializer
|
||||||
@ -23,7 +20,8 @@ def Sanitizer(elements, attributes):
|
|||||||
|
|
||||||
class Inner(HTMLSanitizer):
|
class Inner(HTMLSanitizer):
|
||||||
|
|
||||||
# attributes found in Sundown's HTML serializer [1] except for <img> tag,
|
# attributes found in Sundown's HTML serializer [1]
|
||||||
|
# except for <img> tag,
|
||||||
# because images are not generated anyways.
|
# because images are not generated anyways.
|
||||||
#
|
#
|
||||||
# [1] https://github.com/vmg/sundown/blob/master/html/html.c
|
# [1] https://github.com/vmg/sundown/blob/master/html/html.c
|
||||||
@ -65,14 +63,14 @@ def sanitize(tokenizer, document):
|
|||||||
return serializer.render(stream)
|
return serializer.render(stream)
|
||||||
|
|
||||||
|
|
||||||
def Markdown(extensions=("strikethrough", "superscript", "autolink")):
|
def Markdown(extensions=("strikethrough", "superscript", "autolink",
|
||||||
|
"fenced-code")):
|
||||||
|
|
||||||
flags = reduce(operator.xor, map(
|
renderer = Unofficial()
|
||||||
lambda ext: getattr(misaka, 'EXT_' + ext.upper()), extensions), 0)
|
md = misaka.Markdown(renderer, extensions=extensions)
|
||||||
md = misaka.Markdown(Unofficial(), extensions=flags)
|
|
||||||
|
|
||||||
def inner(text):
|
def inner(text):
|
||||||
rv = md.render(text).rstrip("\n")
|
rv = md(text).rstrip("\n")
|
||||||
if rv.startswith("<p>") or rv.endswith("</p>"):
|
if rv.startswith("<p>") or rv.endswith("</p>"):
|
||||||
return rv
|
return rv
|
||||||
return "<p>" + rv + "</p>"
|
return "<p>" + rv + "</p>"
|
||||||
@ -88,7 +86,7 @@ class Unofficial(misaka.HtmlRenderer):
|
|||||||
to <code class="$lang">, compatible with Highlight.js.
|
to <code class="$lang">, compatible with Highlight.js.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def block_code(self, text, lang):
|
def blockcode(self, text, lang):
|
||||||
lang = ' class="{0}"'.format(lang) if lang else ''
|
lang = ' class="{0}"'.format(lang) if lang else ''
|
||||||
return "<pre><code{1}>{0}</code></pre>\n".format(text, lang)
|
return "<pre><code{1}>{0}</code></pre>\n".format(text, lang)
|
||||||
|
|
||||||
|
5
setup.py
5
setup.py
@ -5,8 +5,8 @@ import sys
|
|||||||
|
|
||||||
from setuptools import setup, find_packages
|
from setuptools import setup, find_packages
|
||||||
|
|
||||||
requires = ['html5lib==0.9999999', 'itsdangerous', 'Jinja2',
|
requires = ['itsdangerous', 'Jinja2', 'misaka>=2.0,<3.0', 'html5lib<0.9999999',
|
||||||
'misaka>=1.0,<2.0', 'werkzeug>=0.9']
|
'werkzeug>=0.9']
|
||||||
|
|
||||||
if sys.version_info < (2, 7):
|
if sys.version_info < (2, 7):
|
||||||
raise SystemExit("Python 2 versions < 2.7 are not supported.")
|
raise SystemExit("Python 2 versions < 2.7 are not supported.")
|
||||||
@ -39,6 +39,7 @@ setup(
|
|||||||
extras_require={
|
extras_require={
|
||||||
':python_version=="2.7"': ['ipaddr>=2.1', 'configparser']
|
':python_version=="2.7"': ['ipaddr>=2.1', 'configparser']
|
||||||
},
|
},
|
||||||
|
setup_requires=["cffi>=1.3.0"],
|
||||||
entry_points={
|
entry_points={
|
||||||
'console_scripts':
|
'console_scripts':
|
||||||
['isso = isso:main'],
|
['isso = isso:main'],
|
||||||
|
Loading…
Reference in New Issue
Block a user