X-Git-Url: https://git.madduck.net/etc/neomutt.git/blobdiff_plain/36b999025f767b33be493a29e7636036b17b5dca..9e8410fe71ea97c659ff61647598495a5a0e03ee:/.config/neomutt/buildmimetree.py diff --git a/.config/neomutt/buildmimetree.py b/.config/neomutt/buildmimetree.py index 97ada97..4ab7a54 100755 --- a/.config/neomutt/buildmimetree.py +++ b/.config/neomutt/buildmimetree.py @@ -266,6 +266,9 @@ def collect_inline_images( ): relparts = [] for path, info in images.items(): + if path.startswith("cid:"): + continue + data = request.urlopen(path) mimetype = data.headers["Content-Type"] @@ -336,9 +339,12 @@ def convert_markdown_to_html( class MIMETreeDFWalker: def __init__(self, *, visitor_fn=None, debug=False): - self._visitor_fn = visitor_fn + self._visitor_fn = visitor_fn or self._echovisit self._debug = debug + def _echovisit(self, node, ancestry, debugprint): + debugprint(f"node={node} ancestry={ancestry}") + def walk(self, root, *, visitor_fn=None): """ Recursive function to implement a depth-dirst walk of the MIME-tree @@ -948,6 +954,23 @@ try: assert tree.children[1].path == written[0] assert written[1] == request.urlopen(test_png).read() + def test_converter_tree_inline_image_cid( + self, const1, fake_filewriter + ): + text = f"![inline base64 image](cid:{const1})" + path = pathlib.Path(const1) + tree = convert_markdown_to_html( + text, + path, + filewriter_fn=fake_filewriter, + related_to_html_only=False, + ) + assert len(tree.children) == 2 + assert tree.children[0].cid != const1 + assert tree.children[0].type != "image" + assert tree.children[1].cid != const1 + assert tree.children[1].type != "image" + def test_inline_image_collection( self, test_png, const1, const2, fake_filewriter ):