You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@allura.apache.org by ke...@apache.org on 2022/02/11 17:36:46 UTC

[allura] 09/12: [#8408] upgrade to markdown 3.2; drop attr_list extension

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 a82172be4a87b4bb7899254bd1854ca971defd15
Author: Dave Brondsema <db...@slashdotmedia.com>
AuthorDate: Tue Jan 18 13:30:16 2022 -0500

    [#8408] upgrade to markdown 3.2; drop attr_list extension
    
    attr_list is rarely used, and rarely would we want end-users to set CSS
    classes or IDs anyway (although they could through HTML).  Most importantly
    it is unexpected syntax for users and so curly braces can be interpreted
    not how the user wants (and be removed from output text then)
---
 Allura/allura/lib/app_globals.py                       |  3 ++-
 Allura/allura/lib/markdown_extensions.py               |  9 +++++----
 Allura/allura/tests/test_globals.py                    | 17 ++++++-----------
 Allura/allura/tests/test_helpers.py                    |  4 ++--
 ForgeGit/forgegit/tests/functional/test_controllers.py |  4 ++--
 requirements.txt                                       | 10 ++++++++--
 6 files changed, 25 insertions(+), 22 deletions(-)

diff --git a/Allura/allura/lib/app_globals.py b/Allura/allura/lib/app_globals.py
index e6f703a..44d81f3 100644
--- a/Allura/allura/lib/app_globals.py
+++ b/Allura/allura/lib/app_globals.py
@@ -447,7 +447,8 @@ class Globals(object):
         '''return a markdown.Markdown object on which you can call convert'''
         return ForgeMarkdown(
             extensions=['markdown.extensions.fenced_code', 'markdown.extensions.codehilite',
-                        'markdown.extensions.extra',  # to allow markdown inside HTML tags
+                        'markdown.extensions.abbr', 'markdown.extensions.def_list', 'markdown.extensions.footnotes',
+                        'markdown.extensions.md_in_html',
                         ForgeExtension(**kwargs), EmojiExtension(), UserMentionExtension(),
                         'markdown.extensions.tables', 'markdown.extensions.toc', 'markdown.extensions.nl2br',
                         'markdown_checklist.extension'],
diff --git a/Allura/allura/lib/markdown_extensions.py b/Allura/allura/lib/markdown_extensions.py
index 826a3ae..27303c0 100644
--- a/Allura/allura/lib/markdown_extensions.py
+++ b/Allura/allura/lib/markdown_extensions.py
@@ -22,6 +22,7 @@ from __future__ import absolute_import
 import re
 import logging
 from typing import List
+import xml.etree.ElementTree as etree
 
 from six.moves.urllib.parse import urljoin
 
@@ -333,7 +334,7 @@ class UserMentionInlinePattern(markdown.inlinepatterns.Pattern):
         result = None
 
         if user and not user.pending and not user.disabled:
-            result = markdown.util.etree.Element('a')
+            result = etree.Element('a')
             result.text = "@%s" % user_name
             result.set('href', user.url())
             result.set('class', 'user-mention')
@@ -351,7 +352,7 @@ class ForgeLinkPattern(markdown.inlinepatterns.Pattern):
         super().__init__(*args, **kwargs)
 
     def handleMatch(self, m):
-        el = markdown.util.etree.Element('a')
+        el = etree.Element('a')
         el.text = m.group(2)
         is_link_with_brackets = False
         try:
@@ -383,7 +384,7 @@ class ForgeLinkPattern(markdown.inlinepatterns.Pattern):
 
         if 'notfound' in classes and not self.ext._use_wiki:
             text = el.text
-            el = markdown.util.etree.Element('span')
+            el = etree.Element('span')
             el.text = '[%s]' % text
         return el
 
@@ -536,7 +537,7 @@ class AutolinkPattern(markdown.inlinepatterns.Pattern):
 
     def handleMatch(self, mo):
         old_link = mo.group(2)
-        result = markdown.util.etree.Element('a')
+        result = etree.Element('a')
         result.text = old_link
         # since this is run before the builtin 'escape' processor, we have to
         # do our own unescaping
diff --git a/Allura/allura/tests/test_globals.py b/Allura/allura/tests/test_globals.py
index 51f10c0..019e406 100644
--- a/Allura/allura/tests/test_globals.py
+++ b/Allura/allura/tests/test_globals.py
@@ -483,9 +483,9 @@ Some text in a regular paragraph
         # no <br
         '<div class="markdown_content"><h1 id="header">Header</h1>\n'
         '<p>Some text in a regular paragraph</p>\n'
-        '<div class="codehilite"><pre><span></span><span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="mi">10</span><span class="p">):</span>\n'
+        '<div class="codehilite"><pre><span></span><code><span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="mi">10</span><span class="p">):</span>\n'
         '    <span class="nb">print</span> <span class="n">i</span>\n'
-        '</pre></div>\n'
+        '</code></pre></div>\n'
         '\n'
         '</div>'
     )
@@ -499,8 +499,8 @@ Some text in a regular paragraph
 ~~~~
 def foo(): pass
 ~~~~'''),
-        '<div class="markdown_content"><div class="codehilite"><pre><span></span>def foo(): pass\n'
-        '</pre></div>\n'
+        '<div class="markdown_content"><div class="codehilite"><pre><span></span><code>def foo(): pass\n'
+        '</code></pre></div>\n'
         '\n'
         '</div>'
     )
@@ -569,7 +569,7 @@ def test_markdown_autolink():
               g.markdown.convert('a blahttp://sdf.com z'))
     assert_in('literal <code>http://domain.net</code> literal',
               g.markdown.convert('literal `http://domain.net` literal'))
-    assert_in('<pre><span></span>preformatted http://domain.net\n</pre>',
+    assert_in('<pre><span></span><code>preformatted http://domain.net\n</code></pre>',
               g.markdown.convert('    :::text\n'
                                  '    preformatted http://domain.net'))
 
@@ -916,12 +916,7 @@ class TestEmojis(unittest.TestCase):
         output = g.markdown.convert('```html\n<p>:camel:</p>\n```')
         assert_in(':camel:', output)
         output = g.markdown.convert('~~~\n:camel:\n~~~')
-        try:
-            # older pygments
-            assert_in('<span></span><span class="err">:camel:</span>', output)
-        except AssertionError:
-            # newer pygments
-            assert_in('<pre><span></span>:camel:\n</pre>', output)
+        assert_in('<pre><span></span><code>:camel:\n</code></pre>', output)
 
     def test_markdown_commit_with_emojis(self):
         output = g.markdown_commit.convert('Thumbs up emoji :+1: wow!')
diff --git a/Allura/allura/tests/test_helpers.py b/Allura/allura/tests/test_helpers.py
index d57b598..5250db8 100644
--- a/Allura/allura/tests/test_helpers.py
+++ b/Allura/allura/tests/test_helpers.py
@@ -273,9 +273,9 @@ def test_render_any_markup_formatting():
     assert_equals(str(h.render_any_markup('README.md', '### foo\n'
                                           '    <script>alert(1)</script> bar')),
                   '<div class="markdown_content"><h3 id="foo">foo</h3>\n'
-                  '<div class="codehilite"><pre><span></span><span class="nt">'
+                  '<div class="codehilite"><pre><span></span><code><span class="nt">'
                   '&lt;script&gt;</span>alert(1)<span class="nt">'
-                  '&lt;/script&gt;</span> bar\n</pre></div>\n\n</div>')
+                  '&lt;/script&gt;</span> bar\n</code></pre></div>\n\n</div>')
 
 
 def test_render_any_markdown_encoding():
diff --git a/ForgeGit/forgegit/tests/functional/test_controllers.py b/ForgeGit/forgegit/tests/functional/test_controllers.py
index 3a5a474..81fde01 100644
--- a/ForgeGit/forgegit/tests/functional/test_controllers.py
+++ b/ForgeGit/forgegit/tests/functional/test_controllers.py
@@ -902,12 +902,12 @@ class TestFork(_TestCase):
 </li>
 </ul>
 <p>Diff:</p>
-<div class="codehilite"><pre><span></span><span class="gd">--- old</span>
+<div class="codehilite"><pre><span></span><code><span class="gd">--- old</span>
 <span class="gi">+++ new</span>
 <span class="gu">@@ -1 +1 @@</span>
 <span class="gd">-description</span>
 <span class="gi">+changed description</span>
-</pre></div>
+</code></pre></div>
 </div>
 """.strip())
 
diff --git a/requirements.txt b/requirements.txt
index d2ed980..a2d4c66 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -67,13 +67,15 @@ httplib2==0.19.0
     # via oauth2
 idna==3.2
     # via requests
+importlib-metadata==4.10.1
+    # via markdown
 inflection==0.5.1
     # via profanityfilter
 iso8601==0.1.16
     # via colander
 jinja2==3.0.2
     # via -r requirements.in
-markdown==3.1.1
+markdown==3.2.2
     # via
     #   -r requirements.in
     #   markdown-checklist
@@ -194,7 +196,9 @@ translationstring==1.4
 turbogears2==2.3.12
     # via -r requirements.in
 typing-extensions==3.10.0.2
-    # via gitpython
+    # via
+    #   gitpython
+    #   importlib-metadata
 urllib3==1.26.6
     # via requests
 waitress==2.0.0
@@ -218,6 +222,8 @@ werkzeug==2.0.2
     # via -r requirements.in
 wrapt==1.11.2
     # via -r requirements.in
+zipp==3.7.0
+    # via importlib-metadata
 
 # The following packages are considered to be unsafe in a requirements file:
 # setuptools