]> 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:

buildmimetree.py: add --related-to-html-only
authormartin f. krafft <madduck@madduck.net>
Thu, 24 Aug 2023 13:36:52 +0000 (01:36 +1200)
committermartin f. krafft <madduck@madduck.net>
Thu, 24 Aug 2023 13:36:52 +0000 (01:36 +1200)
.config/neomutt/buildmimetree.py

index 2396c49413d791f092a1ca0a8b600ae13695c965..36298ca0247294bdf6ffafc5f325582c2462b809 100755 (executable)
@@ -76,6 +76,12 @@ def parse_cli_args(*args, **kwargs):
     else:
         parser.set_defaults(css_file=None)
 
     else:
         parser.set_defaults(css_file=None)
 
+    parser.add_argument(
+        "--related-to-html-only",
+        action="store_true",
+        help="Make related content be sibling to HTML parts only"
+    )
+
     parser.add_argument(
         "--only-build",
         action="store_true",
     parser.add_argument(
         "--only-build",
         action="store_true",
@@ -499,6 +505,7 @@ def do_massage(
     extensions=None,
     cssfile=None,
     converter=convert_markdown_to_html,
     extensions=None,
     cssfile=None,
     converter=convert_markdown_to_html,
+    related_to_html_only=True,
     only_build=False,
     tempdir=None,
     debug_commands=False,
     only_build=False,
     tempdir=None,
     debug_commands=False,
@@ -527,6 +534,7 @@ def do_massage(
         draft_f.read(),
         draftpath,
         cssfile=cssfile,
         draft_f.read(),
         draftpath,
         cssfile=cssfile,
+        related_to_html_only=related_to_html_only,
         tempdir=tempdir,
         extensions=extensions,
     )
         tempdir=tempdir,
         extensions=extensions,
     )
@@ -665,6 +673,7 @@ if __name__ == "__main__":
                 cmd_f,
                 extensions=args.extensions,
                 cssfile=args.css_file,
                 cmd_f,
                 extensions=args.extensions,
                 cssfile=args.css_file,
+                related_to_html_only=args.related_to_html_only,
                 only_build=args.only_build,
                 tempdir=args.tempdir,
                 debug_commands=args.debug_commands,
                 only_build=args.only_build,
                 tempdir=args.tempdir,
                 debug_commands=args.debug_commands,
@@ -844,7 +853,14 @@ try:
             return StringIO(text or const1)
 
         def test_do_massage_basic(self, const1, string_io, capsys):
             return StringIO(text or const1)
 
         def test_do_massage_basic(self, const1, string_io, capsys):
-            def converter(drafttext, draftpath, cssfile, extensions, tempdir):
+            def converter(
+                drafttext,
+                draftpath,
+                cssfile,
+                related_to_html_only,
+                extensions,
+                tempdir,
+            ):
                 return Part("text", "plain", draftpath, orig=True)
 
             do_massage(
                 return Part("text", "plain", draftpath, orig=True)
 
             do_massage(
@@ -869,7 +885,14 @@ try:
         def test_do_massage_fulltree(
             self, string_io, const1, mime_tree_related_to_alternative, capsys
         ):
         def test_do_massage_fulltree(
             self, string_io, const1, mime_tree_related_to_alternative, capsys
         ):
-            def converter(drafttext, draftpath, cssfile, extensions, tempdir):
+            def converter(
+                drafttext,
+                draftpath,
+                cssfile,
+                related_to_html_only,
+                extensions,
+                tempdir,
+            ):
                 return mime_tree_related_to_alternative
 
             do_massage(
                 return mime_tree_related_to_alternative
 
             do_massage(
@@ -881,7 +904,6 @@ try:
 
             captured = capsys.readouterr()
             lines = captured.out.splitlines()[4:-2]
 
             captured = capsys.readouterr()
             lines = captured.out.splitlines()[4:-2]
-            print(lines)
             assert "first-entry" in lines.pop()
             assert "update-encoding" in lines.pop()
             assert "Plain" in lines.pop()
             assert "first-entry" in lines.pop()
             assert "update-encoding" in lines.pop()
             assert "Plain" in lines.pop()
@@ -1122,7 +1144,14 @@ try:
         def test_mime_tree_relative_within_alternative(
             self, string_io, const1, capsys, mime_tree_related_to_html
         ):
         def test_mime_tree_relative_within_alternative(
             self, string_io, const1, capsys, mime_tree_related_to_html
         ):
-            def converter(drafttext, draftpath, cssfile, extensions, tempdir):
+            def converter(
+                drafttext,
+                draftpath,
+                cssfile,
+                related_to_html_only,
+                extensions,
+                tempdir,
+            ):
                 return mime_tree_related_to_html
 
             do_massage(
                 return mime_tree_related_to_html
 
             do_massage(