Allow disabling Pandoc citations in subtrees

master
Kaushal Modi 8 years ago
parent 016959c76e
commit 0670d755fd
  1. 47
      ox-hugo.el
  2. 21
      test/site/content-org/all-posts.org
  3. 12
      test/site/content/posts/disabling-pandoc-citations-in-a-subtree-empty-string.md
  4. 11
      test/site/content/posts/disabling-pandoc-citations-in-a-subtree-nil-string.md

@ -861,7 +861,24 @@ newer."
;;; Miscellaneous Helper Functions
;;;; Check if a boolean plist value is non-nil
;;;; Check if a value is non-nil
(defun org-hugo--value-get-true-p (value)
"Return non-nil if VALUE is non-nil.
Return nil if VALUE is nil, \"nil\" or \"\"."
(cond
((or (equal t value)
(equal nil value))
value)
((and (stringp value)
(string= value "nil"))
nil)
(t
;; "" -> nil
;; "t" -> "t"
;; "anything else" -> "anything else"
;; 123 -> nil
(org-string-nw-p value))))
(defun org-hugo--plist-get-true-p (info key)
"Return non-nil if KEY in INFO is non-nil.
Return nil if the value of KEY in INFO is nil, \"nil\" or \"\".
@ -872,19 +889,7 @@ are expected to hold a boolean value.
INFO is a plist used as a communication channel."
(let ((value (plist-get info key)))
;; (message "dbg: org-hugo--plist-get-true-p:: key:%S value:%S" key value)
(cond
((or (equal t value)
(equal nil value))
value)
((and (stringp value)
(string= value "nil"))
nil)
(t
;; "" -> nil
;; "t" -> "t"
;; "anything else" -> "anything else"
;; 123 -> nil
(org-string-nw-p value)))))
(org-hugo--value-get-true-p value)))
;;;; Workaround to retain the :hl_lines parameter in src-block headers post `org-babel-exp-code'
;; http://lists.gnu.org/archive/html/emacs-orgmode/2017-10/msg00300.html
@ -962,10 +967,18 @@ This is an internal function."
(setq org-hugo--section nil)
(setq org-hugo--bundle nil)
(advice-remove 'org-babel-exp-code #'org-hugo--org-babel-exp-code)
(let ((pandoc-enabled (or (org-entry-get nil "EXPORT_HUGO_PANDOC_CITATIONS" :inherit)
(org-hugo--plist-get-true-p info :hugo-pandoc-citations))))
(let* ((pandoc-citations-enabled--prop-val
(org-entry-get nil "EXPORT_HUGO_PANDOC_CITATIONS" :inherit :literal-nil))
(pandoc-citations-enabled--plist-val
(org-hugo--plist-get-true-p info :hugo-pandoc-citations))
(pandoc-enabled (or pandoc-citations-enabled--prop-val
pandoc-citations-enabled--plist-val))
(pandoc-enabled-bool (org-hugo--value-get-true-p pandoc-enabled)))
;; (message "[ox-hugo DBG pandoc-citations-enabled--prop-val] %S" pandoc-citations-enabled--prop-val)
;; (message "[ox-hugo DBG pandoc-citations-enabled--plist-val] %S" pandoc-citations-enabled--plist-val)
;; (message "[ox-hugo DBG pandoc-enabled-bool] %S" pandoc-enabled-bool)
(when (and outfile
pandoc-enabled)
pandoc-enabled-bool)
(require 'ox-hugo-pandoc-cite)
(plist-put info :outfile outfile)
(plist-put info :front-matter org-hugo--fm)

@ -4886,6 +4886,27 @@ rectangle "<html>, <body>, etc." as a {
#+caption: PlantUML generated figure showing nested boxes
#+RESULTS: code__plantuml_nested_boxes
[[file:images/citations-with-captions/nested-boxes.svg]]
** Disabling Pandoc citations in a subtree :disable:
*** Disabling Pandoc citations in a subtree (empty string)
:PROPERTIES:
:EXPORT_FILE_NAME: disabling-pandoc-citations-in-a-subtree-empty-string
:EXPORT_HUGO_PANDOC_CITATIONS:
:END:
#+begin_description
Test that ~:EXPORT_HUGO_PANDOC_CITATIONS:~ disables Pandoc citations
in a subtree.
#+end_description
The Nocites in the front-matter do not get rendered as citations.
*** Disabling Pandoc citations in a subtree (nil string)
:PROPERTIES:
:EXPORT_FILE_NAME: disabling-pandoc-citations-in-a-subtree-nil-string
:EXPORT_HUGO_PANDOC_CITATIONS: nil
:END:
#+begin_description
Test that ~:EXPORT_HUGO_PANDOC_CITATIONS: nil~ disables Pandoc
citations in a subtree.
#+end_description
The Nocites in the front-matter do not get rendered as citations.
* Export Options :export_option:
** Table of Contents (TOC) :toc:
=ox-hugo= has the =with-toc= option disabled by default as Hugo has an

@ -0,0 +1,12 @@
+++
title = "Disabling Pandoc citations in a subtree (empty string)"
description = """
Test that `:EXPORT_HUGO_PANDOC_CITATIONS:` disables Pandoc citations
in a subtree.
"""
tags = ["pandoc", "citations", "disable"]
draft = false
nocite = ["@giovanelli2016", "@eilan2016"]
+++
The Nocites in the front-matter do not get rendered as citations.

@ -0,0 +1,11 @@
---
title: "Disabling Pandoc citations in a subtree (nil string)"
description: >
Test that `:EXPORT_HUGO_PANDOC_CITATIONS: nil` disables Pandoc
citations in a subtree.
tags: ["pandoc", "citations", "disable"]
draft: false
nocite: ["@giovanelli2016", "@eilan2016"]
---
The Nocites in the front-matter do not get rendered as citations.
Loading…
Cancel
Save