From 27397f2f344c2428e2b519e4af84841e40db5570 Mon Sep 17 00:00:00 2001 From: Kaushal Modi Date: Tue, 13 Feb 2018 11:54:06 -0500 Subject: [PATCH] Append "Figure N: " to figure captions This adds consistency with the table and source block captions. --- ox-hugo.el | 15 ++++++++++++++- .../posts/figure-shortcode-and-attr-html.md | 4 ++-- test/site/content/posts/image-captions.md | 2 +- test/site/content/posts/links-to-images.md | 12 ++++++------ test/site/themes/bare_min | 2 +- 5 files changed, 24 insertions(+), 11 deletions(-) diff --git a/ox-hugo.el b/ox-hugo.el index 514bbcb..a8eaeac 100644 --- a/ox-hugo.el +++ b/ox-hugo.el @@ -1705,7 +1705,20 @@ and rewrite link paths to make blogging more seamless." (org-export-data ;Look for caption set using #+caption (org-export-get-caption (org-export-get-parent-element link)) info)) - (plist-get attr :caption)))) + (plist-get attr :caption))) + (caption (when (org-string-nw-p caption) + (format "%s%s%s%s" + ;; Tue Feb 13 11:32:45 EST 2018 - kmodi + ;; Add the span tag once + ;; https://github.com/gohugoio/hugo/issues/4406 + ;; gets resolved. + "" ;"" + (format (org-html--translate "Figure %d: " info) + (org-export-get-ordinal + useful-parent info + nil #'org-html--has-caption-p)) + "" ;"" + caption)))) ;; (message "[ox-hugo-link DBG] inline image? %s\npath: %s" ;; inline-image path) ;; (message "[org-hugo-link DBG] attr: %s num of attr: %d" diff --git a/test/site/content/posts/figure-shortcode-and-attr-html.md b/test/site/content/posts/figure-shortcode-and-attr-html.md index c91bafc..da6b85d 100644 --- a/test/site/content/posts/figure-shortcode-and-attr-html.md +++ b/test/site/content/posts/figure-shortcode-and-attr-html.md @@ -38,7 +38,7 @@ below image, caption is set using that: Some text before image. -{{< figure src="/images/org-mode-unicorn-logo.png" caption="A unicorn!" >}} +{{< figure src="/images/org-mode-unicorn-logo.png" caption="Figure 1: A unicorn!" >}} Some more text, after image. @@ -46,7 +46,7 @@ Below, the same caption is set using the `#+attr_html` method instead: Some text before image. -{{< figure src="/images/org-mode-unicorn-logo.png" caption="A unicorn!" >}} +{{< figure src="/images/org-mode-unicorn-logo.png" caption="Figure 2: A unicorn!" >}} _Enter a new line after the image link so that it's in an "Org paragraph" that contains just that image. That tells Org that that diff --git a/test/site/content/posts/image-captions.md b/test/site/content/posts/image-captions.md index 09af900..e53171f 100644 --- a/test/site/content/posts/image-captions.md +++ b/test/site/content/posts/image-captions.md @@ -7,6 +7,6 @@ draft = false Some text before image. -{{< figure src="/images/org-mode-unicorn-logo.png" caption="A unicorn!" >}} +{{< figure src="/images/org-mode-unicorn-logo.png" caption="Figure 1: A unicorn!" >}} Some more text, after image. diff --git a/test/site/content/posts/links-to-images.md b/test/site/content/posts/links-to-images.md index 8cb6486..73c04ef 100644 --- a/test/site/content/posts/links-to-images.md +++ b/test/site/content/posts/links-to-images.md @@ -29,10 +29,10 @@ Here's the same image again, but with a different Org link ID: will output below (_lorem-ipsum_ added to increase page content so that the link jump is evident): - -{{< figure src="/images/org-mode-unicorn-logo.png" caption="Org Logo" >}} + +{{< figure src="/images/org-mode-unicorn-logo.png" caption="Figure 1: Org Logo" >}} -**Here we refer to image [2](#org7a92cf1).** +**Here we refer to image [2](#orgb4d5cae).** Lorem ipsum dolor sit amet, consectetur adipiscing elit. Quisque et quam metus. Etiam in iaculis mi, sit amet pretium magna. Donec ut dui @@ -88,10 +88,10 @@ blandit in. Here's the same image again, but with a different Org link ID: - -{{< figure src="/images/org-mode-unicorn-logo.png" caption="Same Org Logo" >}} + +{{< figure src="/images/org-mode-unicorn-logo.png" caption="Figure 2: Same Org Logo" >}} -**Here we refer to image [1](#orgccda3d6).** +**Here we refer to image [1](#org21b2f71).** --- diff --git a/test/site/themes/bare_min b/test/site/themes/bare_min index 3f7dcc9..2d8c4a1 160000 --- a/test/site/themes/bare_min +++ b/test/site/themes/bare_min @@ -1 +1 @@ -Subproject commit 3f7dcc9619d61c005992fb47f60caa2e1f5e3831 +Subproject commit 2d8c4a1e8c08784228305d9b22080e3522cdfbc9