Render non-fuzzy links without content correctly

If a link was non-fuzzy (points at a known URI scheme) and also
had no description, the parser would incorrectly wrap the text
in an <em> tag instead of displaying the link as the content.
not manx 2 years ago
parent 22f9437d93
commit 2de9c92881
Signed by: C-xC-c
GPG Key ID: F52ED472284EF2F4

@ -61,6 +61,11 @@
"<h1 id=\"org[[:alnum:]]\\{7\\}\">mwee</h1>"
"* mwee" '(:export-header-ids t)))
(ert-deftest link-without-content ()
"<p><a href=\"\"></a></p>"
;; Links and IDs
(ert-deftest link ()

@ -3,7 +3,7 @@
;; Author: Plum <>
;; Created: June 2020
;; Package-Version: 1.2.0
;; Package-Version: 1.2.1
;; Keywords: files
;; URL:
;; Package-Requires: ((emacs "26.1") (ox-slimhtml "0.4.5"))
@ -120,20 +120,18 @@ INFO is a plist holding contextual information."
((ox-slimhtml--immediate-child-of-p link 'link)
(org-element-property :raw-link link))
((not contents)
(format "<em>%s</em>" (org-element-property :path link)))
(t (let ((link-type (org-element-property :type link))
(href (org-element-property :raw-link link))
(attributes (if (ox-slimhtml--immediate-child-of-p link 'paragraph)
(ox-slimhtml--attr (org-export-get-parent link))
(element "<a href=\"%s\"%s>%s</a>"))
(element "<a href=\"%s\"%s>%s</a>")
(path (or (org-element-property :path link) "")))
((string= "file" link-type)
(let ((html-extension (or (plist-get info :html-extension) ""))
(use-abs-url (plist-get info :html-link-use-abs-url))
(link-org-files-as-html (plist-get info :html-link-org-as-html))
(path (or (org-element-property :path link) "")))
(link-org-files-as-html (plist-get info :html-link-org-as-html)))
(format element
(concat (if (and use-abs-url (file-name-absolute-p path)) "file:" "")
(if (and link-org-files-as-html (string= "org" (downcase (or (file-name-extension path) ""))))
@ -142,12 +140,15 @@ INFO is a plist holding contextual information."
(file-name-sans-extension path))
attributes contents)))
((and (string= "fuzzy" link-type)
(not contents))
(format "<em>%s</em>" path))
((and (string= "fuzzy" link-type)
(plist-get info :export-header-ids))
(format "<a href=\"#%s\"%s>%s</a>"
(org-export-get-reference (org-export-resolve-fuzzy-link link info) info)
attributes contents))
(t (format element href attributes contents)))))))
(t (format element href attributes (or contents href))))))))
;; org-export backend and export/publish functions
(org-export-define-derived-backend 'plumhtml