This is a follow-up question from a previous thread
org-html--wrap-image adds a
<p> tag around its contents, as you can see here:
ELISP> (org-html--wrap-image "bla" t) "\n<div class=\"figure\">\n<p>bla</p>\n</div>"
I want to remove those
<p> tags around "bla". My current workaround consists of redefining the function
org-html--wrap-image completely, removing the tags, but this seems to be a bit of an overkill.
I acknowledge that if I wrap the function with a call to
replace-regexp-in-string, I can achieve the same effect.
ELISP> (replace-regexp-in-string (rx (or "<p>" "</p>")) "" (org-html--wrap-image "bla" t)) "\n<div class=\"figure\">\nbla\n</div>"
How can I write an "advice" to do that? I've never written one before, and the documentation for "advices" is kind of harsh on Elisp beginners.
For completeness, here's the function code:
(defun org-html--wrap-image (contents info &optional caption label) "Wrap CONTENTS string within an appropriate environment for images. INFO is a plist used as a communication channel. When optional arguments CAPTION and LABEL are given, use them for caption and \"id\" attribute." (let ((html5-fancy (org-html--html5-fancy-p info))) (format (if html5-fancy "\n<figure%s>%s%s\n</figure>" "\n<div%s class=\"figure\">%s%s\n</div>") ;; ID. (if (org-string-nw-p label) (format " id=\"%s\"" label) "") ;; Contents. (format "\n<p>%s</p>" contents) ;; Caption. (if (not (org-string-nw-p caption)) "" (format (if html5-fancy "\n<figcaption>%s</figcaption>" "\n<p>%s</p>") caption)))))