From a716fee972344c6ded73224dd48d5ebce20760d1 Mon Sep 17 00:00:00 2001 From: Kaushal Modi Date: Tue, 12 Jun 2018 17:10:13 -0400 Subject: [PATCH] org-hugo--quote-string now returns an empty quoted string by default --- ox-hugo.el | 9 ++++++--- test/site/content-org/all-posts.org | 2 ++ .../posts/custom-front-matter-with-nested-maps-toml.md | 2 ++ .../posts/custom-front-matter-with-nested-maps-yaml.md | 2 ++ test/site/themes/hugo-bare-min-theme | 2 +- 5 files changed, 13 insertions(+), 4 deletions(-) diff --git a/ox-hugo.el b/ox-hugo.el index 9817c31..5d65337 100644 --- a/ox-hugo.el +++ b/ox-hugo.el @@ -2386,12 +2386,15 @@ If VAL contains newlines, format it according to TOML or YAML FORMAT to preserve them. VAL is returned as-it-is under the following cases: -- It is a number or nil. +- It is a number. - It is a string and is already wrapped with double quotes. - It is a string and it's value is \"true\" or \"false\". - It is a string representing a date. - It is a string representing an integer or float. +If VAL is nil or an empty string, a quoted empty string \"\" is +returned. + If optional argument PREFER-NO-QUOTES is non-nil, return the VAL as-it-is if it's a string with just alphanumeric characters. @@ -2475,9 +2478,9 @@ Optional argument FORMAT can be \"toml\" or \"yaml\"." (setq val (replace-regexp-in-string "\"" "\\\\\"" val)) (concat "\"" val "\"")))) (t ;If `val' is any empty string - ""))) + "\"\""))) (t ;Return empty string if anything else - ""))) + "\"\""))) (defun org-hugo--parse-property-arguments (str) "Return an alist converted from a string STR of Hugo property value. diff --git a/test/site/content-org/all-posts.org b/test/site/content-org/all-posts.org index 3ed0878..0104bcf 100644 --- a/test/site/content-org/all-posts.org +++ b/test/site/content-org/all-posts.org @@ -1705,6 +1705,7 @@ Here there is white space in menu name property. :EXPORT_HUGO_CUSTOM_FRONT_MATTER+: :alpha 1 :EXPORT_HUGO_CUSTOM_FRONT_MATTER+: :beta "two words" :EXPORT_HUGO_CUSTOM_FRONT_MATTER+: :gamma 10 +:EXPORT_HUGO_CUSTOM_FRONT_MATTER+: :empty_string "" :END: From [[https://orgmode.org/manual/Property-syntax.html][*(org) Property syntax*]]: #+begin_quote @@ -1755,6 +1756,7 @@ The following results in the 'genres' property having the value :EXPORT_HUGO_CUSTOM_FRONT_MATTER+: :header '((image . "projects/Readingabook.jpg") (caption . "stay hungry, stay foolish")) :EXPORT_HUGO_CUSTOM_FRONT_MATTER+: :collection '((animals . (dog cat "penguin" "mountain gorilla")) (nothing) (nonnil . t) (strings-symbols . ("abc" def "two words")) (integers . (123 -5 17 1_234)) (floats . (12.3 -5.0 -17E-6)) (booleans . (true false))) :EXPORT_HUGO_CUSTOM_FRONT_MATTER+: :random '((foo . bar)) +:EXPORT_HUGO_CUSTOM_FRONT_MATTER+: :empty_string_value '((empty . "")) :END: *** Custom front matter with nested maps in TOML :PROPERTIES: diff --git a/test/site/content/posts/custom-front-matter-with-nested-maps-toml.md b/test/site/content/posts/custom-front-matter-with-nested-maps-toml.md index 85d8b9b..5cfd59c 100644 --- a/test/site/content/posts/custom-front-matter-with-nested-maps-toml.md +++ b/test/site/content/posts/custom-front-matter-with-nested-maps-toml.md @@ -20,6 +20,8 @@ draft = false booleans = [true, false] [random] foo = "bar" +[empty_string_value] + empty = "" +++ `ox-hugo` Issue #[139](https://github.com/kaushalmodi/ox-hugo/issues/139) diff --git a/test/site/content/posts/custom-front-matter-with-nested-maps-yaml.md b/test/site/content/posts/custom-front-matter-with-nested-maps-yaml.md index 4ecc677..f6fd878 100644 --- a/test/site/content/posts/custom-front-matter-with-nested-maps-yaml.md +++ b/test/site/content/posts/custom-front-matter-with-nested-maps-yaml.md @@ -20,6 +20,8 @@ collection: booleans: [true, false] random: foo: "bar" +empty_string_value: + empty: "" --- `ox-hugo` Issue #[139](https://github.com/kaushalmodi/ox-hugo/issues/139) diff --git a/test/site/themes/hugo-bare-min-theme b/test/site/themes/hugo-bare-min-theme index 1fa02cd..d5faea0 160000 --- a/test/site/themes/hugo-bare-min-theme +++ b/test/site/themes/hugo-bare-min-theme @@ -1 +1 @@ -Subproject commit 1fa02cddc3419e7183031946e3114eaf08bcb21d +Subproject commit d5faea081a4e7ef06b633a9921726c0083ce07e2