~sirn/fanboi2

b964d88ed0fe478b313f33939f5cac5a5ea09902 — Kridsada Thanabulpong 5 years ago d97a444
Switch Markdown parser back to Misaka.
3 files changed, 8 insertions(+), 11 deletions(-)

M fanboi2/formatters.py
M fanboi2/tests/test_formatters.py
M setup.py
M fanboi2/formatters.py => fanboi2/formatters.py +2 -3
@@ 1,12 1,12 @@
import html
import isodate
import misaka
import pytz
import re
import urllib
import urllib.parse as urlparse
from collections import OrderedDict
from html.parser import HTMLParser
from markdown import Markdown
from markupsafe import Markup




@@ 165,8 165,7 @@ def format_markdown(context, request, text):
    :rtype: Markup
    """
    if text is not None:
        markdown = Markdown()
        return Markup(markdown.convert(str(text)))
        return Markup(misaka.html(str(text)))


RE_ANCHOR = re.compile(r'%s(\d+)(\-)?(\d+)?' % html.escape('>>'))

M fanboi2/tests/test_formatters.py => fanboi2/tests/test_formatters.py +4 -4
@@ 171,10 171,10 @@ class TestFormatters(unittest.TestCase):
        from markupsafe import Markup
        request = self._makeRequest()
        tests = [
            ('**Hello, world!**', '<p><strong>Hello, world!</strong></p>'),
            ('<b>Foobar</b>', '<p><b>Foobar</b></p>'),
            ('Split\n\nParagraph', '<p>Split</p>\n<p>Paragraph</p>'),
            ('Split\nlines', '<p>Split\nlines</p>'),
            ('**Hello, world!**', '<p><strong>Hello, world!</strong></p>\n'),
            ('<b>Foobar</b>', '<p><b>Foobar</b></p>\n'),
            ('Split\n\nParagraph', '<p>Split</p>\n\n<p>Paragraph</p>\n'),
            ('Split\nlines', '<p>Split\nlines</p>\n'),
        ]
        for source, target in tests:
            self.assertEqual(format_markdown(None, request, source),

M setup.py => setup.py +2 -4
@@ 29,17 29,15 @@ requires = [
    'requests',

    # Frontend
    'isodate',
    'MarkupSafe',
    'isodate',
    'misaka',
    'wtforms',

    # Tests
    'nose',
    'coverage',

    # To be deprecate.
    'Markdown==2.5.2',

    ]

setup(name='fanboi2',