From af4c706305aaf481c2d3d55c643df6ffeb09e424 Mon Sep 17 00:00:00 2001 From: Kaushal Modi Date: Thu, 16 Aug 2018 15:22:15 -0400 Subject: [PATCH] Escape double quotes in figure captions Fixes https://github.com/kaushalmodi/ox-hugo/issues/190. --- ox-hugo.el | 4 +++- test/site/content-org/all-posts.org | 2 +- test/site/content/posts/figure-shortcode-and-attr-html.md | 2 +- test/site/content/posts/image-captions.md | 2 +- 4 files changed, 6 insertions(+), 4 deletions(-) diff --git a/ox-hugo.el b/ox-hugo.el index 0066dd7..7cb8e30 100644 --- a/ox-hugo.el +++ b/ox-hugo.el @@ -1881,7 +1881,9 @@ and rewrite link paths to make blogging more seamless." useful-parent info nil #'org-html--has-caption-p)) " " ;" " - caption)))) + ;; Escape the double-quotes, if any, + ;; present in the caption. + (replace-regexp-in-string "\"" "\\\\\"" 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-org/all-posts.org b/test/site/content-org/all-posts.org index 57507a5..94b30c7 100644 --- a/test/site/content-org/all-posts.org +++ b/test/site/content-org/all-posts.org @@ -204,7 +204,7 @@ This is an inline non-hyperlinked image with the width attribute: :END: Some text before image. -#+caption: A unicorn! +#+caption: A unicorn! "Something in double quotes" [[/images/org-mode-unicorn-logo.png]] Some more text, after image. 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 dabfee3..37ff056 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="Figure 1: A unicorn!" >}} +{{< figure src="/images/org-mode-unicorn-logo.png" caption="Figure 1: A unicorn! \"Something in double quotes\"" >}} Some more text, after image. diff --git a/test/site/content/posts/image-captions.md b/test/site/content/posts/image-captions.md index e53171f..60c4ede 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="Figure 1: A unicorn!" >}} +{{< figure src="/images/org-mode-unicorn-logo.png" caption="Figure 1: A unicorn! \"Something in double quotes\"" >}} Some more text, after image.