Occasionally I embed base64 in markdown like:
<figure>
<img src="data:image/png;base64,/9j/4AAQ … [snip] " width="100%">
</figure>
I have this defined in syntax markdown.vim:
syn region markdownBase64Image start=/<img src="data:image/ end=/"/ conceal cchar=X
It works but I have many blank lines under cchar and then if cursor and concealed line is moved to top of window, the remaining base64 code appears. It kind of defeats the purpose.
I would like to conceal the base64 string to see the context in which it appears. Like
<figure>
X
</figure>
I've read the help docs and searched online but cannot find anything to help me.
Edit: Added more info
With conceallevel=2
and concealcursor=
it looks like this:
Base64 string does not include 'end' pattern '"'. It marks the end of the base64 representation.
Edit: Added more additional info
- the syntax rule is defined in .../vimfiles/after/syntax/markdown.vim. there is only the one line (shown above).
- the file has also
:set cole=1
andset concealcursor=
. - i have also tested syntax rule with text file with no filetype. i'm guessing this means no other syntax rules apply.my issue is the same when syntax rule is input through command line.
- while the example image shows
<img>
tag surrounded by<figure>
tag, i have tested syntax rules in other contexts and the issue is the same. - example base64 image data (i have encoded and tested a tiny 819b image and give the string here. while the effect is not so extreme, same issue persists. Also note string is one line.):
<img src="data:image/png;base64,/9j/4AAQSkZJRgABAQEAYABgAAD/2wBDABQODxIPDRQSEBIXFRQYHjIhHhwcHj0sLiQySUBMS0dARkVQWnNiUFVtVkVGZIhlbXd7gYKBTmCNl4x9lnN+gXz/2wBDARUXFx4aHjshITt8U0ZTfHx8fHx8fHx8fHx8fHx8fHx8fHx8fHx8fHx8fHx8fHx8fHx8fHx8fHx8fHx8fHx8fHz/wAARCAA4AGQDASIAAhEBAxEB/8QAGQAAAwEBAQAAAAAAAAAAAAAAAAMEAgEF/8QAKhAAAQQBAwMEAAcAAAAAAAAAAQACAxEhBDFBEhNRBSJhgRUkMjNxocH/xAAXAQEBAQEAAAAAAAAAAAAAAAACAAED/8QAGxEBAQADAQEBAAAAAAAAAAAAAAECETEhQkP/2gAMAwEAAhEDEQA/APFgsvA4BV9KdvbJFAXarRjpWKXaW6RWFCleMrJwnOGVgtUx5ZmeNS5oFi1XFKBROAiLS9/VFpw0b1yvU/D4TFXTXyjacxSNAIwtFqnBMGqETjzSsIWimc1NngijDqcSQuuHtS3kuJJNk7qRQCFqghSOEzOQmCVpypS2gtA4WpWJIzyFokVuFH8BFnhwVth5C5SV3jy1a748FSLhid3ZXBxbm/6Xo9pznNIkrGQvPa49RwQCr4v2xn6C512x4m12nic7vE0QKGdzwtlSztdJ6n0kWAAVW5bOBesOHsSXDCokcBEASku2CYku3Quu3QpOg9wLrY8brMYoUmtPCkSXDqwsA08dJP8AC26hKMLM5a0iiLKNZXHTFrwALv4ToonaiaNhuMO3cP8AFMZTG9vcGDg4V+lNSxmsWClJ4zZjtCYyWhxLR5K3E0RHKvkHP0kSAVshl13l8eK6Qy6+Uhxb4TXyStb1FuTx4WA388SP0nhMnlLQaFkmgnJ45ZVNMZZOklpTmOtteE2GMBlEknklKcOlytDK445Qsu3QtI7pxgg0tNF5QhYk+pOaCn1EJa1riRuhC1lcjBlbTs8Kv0+Q4jcctdSEJBOPfDgbS3Rg7OH2hCOUh42vI1DY4vUAA6zWSkPdeso1TcoQqMy6rhNlwStRW4Qhcv0pfKZ0rb3QhC6i/9k=">
Edit: More info
Vim version:
VIM - Vi IMproved 9.1 (2024 Jan 02, compiled Jan 3 2024 00:15:11)
MS-Windows 32-bit GUI version with OLE support
Compiled by appveyor@APPVEYOR-VM
I have tested on 'clean' vim ...\vim91\gvim.exe --clean -i ~/.viminfo2
and recorded output to 'gif':
(Strangely, I tried uploading a 1M gif 700x800px and got error "Image uploads are limited to 50 megapixels; please use a smaller image" Tried with other gifs and same problem. However, it's happy with an '.apng' file.)
Click on image if it stops looping :)
Edit (240626):
:set nowrap
changes effect of conceal but makes the effort rather pointless. With nowrap
the embeddded image is no longer a problem (it occupies only one line) and I would not bother trying to conceal it. But then, most of my text is in lines longer than screen width so setting :set nowrap
has the effect of concealing most of my text!
There appears to be a bug however if I assume there's not a problem with my vim. See how the conceal rule doesn't properly conceal the image tag according to the rule: