allura-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kentontay...@apache.org
Subject [allura] 10/17: [#8325] upgrade markdown to 2.3.x
Date Wed, 04 Sep 2019 19:15:15 GMT
This is an automated email from the ASF dual-hosted git repository.

kentontaylor pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/allura.git

commit d8f43d251ca46624f9c329d60bfe4a4fffdecf24
Author: Dave Brondsema <dave@brondsema.net>
AuthorDate: Wed Aug 21 11:52:28 2019 -0400

    [#8325] upgrade markdown to 2.3.x
---
 Allura/allura/lib/markdown_extensions.py           | 36 -----------------
 Allura/allura/model/repo_refresh.py                |  2 +-
 Allura/allura/templates/widgets/repo/log.html      |  2 +-
 Allura/allura/templates/widgets/repo/revision.html |  2 +-
 ForgeBlog/forgeblog/tests/test_commands.py         | 45 ----------------------
 .../forgegit/tests/functional/test_controllers.py  |  2 +-
 requirements.in                                    |  2 +-
 requirements.txt                                   |  4 +-
 8 files changed, 7 insertions(+), 88 deletions(-)

diff --git a/Allura/allura/lib/markdown_extensions.py b/Allura/allura/lib/markdown_extensions.py
index ed093b3..4f399a7 100644
--- a/Allura/allura/lib/markdown_extensions.py
+++ b/Allura/allura/lib/markdown_extensions.py
@@ -36,10 +36,6 @@ from allura.lib.utils import ForgeHTMLSanitizerFilter, is_nofollow_url
 
 log = logging.getLogger(__name__)
 
-PLAINTEXT_BLOCK_RE = re.compile(
-    r'(?P<bplain>\[plain\])(?P<code>.*?)(?P<eplain>\[\/plain\])',
-    re.MULTILINE | re.DOTALL
-)
 
 MACRO_PATTERN = r'\[\[([^\]\[]+)\]\]'
 
@@ -251,7 +247,6 @@ class ForgeExtension(markdown.Extension):
         # allow markdown within e.g. <div markdown>...</div>  More info at:
         # https://github.com/waylan/Python-Markdown/issues/52
         md.preprocessors['html_block'].markdown_in_raw = True
-        md.preprocessors.add('plain_text_block', PlainTextPreprocessor(md), "_begin")
         md.preprocessors.add('macro_include', ForgeMacroIncludePreprocessor(md), '_end')
         # this has to be before the 'escape' processor, otherwise weird
         # placeholders are inserted for escaped chars within urls, and then the
@@ -397,37 +392,6 @@ class ForgeLinkPattern(markdown.inlinepatterns.LinkPattern):
         return href, classes
 
 
-class PlainTextPreprocessor(markdown.preprocessors.Preprocessor):
-
-    '''
-    This was used earlier for [plain] tags that the Blog tool's rss importer
-    created, before html2text did good escaping of all special markdown chars.
-    Can be deprecated.
-    '''
-
-    def run(self, lines):
-        text = "\n".join(lines)
-        while 1:
-            res = PLAINTEXT_BLOCK_RE.finditer(text)
-            for m in res:
-                code = self._escape(m.group('code'))
-                placeholder = self.markdown.htmlStash.store(code, safe=True)
-                text = '%s%s%s' % (
-                    text[:m.start()], placeholder, text[m.end():])
-                break
-            else:
-                break
-        return text.split("\n")
-
-    def _escape(self, txt):
-        """ basic html escaping """
-        txt = txt.replace('&', '&amp;')
-        txt = txt.replace('<', '&lt;')
-        txt = txt.replace('>', '&gt;')
-        txt = txt.replace('"', '&quot;')
-        return txt
-
-
 class ForgeMacroPattern(markdown.inlinepatterns.Pattern):
 
     def __init__(self, *args, **kwargs):
diff --git a/Allura/allura/model/repo_refresh.py b/Allura/allura/model/repo_refresh.py
index 9712164..8585ffe 100644
--- a/Allura/allura/model/repo_refresh.py
+++ b/Allura/allura/model/repo_refresh.py
@@ -217,7 +217,7 @@ def send_notifications(repo, commit_ids):
                 link=href,
                 unique_id=href)
 
-            summary = g.markdown_commit.convert(ci.message) if ci.message else ""
+            summary = g.markdown_commit.convert(ci.message.strip()) if ci.message else ""
             current_branch = repo.symbolics_for_commit(ci)[0]  # only the head of a branch
will have this
             commit_msgs.append(dict(
                 author=ci.authored.name,
diff --git a/Allura/allura/templates/widgets/repo/log.html b/Allura/allura/templates/widgets/repo/log.html
index 90899c0..68c040d 100644
--- a/Allura/allura/templates/widgets/repo/log.html
+++ b/Allura/allura/templates/widgets/repo/log.html
@@ -54,7 +54,7 @@
                 {%- if commit.committed.email != commit.authored.email %},
                 pushed by {{ email_link(commit.committed.email, commit.committed.name) }}
                 {% endif %}
-                {{ h.hide_private_info(g.markdown_commit.convert(commit.message)) }}
+                {{ h.hide_private_info(g.markdown_commit.convert(commit.message.strip()))
}}
                 {% if commit.rename_details %}
                     <div>
                       <b>renamed from</b>
diff --git a/Allura/allura/templates/widgets/repo/revision.html b/Allura/allura/templates/widgets/repo/revision.html
index 1d32953..309b332 100644
--- a/Allura/allura/templates/widgets/repo/revision.html
+++ b/Allura/allura/templates/widgets/repo/revision.html
@@ -20,7 +20,7 @@
 <div class="commit-details">
     <div class="commit-message">
         <div class="first-line">{{ h.hide_private_info(g.markdown_commit.convert(h.really_unicode(value.message.split('\n')[0])))
}}</div>
-        {{ h.hide_private_info(g.markdown_commit.convert(h.really_unicode('\n'.join(value.message.split('\n')[1:]))))
}}
+        {{ h.hide_private_info(g.markdown_commit.convert(h.really_unicode('\n'.join(value.message.split('\n')[1:])).strip()))
}}
     </div>
     <div class="commit-details">
 
diff --git a/ForgeBlog/forgeblog/tests/test_commands.py b/ForgeBlog/forgeblog/tests/test_commands.py
index 405b4a2..87f9c2b 100644
--- a/ForgeBlog/forgeblog/tests/test_commands.py
+++ b/ForgeBlog/forgeblog/tests/test_commands.py
@@ -131,48 +131,3 @@ def test_pull_rss_feeds(parsefeed):
     assert_equal(posts[3].title, 'Default Title 4')
     assert_equal(posts[3].text, rendered_html_content)
 
-
-@skipif(module_not_available('html2text'))
-def test_plaintext_preprocessor():
-    from forgeblog.command import rssfeeds  # importing this sets html2text.BODY_WIDTH to
a value this test expects
-    from html2text import html2text
-    text = html2text(
-        "[plain]1. foo[/plain]\n"
-        "\n"
-        "[plain]#foo bar [/plain]<a href='baz'>[plain]baz[/plain]</a>\n"
-        "[plain]foo bar[/plain]\n"
-        "\n"
-        "[plain]#foo bar [/plain]<a href='baz'>\n"
-        "[plain]baz[/plain]\n"
-        "</a>\n"
-    )
-    html = g.markdown.convert(text)
-    assert_equal(html,
-                 '<div class="markdown_content"><p>1. foo '
-                 '#foo bar <a class="" href="../baz">baz</a> foo bar '
-                 '#foo bar <a class="" href="../baz"> baz </a></p></div>'
-                 )
-
-
-@skipif(module_not_available('html2text'))
-def test_plaintext_preprocessor_wrapped():
-    from forgeblog.command import rssfeeds  # importing this sets html2text.BODY_WIDTH to
a value this test expects
-    from html2text import html2text
-    text = html2text(
-        "<p>[plain]1. foo[/plain]</p>\n"
-        "\n"
-        "<p>\n"
-        "[plain]#foo bar [/plain]<a href='baz'>[plain]baz[/plain]</a>\n"
-        "[plain]foo bar[/plain]\n"
-        "</p>\n"
-        "\n"
-        "<p>[plain]#foo bar [/plain]<a href='baz'>\n"
-        "[plain]baz[/plain]\n"
-        "</a></p>\n"
-    )
-    html = g.markdown.convert(text)
-    assert_equal(html,
-                 '<div class="markdown_content"><p>1. foo</p>\n'
-                 '<p>#foo bar <a class="" href="../baz">baz</a> foo bar
</p>\n'
-                 '<p>#foo bar <a class="" href="../baz"> baz </a></p></div>'
-                 )
diff --git a/ForgeGit/forgegit/tests/functional/test_controllers.py b/ForgeGit/forgegit/tests/functional/test_controllers.py
index ffd0971..1f2aa0c 100644
--- a/ForgeGit/forgegit/tests/functional/test_controllers.py
+++ b/ForgeGit/forgegit/tests/functional/test_controllers.py
@@ -159,7 +159,7 @@ class TestRootController(_TestCase):
     def test_log(self):
         resp = self.app.get('/src-git/ci/1e146e67985dcd71c74de79613719bef7bddca4a/log/')
         assert 'Initial commit' in resp
-        assert '<div class="markdown_content"><p>Change README</div>' in
resp
+        assert '<div class="markdown_content"><p>Change README</div>' in
resp, resp
         assert 'tree/README?format=raw">Download</a>' not in resp
         assert 'Tree' in resp.html.findAll('td')[2].text, resp.html.findAll('td')[2].text
         assert_in('by Rick Copeland', squish_spaces(resp.html.findAll('td')[0].text))
diff --git a/requirements.in b/requirements.in
index d316140..c05a8e8 100644
--- a/requirements.in
+++ b/requirements.in
@@ -15,7 +15,7 @@ FormEncode
 GitPython==2.1.11
 html5lib==1.0.1
 Jinja2==2.10
-Markdown==2.2.1
+Markdown<2.4
 markdown-checklist==0.4.1
 MarkupSafe
 Ming==0.5.6
diff --git a/requirements.txt b/requirements.txt
index 7731c01..5677271 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -49,7 +49,7 @@ isort==4.3.21             # via pylint
 jinja2==2.10
 lazy-object-proxy==1.4.1  # via astroid
 markdown-checklist==0.4.1
-markdown==2.2.1
+markdown==2.3.1
 markupsafe==1.1.1
 mccabe==0.6.1             # via pylint
 ming==0.5.6
@@ -105,4 +105,4 @@ webtest==2.0.33
 wrapt==1.11.2
 
 # The following packages are considered to be unsafe in a requirements file:
-# setuptools==41.1.0        # via ipython
+# setuptools==41.2.0        # via ipython


Mime
View raw message