From a89058dd213455c977180e6cfb7ad7f16720b8c6 Mon Sep 17 00:00:00 2001 From: Kaushal Modi Date: Fri, 7 Jul 2017 23:32:45 -0400 Subject: [PATCH] Do not allow empty captions and "nil" classes for figures --- example-site/content/posts/image.md | 8 ++++---- ox-hugo.el | 10 ++++++++-- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/example-site/content/posts/image.md b/example-site/content/posts/image.md index e727ad3..6e0ef3b 100644 --- a/example-site/content/posts/image.md +++ b/example-site/content/posts/image.md @@ -1,6 +1,6 @@ +++ title = "Image" -date = 2017-07-07T23:15:39-04:00 +date = 2017-07-07T23:32:14-04:00 tags = [] +++ @@ -11,7 +11,7 @@ tags = [] # Unclickable image (works!) -{{
}} +{{
}} **To be fixed**: The sub-headings in a post get exported as *Heading 1* instead of *Heading 2*. @@ -33,13 +33,13 @@ So the sub-heading title and the post title both get the *Heading 1* tag and loo # Clickable image that opens the image (works!) -Click below image to jump to the unicorn image. [{{
}}](/images/org-mode-unicorn-logo.png) +Click below image to jump to the unicorn image. [{{
}}](/images/org-mode-unicorn-logo.png) - **NOTE:** `file:` has to be used in both Link and Description components of the Org link. # Image with `ATTR_HTML` [Issue # 17](https://github.com/kaushalmodi/ox-hugo/issues/17) -{{
}} +{{
}} [Discussion](https://github.com/kaushalmodi/ox-hugo/issues/17#issuecomment-313627728) diff --git a/ox-hugo.el b/ox-hugo.el index b74b9b4..b4720f7 100644 --- a/ox-hugo.el +++ b/ox-hugo.el @@ -198,8 +198,14 @@ and rewrite link paths to make blogging more seamless." (parent (org-export-get-parent link)) (attr (org-export-read-attribute :attr_html parent)) (class (plist-get attr :class))) - (format "{{
}}" - path caption class))) + (format "{{
}}" + path + (if (org-string-nw-p caption) + (format " caption=\"%s\"" caption) + "") + (if (org-string-nw-p class) + (format " class=\"%s\"" class) + "")))) ((string= type "coderef") (let ((ref (org-element-property :path link))) (format (org-export-get-coderef-format ref contents)