Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Toggle ommission of subheading content #673

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions ox-hugo.el
Original file line number Diff line number Diff line change
Expand Up @@ -745,6 +745,17 @@ The software list is taken from https://www.gnu.org/software/."
:group 'org-export-hugo
:type '(repeat string))

(defcustom org-hugo-omit-subheadings nil
"When non-nil, omit subheadings with their own pages.

Normally, each heading includes its subheadings' content along
with its own. When this variable is non-nil, those subheadings
that have their own pages (as indicated by the presence of the
`:EXPORT_FILE_NAME' property), will have their content omitted
from the parent heading's page."
:group 'org-export-hugo
:type 'boolean)
;;;###autoload (put 'org-hugo-exclude-subheadings 'safe-local-variable 'booleanp)


;;; Define Back-End
Expand Down Expand Up @@ -2141,6 +2152,7 @@ a communication channel."
;; of that preceding list.
bullet " " heading tags-fmtd "\n\n"
(and contents (replace-regexp-in-string "^" " " contents)))))
((and org-hugo-omit-subheadings (org-hugo--export-file-name-p heading)) "")
(t
(let* ((anchor (format "{#%s}" (org-hugo--get-anchor heading info))) ;https://gohugo.io/extras/crossreferences/
(heading-title (org-hugo--heading-title style level loffset title
Expand Down Expand Up @@ -2183,6 +2195,10 @@ Else, no HTML element is wrapped around the HEADING."
(plist-get info :html-container)
"div"))))

(defun org-hugo--export-file-name-p (heading)
"Determine if a heading has the `:EXPORT_FILE_NAME' property."
(org-export-get-node-property :EXPORT_FILE_NAME heading nil))

;;;###autoload
(defun org-hugo-slug (str &optional allow-double-hyphens)
"Convert string STR to a `slug' and return that string.
Expand Down