]> git.madduck.net Git - etc/neomutt.git/commitdiff

madduck's git repository

Every one of the projects in this repository is available at the canonical URL git://git.madduck.net/madduck/pub/<projectpath> — see each project's metadata for the exact URL.

All patches and comments are welcome. Please squash your changes to logical commits before using git-format-patch and git-send-email to patches@git.madduck.net. If you'd read over the Git project's submission guidelines and adhered to them, I'd be especially grateful.

SSH access, as well as push access can be individually arranged.

If you use my repositories frequently, consider adding the following snippet to ~/.gitconfig and using the third clone URL listed for each project:

[url "git://git.madduck.net/madduck/"]
  insteadOf = madduck:

manage context for blockquote within admonition
authormartin f. krafft <madduck@madduck.net>
Tue, 21 Nov 2023 13:47:46 +0000 (14:47 +0100)
committermartin f. krafft <madduck@madduck.net>
Tue, 21 Nov 2023 13:50:24 +0000 (14:50 +0100)
.config/neomutt/buildmimetree.py
.config/neomutt/htmlmail.css

index c541ed12094e9ff1c22ab147e5eb9824ff9b6f73..d1f9eaaf6381a1103230ae24ff80c067c169d389 100755 (executable)
@@ -47,6 +47,7 @@ import bs4
 import xml.etree.ElementTree as etree
 import io
 import enum
 import xml.etree.ElementTree as etree
 import io
 import enum
+from contextlib import contextmanager
 from collections import namedtuple, OrderedDict
 from markdown.extensions import Extension
 from markdown.blockprocessors import BlockProcessor
 from collections import namedtuple, OrderedDict
 from markdown.extensions import Extension
 from markdown.blockprocessors import BlockProcessor
@@ -482,8 +483,12 @@ class QuoteToAdmonitionExtension(Extension):
         def __init__(self, parser):
             super().__init__(parser)
             self._title = None
         def __init__(self, parser):
             super().__init__(parser)
             self._title = None
+            self._disable = False
 
         def test(self, parent, blocks):
 
         def test(self, parent, blocks):
+            if self._disable:
+                return False
+
             if markdown.util.nearing_recursion_limit():
                 return False
 
             if markdown.util.nearing_recursion_limit():
                 return False
 
@@ -519,9 +524,16 @@ class QuoteToAdmonitionExtension(Extension):
             self.parser.parseChunk(admonition, self._title)
 
             admonition[0].set("class", "admonition-title")
             self.parser.parseChunk(admonition, self._title)
 
             admonition[0].set("class", "admonition-title")
-            self.parser.parseChunk(
-                admonition, "\n".join(self.clean(line) for line in quotelines)
-            )
+            with self.disable():
+                self.parser.parseChunk(
+                    admonition, "\n".join(quotelines)
+                )
+
+        @contextmanager
+        def disable(self):
+            self._disable = True
+            yield True
+            self._disable = False
 
         @classmethod
         def clean(klass, line):
 
         @classmethod
         def clean(klass, line):
@@ -2037,6 +2049,29 @@ try:
             p = quote.p.extract()
             assert p.contents[1].name == "strong"
 
             p = quote.p.extract()
             assert p.contents[1].name == "strong"
 
+        @pytest.mark.converter
+        def test_converter_attribution_to_admonition_with_blockquote(
+            self, fakepath, fakefilefactory
+        ):
+            mailparts = (
+                "Regarding whatever",
+                "> blockquote line1",
+                "> blockquote line2",
+                "> ",
+                "> new para with **bold** text",
+            )
+            with fakefilefactory(
+                fakepath, content="\n".join(mailparts)
+            ) as draft_f:
+                convert_markdown_to_html(draft_f, filefactory=fakefilefactory)
+
+            soup = bs4.BeautifulSoup(
+                fakefilefactory[fakepath.with_suffix(".html")].read(),
+                "html.parser",
+            )
+            quote = soup.select_one("div.admonition.quote")
+            assert quote.blockquote
+
         @pytest.mark.converter
         def test_converter_attribution_to_admonition_multiple(
             self, fakepath, fakefilefactory
         @pytest.mark.converter
         def test_converter_attribution_to_admonition_multiple(
             self, fakepath, fakefilefactory
index ef23086ae112e9b258e7d2989f11b86f48ee88b0..7003a340e62a010cc42d364ba5562431291b2e15 100644 (file)
@@ -29,6 +29,26 @@ body, .signature, #signature { font-family: Lato, Calibri, Tahoma, sans-serif; }
     margin: 0.5em;
 }
 
     margin: 0.5em;
 }
 
+.block {
+    padding: 0 0.5em;
+    margin: 0;
+    font-style: italic;
+    border-left: 2px solid #eee;
+}
+blockquote, .blockquote {
+    padding: 0 0.5em;
+    margin: 0;
+    font-style: italic;
+    border-left: 2px solid #666;
+    color: #666;
+    font-size: 80%;
+}
+
+.admonition blockquote {
+    font-size: inherit;
+    border-left: inherit;
+}
+
 table, th, td {
     border-collapse: collapse;
     border: 1px solid #999;
 table, th, td {
     border-collapse: collapse;
     border: 1px solid #999;
@@ -55,20 +75,6 @@ h6 { font-size: 100%; }
 a { text-decoration:none; color:#3a5dae; }
 a:visited { color:#3a5dae; }
 a:hover { text-decoration:underline; }
 a { text-decoration:none; color:#3a5dae; }
 a:visited { color:#3a5dae; }
 a:hover { text-decoration:underline; }
-.block {
-    padding: 0 0.5em;
-    margin: 0;
-    font-style: italic;
-    border-left: 2px solid #eee;
-}
-blockquote {
-    padding: 0 0.5em;
-    margin: 0;
-    font-style: italic;
-    border-left: 2px solid #666;
-    color: #666;
-    font-size: 80%;
-}
 /*.quotelead {
     margin-bottom: -1em;
     font-size: 80%;
 /*.quotelead {
     margin-bottom: -1em;
     font-size: 80%;