Skip to content

Commit

Permalink
Refactor: *-prefer-hyphen-in-tags -> *-enable-special-tags
Browse files Browse the repository at this point in the history
Minor re-org in all-posts.org
  • Loading branch information
kaushalmodi committed Aug 10, 2017
1 parent 3e39876 commit 0b775c7
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 28 deletions.
39 changes: 20 additions & 19 deletions example-site/content-org/all-posts.org
Expand Up @@ -172,12 +172,6 @@ This post must not be exported as it is tagged =noexport=.
:EXPORT_FILE_NAME: commented-post
:END:
This post must not be exported as it is commented.
* Test tags :abc:def:
:PROPERTIES:
:EXPORT_FILE_NAME: test-tags
:EXPORT_DATE: 2017-07-12T13:48:01-04:00
:END:
Testing tags set using Org tags in headings.
* Section
** Articles
:PROPERTIES:
Expand Down Expand Up @@ -740,40 +734,47 @@ This is some text[fn:1][fn:2].
This is some text[fn:1].
This is some text[fn:1].
This is some text[fn:1].
* Hyphens in Org tags
** Prefer
* Tags
** Basic tags :abc:def:
:PROPERTIES:
:EXPORT_FILE_NAME: test-tags
:EXPORT_DATE: 2017-07-12T13:48:01-04:00
:END:
Testing tags set using Org tags in headings.
** Hyphens in Org tags
*** Prefer
:PROPERTIES:
:EXPORT_HUGO_PREFER_HYPHEN_IN_TAGS: t
:EXPORT_HUGO_ENABLE_SPECIAL_TAGS: t
:END:
*** Prefer Hyphen in Tags :_a:__a:b_:b__:a_b:a__b:a_b__c:_a_b__c__:
**** Prefer Hyphen in Tags :_a:__a:b_:b__:a_b:a__b:a_b__c:_a_b__c__:
:PROPERTIES:
:EXPORT_FILE_NAME: hyphen-tags-prefer
:END:
*** Prefer Hyphen Categories :@_a:@__a:@b_:@b__:@a_b:@a__b:@a_b__c:@_a_b__c__:
**** Prefer Hyphen Categories :@_a:@__a:@b_:@b__:@a_b:@a__b:@a_b__c:@_a_b__c__:
:PROPERTIES:
:EXPORT_FILE_NAME: hyphen-categories-prefer
:END:
** Don't Prefer
*** Don't Prefer
:PROPERTIES:
:EXPORT_HUGO_PREFER_HYPHEN_IN_TAGS:
:EXPORT_HUGO_ENABLE_SPECIAL_TAGS:
:END:
*** Don't Prefer Hyphen in Tags :_a:__a:b_:b__:a_b:a__b:a_b__c:_a_b__c__:
**** Don't Prefer Hyphen in Tags :_a:__a:b_:b__:a_b:a__b:a_b__c:_a_b__c__:
:PROPERTIES:
:EXPORT_FILE_NAME: hyphen-tags-dont-prefer
:END:
*** Don't Prefer Hyphen Categories :@_a:@__a:@b_:@b__:@a_b:@a__b:@a_b__c:@_a_b__c__:
**** Don't Prefer Hyphen Categories :@_a:@__a:@b_:@b__:@a_b:@a__b:@a_b__c:@_a_b__c__:
:PROPERTIES:
:EXPORT_FILE_NAME: hyphen-categories-dont-prefer
:END:
* Tags as Categories
** Category A :@catA:
*** Cat A post 1 :meow:
** Tags as Categories
*** Category A :@catA:
**** Cat A post 1 :meow:
:PROPERTIES:
:EXPORT_DATE: 2017-07-24
:EXPORT_FILE_NAME: cat-a-post-1
:END:
This post is in category =catA= and tagged =meow=.
*** Cat A and cat B :@catB:
**** Cat A and cat B :@catB:
:PROPERTIES:
:EXPORT_FILE_NAME: cat-a-and-cat-b
:EXPORT_DATE: 2017-07-24
Expand Down
2 changes: 1 addition & 1 deletion example-site/content/posts/test-tags.md
@@ -1,5 +1,5 @@
+++
title = "Test tags"
title = "Basic tags"
date = 2017-07-12T13:48:01-04:00
tags = ["abc", "def"]
draft = false
Expand Down
17 changes: 9 additions & 8 deletions ox-hugo.el
Expand Up @@ -364,9 +364,10 @@ The string needs to be in a Hugo-compatible Markdown format or HTML."
:type 'boolean
:safe #'booleanp)

(defcustom org-hugo-prefer-hyphen-in-tags t
"When non-nil, replace underscores with hyphens in Org tags.
In that case, use double underscores to represent a single underscore.
(defcustom org-hugo-enable-special-tags t
"When non-nil, interpret Org tags in special manner.
See `org-hugo--transform-org-tags' for more information.
This also affects the Hugo categories set via Org tags using the
\"@\" prefix."
Expand Down Expand Up @@ -441,7 +442,7 @@ Example value: (org)."
(:hugo-menu "HUGO_MENU" nil nil)
(:hugo-menu-override "HUGO_MENU_OVERRIDE" nil nil)
(:hugo-use-code-for-kbd "HUGO_USE_CODE_FOR_KBD" nil org-hugo-use-code-for-kbd)
(:hugo-prefer-hyphen-in-tags "HUGO_PREFER_HYPHEN_IN_TAGS" nil org-hugo-prefer-hyphen-in-tags)
(:hugo-enable-special-tags "HUGO_ENABLE_SPECIAL_TAGS" nil org-hugo-enable-special-tags)
(:hugo-custom-front-matter "HUGO_CUSTOM_FRONT_MATTER" nil nil)
(:hugo-blackfriday "HUGO_BLACKFRIDAY" nil nil)

Expand Down Expand Up @@ -1094,7 +1095,7 @@ INFO is a plist used as a communication channel."
date-nocolon)))
(draft (or org-hugo--draft-state
(org-export-data (plist-get info :hugo-draft) info)))
(tag-list (if (org-hugo--plist-value-true-p :hugo-prefer-hyphen-in-tags info)
(tag-list (if (org-hugo--plist-value-true-p :hugo-enable-special-tags info)
(mapcar #'org-hugo--transform-org-tags
org-hugo--tags-list)
org-hugo--tags-list))
Expand All @@ -1103,7 +1104,7 @@ INFO is a plist used as a communication channel."
(concat
(org-export-data (plist-get info :hugo-tags) info) " "
(org-export-data (plist-get info :tags) info)))))
(categories-list (if (org-hugo--plist-value-true-p :hugo-prefer-hyphen-in-tags info)
(categories-list (if (org-hugo--plist-value-true-p :hugo-enable-special-tags info)
(mapcar #'org-hugo--transform-org-tags
org-hugo--categories-list)
org-hugo--categories-list))
Expand Down Expand Up @@ -1305,7 +1306,7 @@ are \"toml\" and \"yaml\"."
(defun org-hugo--selective-property-inheritance ()
"Return a list of properties that should be inherited."
(let ((prop-list '("HUGO_FRONT_MATTER_FORMAT"
"HUGO_PREFER_HYPHEN_IN_TAGS"
"HUGO_ENABLE_SPECIAL_TAGS"
"HUGO_BLACKFRIDAY"
"HUGO_SECTION"
"HUGO_BASE_DIR"
Expand Down Expand Up @@ -1637,7 +1638,7 @@ buffer and returned as a string in Org format."
,(format "|org-hugo-front-matter-format |%S|" org-hugo-front-matter-format)
,(format "|org-hugo-default-section-directory |%S|" org-hugo-default-section-directory)
,(format "|org-hugo-use-code-for-kbd |%S|" org-hugo-use-code-for-kbd)
,(format "|org-hugo-prefer-hyphen-in-tags |%S|" org-hugo-prefer-hyphen-in-tags)
,(format "|org-hugo-enable-special-tags |%S|" org-hugo-enable-special-tags)
,(format "|org-hugo-langs-no-descr-in-code-fences|%S|" org-hugo-langs-no-descr-in-code-fences))
"\n"))
(org-export-with-toc nil)
Expand Down

1 comment on commit 0b775c7

@kaushalmodi
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Whoever is reading this, ignore this commit.

Please sign in to comment.