Skip to content

Commit

Permalink
Append "Figure N: " to figure captions
Browse files Browse the repository at this point in the history
This adds consistency with the table and source block captions.
  • Loading branch information
kaushalmodi committed Feb 13, 2018
1 parent d35f53a commit 27397f2
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 11 deletions.
15 changes: 14 additions & 1 deletion ox-hugo.el
Expand Up @@ -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.
"" ;"<span class=\\\"figure-number\\\">"
(format (org-html--translate "Figure %d: " info)
(org-export-get-ordinal
useful-parent info
nil #'org-html--has-caption-p))
"" ;"</span>"
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"
Expand Down
4 changes: 2 additions & 2 deletions test/site/content/posts/figure-shortcode-and-attr-html.md
Expand Up @@ -38,15 +38,15 @@ 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.

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
Expand Down
2 changes: 1 addition & 1 deletion test/site/content/posts/image-captions.md
Expand Up @@ -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.
12 changes: 6 additions & 6 deletions test/site/content/posts/links-to-images.md
Expand Up @@ -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):

<a id="orgccda3d6"></a>
{{< figure src="/images/org-mode-unicorn-logo.png" caption="Org Logo" >}}
<a id="org21b2f71"></a>
{{< 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
Expand Down Expand Up @@ -88,10 +88,10 @@ blandit in.

Here's the same image again, but with a different Org link ID:

<a id="org7a92cf1"></a>
{{< figure src="/images/org-mode-unicorn-logo.png" caption="Same Org Logo" >}}
<a id="orgb4d5cae"></a>
{{< 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).**

---

Expand Down
2 changes: 1 addition & 1 deletion test/site/themes/bare_min

0 comments on commit 27397f2

Please sign in to comment.