Support Org #+AUTHOR keyword

Also allow disabling author export.

This commit might be a big behavior change for some as now the author
name is auto-exported to the post front matter.

To disable that, simply put "#+AUTHOR:" or "#+OPTIONS: author:nil" at
the top of your Org file.

With this commit, ox-hugo now supports one more implicit ox.el
feature.

Part of solution to https://github.com/kaushalmodi/ox-hugo/issues/106
master
Kaushal Modi 8 years ago
parent e86ab6ad21
commit 852ab6ce24
  1. 10
      ox-hugo.el
  2. 46
      test/site/content-org/all-posts.org
  3. 2
      test/site/content-org/auto-set-lastmod.org
  4. 2
      test/site/content-org/construct-hugo-front-matter-from-menu-meta-data.org
  5. 2
      test/site/content-org/deep-nesting.org
  6. 2
      test/site/content-org/hugo-menu-as-keyword.org
  7. 2
      test/site/content-org/hugo-weight-as-keyword-auto-calc.org
  8. 2
      test/site/content-org/images-in-content/images-in-content.org
  9. 1
      test/site/content-org/images-in-content/post3/post3.org
  10. 1
      test/site/content-org/images-in-content/post4/post4.org
  11. 1
      test/site/content-org/single-posts/allow-empty-titles-1.org
  12. 1
      test/site/content-org/single-posts/disable-title-1.org
  13. 1
      test/site/content-org/single-posts/export-without-emphasize.org
  14. 2
      test/site/content-org/single-posts/hugo-auto-weight-ineffective-for-per-file-exports.org
  15. 1
      test/site/content-org/single-posts/post-draft.org
  16. 1
      test/site/content-org/single-posts/post-toml.org
  17. 1
      test/site/content-org/single-posts/post-yaml.org
  18. 2
      test/site/content-org/src-blocks-with-highlight-shortcode.org
  19. 2
      test/site/content-org/tags-and-categories.org
  20. 2
      test/site/content/alias-test/alias-without-section-2.md
  21. 2
      test/site/content/posts/alias-different-section.md
  22. 2
      test/site/content/posts/alias-multiple-with-section.md
  23. 2
      test/site/content/posts/alias-multiple-without-section.md
  24. 2
      test/site/content/posts/alias-root-section.md
  25. 2
      test/site/content/posts/alias-without-section-1.md
  26. 2
      test/site/content/posts/auto-set-lastmod.md
  27. 8
      test/site/content/posts/disable-author.md
  28. 9
      test/site/content/posts/multiple-authors.md
  29. 8
      test/site/content/posts/single-author.md
  30. 2
      test/site/content/real-examples/multifractals-in-ecology-using-r.md
  31. 2
      test/site/content/real-examples/nn-intro.md
  32. 5
      test/site/content/writing-hugo-blog-in-org-file-export.md
  33. 3
      test/site/content/writing-hugo-blog-in-org-subtree-export.md

@ -1789,6 +1789,15 @@ INFO is a plist used as a communication channel."
;; (message "[hugo front matter DBG] info: %S" (pp info))
(let* ((fm-format (plist-get info :hugo-front-matter-format))
(title (org-entry-get (point) "ITEM")) ;Post title
(author-list (and (plist-get info :with-author)
(let ((author-raw
(org-string-nw-p
(org-export-data (plist-get info :author) info))))
(when author-raw
;; Comma-separated multiple authors
(let ((author-list-1 (org-split-string author-raw ",")))
;; Don't allow spaces around author names.
(mapcar #'org-trim author-list-1))))))
(hugo-date-fmt "%Y-%m-%dT%T%z")
(date-raw (or
;; Get the date from the "CLOSED" property;
@ -1935,6 +1944,7 @@ INFO is a plist used as a communication channel."
(data `(;; The order of the elements below will be the order in which the front matter
;; variables will be ordered.
(title . ,(org-hugo--sanitize-title info))
(author . ,author-list)
(description . ,(org-export-data (plist-get info :description) info))
(date . ,date)
(publishDate . ,(org-export-data (plist-get info :hugo-publishdate) info))

@ -1,9 +1,12 @@
#+HUGO_BASE_DIR: ../
#+SEQ_TODO: TODO DRAFT DONE
#+PROPERTY: header-args :eval no
#+MACRO: doc [[https://ox-hugo.scripter.co/doc/$1][$2]]
#+MACRO: oxhugoissue =ox-hugo= Issue #[[https://github.com/kaushalmodi/ox-hugo/issues/$1][$1]]
#+AUTHOR:
* Preparation
:PROPERTIES:
:EXPORT_FILE_NAME: prep
@ -2609,45 +2612,68 @@ a_{b} a_{bc} a^{b} a^{bc}
:END:
This post will be exported without =title= in the front-matter because
it is disabled using =:EXPORT_OPTIONS: title:nil=.
* Hugo Aliases :aliases:
** Alias without section portion 1
** Disable exporting author :author:disable:
:PROPERTIES:
:EXPORT_OPTIONS: author:nil
:EXPORT_FILE_NAME: disable-author
:EXPORT_AUTHOR: Foo Bar
:END:
This post will be exported without =author= in the front-matter because
it is disabled using =:EXPORT_OPTIONS: author:nil=.
* Miscellaneous Front Matter :front_matter:
** Hugo Aliases :aliases:
*** Alias without section portion 1
:PROPERTIES:
:EXPORT_FILE_NAME: alias-without-section-1
:EXPORT_HUGO_ALIASES: alias-a
:END:
As the specified alias does not contain the "/" string, it will be
auto-prefixed with the section for the current post.
** New section just for test
*** New section just for test
:PROPERTIES:
:EXPORT_HUGO_SECTION: alias-test
:END:
*** Alias without section portion 2
**** Alias without section portion 2
:PROPERTIES:
:EXPORT_FILE_NAME: alias-without-section-2
:EXPORT_HUGO_ALIASES: alias-b
:END:
As the specified alias does not contain the "/" string, it will be
auto-prefixed with the section for the current post.
** Alias specifying a different section
*** Alias specifying a different section
:PROPERTIES:
:EXPORT_FILE_NAME: alias-different-section
:EXPORT_HUGO_ALIASES: /alias-test/alias-c
:END:
** Alias specifying root section
*** Alias specifying root section
:PROPERTIES:
:EXPORT_FILE_NAME: alias-root-section
:EXPORT_HUGO_ALIASES: /alias-d
:END:
** Multiple aliases without section portion
*** Multiple aliases without section portion
:PROPERTIES:
:EXPORT_FILE_NAME: alias-multiple-without-section
:EXPORT_HUGO_ALIASES: alias-e alias-f
:END:
** Multiple aliases with section portion
*** Multiple aliases with section portion
:PROPERTIES:
:EXPORT_FILE_NAME: alias-multiple-with-section
:EXPORT_HUGO_ALIASES: /alias-test/alias-g /alias-test/alias-h
:END:
** Author :author:
*** Single author
:PROPERTIES:
:EXPORT_FILE_NAME: single-author
:EXPORT_AUTHOR: Foo Bar
:END:
This post has 1 author.
*** Multiple authors
:PROPERTIES:
:EXPORT_FILE_NAME: multiple-authors
:EXPORT_AUTHOR: Foo Bar, Toto Kumar , Zulu ,Ágota Kristóf
:END:
This post has multiple authors. In Org, multiple authors are added
comma-separated.
* Real Examples :real_examples:
:PROPERTIES:
:EXPORT_HUGO_SECTION: real-examples
@ -2655,7 +2681,7 @@ auto-prefixed with the section for the current post.
** Multifractals in ecology using R :math:equations:
:PROPERTIES:
:EXPORT_FILE_NAME: multifractals-in-ecology-using-r
:EXPORT_HUGO_CUSTOM_FRONT_MATTER: :author Leonardo A. Saravia
:EXPORT_AUTHOR: Leonardo A. Saravia
:EXPORT_HUGO_CUSTOM_FRONT_MATTER+: :source https://github.com/lsaravia/MultifractalsInR/blob/master/Curso3.md
:EXPORT_DATE: 2017-11-28T10:48:00-05:00
:END:
@ -2767,6 +2793,8 @@ auto-prefixed with the section for the current post.
** 神经网络基础 :math:equations:not_english:table:latex:latex_environment:
:PROPERTIES:
:EXPORT_FILE_NAME: nn-intro
:EXPORT_AUTHOR: Feng Ruohang
:EXPORT_HUGO_CUSTOM_FRONT_MATTER+: :source https://github.com/Vonng/Math/blob/master/nndl/nn-intro.md
:EXPORT_DATE: 2017-11-29
:END:
- Disclaimer :: This post is from the [[https://github.com/Vonng/Math/blob/master/nndl/nn-intro.md][link]] posted by GitHub user

@ -3,6 +3,8 @@
# Auto-set lastmod field in the below posts.
#+HUGO_AUTO_SET_LASTMOD: t
#+AUTHOR:
#+FILETAGS: dont_export_during_make_test
* Auto-set Lastmod

@ -2,6 +2,8 @@
#+HUGO_FRONT_MATTER_FORMAT: yaml
#+HUGO_MENU: :menu main :parent posts
#+AUTHOR:
* Menu Meta Data in YAML Front Matter :menu:yaml:
:PROPERTIES:
:EXPORT_FILE_NAME: menu-meta-data-yaml

@ -1,5 +1,7 @@
#+HUGO_BASE_DIR: ../
#+AUTHOR:
* Introduction
See https://github.com/kaushalmodi/ox-hugo/issues/81

@ -2,6 +2,8 @@
#+SEQ_TODO: TODO DRAFT DONE
#+HUGO_MENU: :menu "auto weight"
#+AUTHOR:
* Post with menu 1 (HUGO_MENU as keyword)
:PROPERTIES:
:EXPORT_FILE_NAME: hugo-menu-as-keyword--post-with-menu-1

@ -3,6 +3,8 @@
#+HUGO_WEIGHT: auto
#+HUGO_TAGS: weight
#+AUTHOR:
* Post 1 with auto calculation of weight (HUGO_WEIGHT as keyword)
:PROPERTIES:
:EXPORT_FILE_NAME: post-1-with-auto-calc-of-weight--hugo-weight-as-keyword

@ -2,6 +2,8 @@
#+HUGO_SECTION: images-in-content
#+STARTUP: inlineimages
#+AUTHOR:
* Post 1
:PROPERTIES:
:EXPORT_FILE_NAME: post1

@ -3,6 +3,7 @@
#+STARTUP: inlineimages
#+TITLE: Post 3
#+AUTHOR:
Post 3 contents

@ -3,6 +3,7 @@
#+STARTUP: inlineimages
#+TITLE: Post 4
#+AUTHOR:
Post 4 contents

@ -1,6 +1,7 @@
#+HUGO_BASE_DIR: ../../
#+TITLE:
#+AUTHOR:
#+FILETAGS: empty title
This post will be exported without =title= in the front-matter because

@ -1,6 +1,7 @@
#+HUGO_BASE_DIR: ../../
#+TITLE: Disable exporting title
#+AUTHOR:
#+OPTIONS: title:nil
#+FILETAGS: disable title

@ -1,4 +1,5 @@
#+TITLE: Table with Org markup where the markup is ignored
#+AUTHOR:
# Ignore the Org emphasis characters like * and /
#+OPTIONS: *:nil

@ -1,4 +1,6 @@
#+TITLE: Hugo auto weight ineffective for per-file exports
#+AUTHOR:
#+HUGO_BASE_DIR: ../../
#+HUGO_WEIGHT: auto
#+HUGO_TAGS: weight

@ -1,4 +1,5 @@
#+TITLE: Single Post, but draft
#+AUTHOR:
#+DATE: 2017-07-20
#+HUGO_PUBLISHDATE: 2017-07-22
#+HUGO_EXPIRYDATE: 2017-07-23

@ -1,4 +1,5 @@
#+TITLE: Single Post with TOML front matter
#+AUTHOR:
#+DATE: 2017-07-20
#+HUGO_PUBLISHDATE: 2017-07-22
#+HUGO_EXPIRYDATE: 2017-07-23

@ -1,4 +1,5 @@
#+TITLE: Single Post with YAML front matter
#+AUTHOR:
#+DATE: 2017-07-20
#+HUGO_PUBLISHDATE: 2017-07-22
#+HUGO_EXPIRYDATE: 2017-07-23

@ -8,6 +8,8 @@
# shortcode.
# #+HUGO_CODE_FENCE: t
#+AUTHOR:
#+SEQ_TODO: TODO DRAFT DONE
* Source blocks with Hugo =highlight= shortcode

@ -1,4 +1,6 @@
#+TITLE: My Blog
#+AUTHOR:
#+HUGO_BASE_DIR: ../
#+TAGS: these tags do not get globally applied to the posts

@ -1,7 +1,7 @@
+++
title = "Alias without section portion 2"
aliases = ["/alias-test/alias-b"]
tags = ["aliases"]
tags = ["front-matter", "aliases"]
draft = false
+++

@ -1,6 +1,6 @@
+++
title = "Alias specifying a different section"
aliases = ["/alias-test/alias-c"]
tags = ["aliases"]
tags = ["front-matter", "aliases"]
draft = false
+++

@ -1,6 +1,6 @@
+++
title = "Multiple aliases with section portion"
aliases = ["/alias-test/alias-g", "/alias-test/alias-h"]
tags = ["aliases"]
tags = ["front-matter", "aliases"]
draft = false
+++

@ -1,6 +1,6 @@
+++
title = "Multiple aliases without section portion"
aliases = ["/posts/alias-e", "/posts/alias-f"]
tags = ["aliases"]
tags = ["front-matter", "aliases"]
draft = false
+++

@ -1,6 +1,6 @@
+++
title = "Alias specifying root section"
aliases = ["/alias-d"]
tags = ["aliases"]
tags = ["front-matter", "aliases"]
draft = false
+++

@ -1,7 +1,7 @@
+++
title = "Alias without section portion 1"
aliases = ["/posts/alias-a"]
tags = ["aliases"]
tags = ["front-matter", "aliases"]
draft = false
+++

@ -1,6 +1,6 @@
+++
title = "Auto-set Lastmod"
lastmod = 2017-12-01T07:02:01-05:00
lastmod = 2017-12-01T16:24:29-05:00
tags = ["dont-export-during-make-test"]
draft = false
+++

@ -0,0 +1,8 @@
+++
title = "Disable exporting author"
tags = ["export-option", "author", "disable"]
draft = false
+++
This post will be exported without `author` in the front-matter because
it is disabled using `:EXPORT_OPTIONS: author:nil`.

@ -0,0 +1,9 @@
+++
title = "Multiple authors"
author = ["Foo Bar", "Toto Kumar", "Zulu", "Ágota Kristóf"]
tags = ["front-matter", "author"]
draft = false
+++
This post has multiple authors. In Org, multiple authors are added
comma-separated.

@ -0,0 +1,8 @@
+++
title = "Single author"
author = ["Foo Bar"]
tags = ["front-matter", "author"]
draft = false
+++
This post has 1 author.

@ -1,9 +1,9 @@
+++
title = "Multifractals in ecology using R"
author = ["Leonardo A. Saravia"]
date = 2017-11-28T10:48:00-05:00
tags = ["real-examples", "math", "equations"]
draft = false
author = "Leonardo A. Saravia"
source = "https://github.com/lsaravia/MultifractalsInR/blob/master/Curso3.md"
+++

@ -1,8 +1,10 @@
+++
title = "神经网络基础"
author = ["Feng Ruohang"]
date = 2017-11-29
tags = ["real-examples", "math", "equations", "not-english", "table", "latex", "latex-environment"]
draft = false
source = "https://github.com/Vonng/Math/blob/master/nndl/nn-intro.md"
+++
- **Disclaimer:** This post is from the [link](https://github.com/Vonng/Math/blob/master/nndl/nn-intro.md) posted by GitHub user

@ -1,8 +1,9 @@
+++
title = "Writing Hugo blog in Org (File Export)"
author = ["Kaushal Modi"]
date = 2017-09-10
lastmod = 2017-11-30T14:21:54-05:00
tags = ["hugo", "org", "dont_export_during_make_test"]
lastmod = 2017-12-01T16:23:22-05:00
tags = ["hugo", "org"]
categories = ["emacs"]
weight = 2001
draft = true

@ -1,7 +1,8 @@
+++
title = "Writing Hugo blog in Org"
author = ["Kaushal Modi"]
date = 2017-09-10
lastmod = 2017-11-30T14:22:00-05:00
lastmod = 2017-12-01T16:24:07-05:00
tags = ["dont-export-during-make-test", "hugo", "org"]
categories = ["emacs"]
weight = 2001

Loading…
Cancel
Save