diff --git a/ox-hugo.el b/ox-hugo.el index f7259ea..e2d53c8 100644 --- a/ox-hugo.el +++ b/ox-hugo.el @@ -1740,7 +1740,9 @@ CONTENTS is the headline contents. INFO is a plist used as a communication channel." (unless (org-element-property :footnote-section-p headline) (let* ((numbers (org-hugo--get-headline-number headline info nil)) + (loffset (string-to-number (plist-get info :hugo-level-offset))) ;"" -> 0, "0" -> 0, "1" -> 1, .. (level (org-export-get-relative-level headline info)) + (level-effective (+ loffset level)) (title (org-export-data (org-element-property :title headline) info)) ;`org-export-data' required (todo (and (org-hugo--plist-get-true-p info :with-todo-keywords) (org-element-property :todo-keyword headline))) @@ -1759,8 +1761,8 @@ a communication channel." ;; Cannot create a headline. Fall-back to a list. ((or (org-export-low-level-p headline info) (not (memq style '(atx setext))) - (and (eq style 'atx) (> level 6)) - (and (eq style 'setext) (> level 2))) + (and (eq style 'atx) (> level-effective 6)) + (and (eq style 'setext) (> level-effective 2))) (let ((bullet (if (not (org-export-numbered-headline-p headline info)) "-" (concat (number-to-string @@ -1774,7 +1776,6 @@ a communication channel." (let ((anchor (format "{#%s}" ;https://gohugo.io/extras/crossreferences/ (or (org-element-property :CUSTOM_ID headline) (org-hugo-slug title)))) - (loffset (string-to-number (plist-get info :hugo-level-offset))) ;"" -> 0, "0" -> 0, "1" -> 1, .. (todo (when todo (concat (org-hugo--todo todo info) " ")))) (concat (org-hugo--headline-title style level loffset title todo anchor numbers) diff --git a/test/site/content-org/all-posts.org b/test/site/content-org/all-posts.org index d56c402..8bc9a52 100644 --- a/test/site/content-org/all-posts.org +++ b/test/site/content-org/all-posts.org @@ -4039,6 +4039,55 @@ with spaces was added in {{{commit(7691f0453b)}}}. #+end_description *** TEST__TODO This heading's TODO kwd should read as "TEST TODO" *** TEST__DONE This heading's TODO kwd should read as "TEST DONE" +** Deeply nested Org TODO headings :nested: +*** Reused test body +:PROPERTIES: +:CUSTOM_ID: deeply-nested-todo-headings +:END: +{{{oxhugoissue(250)}}} +**** TODO Level 1 +***** TODO Level 2 +****** TODO Level 3 +******* TODO Level 4 +******** TODO Level 5 +********* TODO Level 6 +********** TODO Level 7 +*** Deeply nested Org TODO headings -- Default heading level +:PROPERTIES: +:EXPORT_FILE_NAME: deeply-nested-org-todo-headings--default-h +:END: +#+include: "./all-posts.org::#deeply-nested-todo-headings" :only-contents t +*** Deeply nested Org TODO headings -- h1 +:PROPERTIES: +:EXPORT_FILE_NAME: deeply-nested-org-todo-headings--h1 +:EXPORT_OPTIONS: h:1 +:END: +#+include: "./all-posts.org::#deeply-nested-todo-headings" :only-contents t +*** Deeply nested Org TODO headings -- h2 +:PROPERTIES: +:EXPORT_FILE_NAME: deeply-nested-org-todo-headings--h2 +:EXPORT_OPTIONS: h:2 +:END: +#+include: "./all-posts.org::#deeply-nested-todo-headings" :only-contents t +*** Deeply nested Org TODO headings -- h5 +:PROPERTIES: +:EXPORT_FILE_NAME: deeply-nested-org-todo-headings--h5 +:EXPORT_OPTIONS: h:5 +:END: +#+include: "./all-posts.org::#deeply-nested-todo-headings" :only-contents t +*** Deeply nested Org TODO headings -- h6 +:PROPERTIES: +:EXPORT_FILE_NAME: deeply-nested-org-todo-headings--h6 +:EXPORT_OPTIONS: h:6 +:END: +#+include: "./all-posts.org::#deeply-nested-todo-headings" :only-contents t +*** Deeply nested Org TODO headings -- h6, Offset 0 +:PROPERTIES: +:EXPORT_FILE_NAME: deeply-nested-org-todo-headings--h6--offset0 +:EXPORT_OPTIONS: h:6 +:EXPORT_HUGO_LEVEL_OFFSET: 0 +:END: +#+include: "./all-posts.org::#deeply-nested-todo-headings" :only-contents t * Level Offset :level_offset: ** Default level offset :PROPERTIES: diff --git a/test/site/content/posts/deeply-nested-org-todo-headings--default-h.md b/test/site/content/posts/deeply-nested-org-todo-headings--default-h.md new file mode 100644 index 0000000..481f652 --- /dev/null +++ b/test/site/content/posts/deeply-nested-org-todo-headings--default-h.md @@ -0,0 +1,25 @@ ++++ +title = "Deeply nested Org TODO headings –Default heading level" +tags = ["todo", "nested"] +draft = false ++++ + +`ox-hugo` Issue #[250](https://github.com/kaushalmodi/ox-hugo/issues/250) + + +## TODO Level 1 {#level-1} + + +### TODO Level 2 {#level-2} + + +#### TODO Level 3 {#level-3} + + +##### TODO Level 4 {#level-4} + +- TODO Level 5 + + - TODO Level 6 + + - TODO Level 7 diff --git a/test/site/content/posts/deeply-nested-org-todo-headings--h1.md b/test/site/content/posts/deeply-nested-org-todo-headings--h1.md new file mode 100644 index 0000000..4705432 --- /dev/null +++ b/test/site/content/posts/deeply-nested-org-todo-headings--h1.md @@ -0,0 +1,22 @@ ++++ +title = "Deeply nested Org TODO headings –h1" +tags = ["todo", "nested"] +draft = false ++++ + +`ox-hugo` Issue #[250](https://github.com/kaushalmodi/ox-hugo/issues/250) + + +## TODO Level 1 {#level-1} + +- TODO Level 2 + + - TODO Level 3 + + - TODO Level 4 + + - TODO Level 5 + + - TODO Level 6 + + - TODO Level 7 diff --git a/test/site/content/posts/deeply-nested-org-todo-headings--h2.md b/test/site/content/posts/deeply-nested-org-todo-headings--h2.md new file mode 100644 index 0000000..506abda --- /dev/null +++ b/test/site/content/posts/deeply-nested-org-todo-headings--h2.md @@ -0,0 +1,23 @@ ++++ +title = "Deeply nested Org TODO headings –h2" +tags = ["todo", "nested"] +draft = false ++++ + +`ox-hugo` Issue #[250](https://github.com/kaushalmodi/ox-hugo/issues/250) + + +## TODO Level 1 {#level-1} + + +### TODO Level 2 {#level-2} + +- TODO Level 3 + + - TODO Level 4 + + - TODO Level 5 + + - TODO Level 6 + + - TODO Level 7 diff --git a/test/site/content/posts/deeply-nested-org-todo-headings--h5.md b/test/site/content/posts/deeply-nested-org-todo-headings--h5.md new file mode 100644 index 0000000..d13192e --- /dev/null +++ b/test/site/content/posts/deeply-nested-org-todo-headings--h5.md @@ -0,0 +1,26 @@ ++++ +title = "Deeply nested Org TODO headings –h5" +tags = ["todo", "nested"] +draft = false ++++ + +`ox-hugo` Issue #[250](https://github.com/kaushalmodi/ox-hugo/issues/250) + + +## TODO Level 1 {#level-1} + + +### TODO Level 2 {#level-2} + + +#### TODO Level 3 {#level-3} + + +##### TODO Level 4 {#level-4} + + +###### TODO Level 5 {#level-5} + +- TODO Level 6 + + - TODO Level 7 diff --git a/test/site/content/posts/deeply-nested-org-todo-headings--h6--offset0.md b/test/site/content/posts/deeply-nested-org-todo-headings--h6--offset0.md new file mode 100644 index 0000000..670dac4 --- /dev/null +++ b/test/site/content/posts/deeply-nested-org-todo-headings--h6--offset0.md @@ -0,0 +1,27 @@ ++++ +title = "Deeply nested Org TODO headings –h6, Offset 0" +tags = ["todo", "nested"] +draft = false ++++ + +`ox-hugo` Issue #[250](https://github.com/kaushalmodi/ox-hugo/issues/250) + + +# TODO Level 1 {#level-1} + + +## TODO Level 2 {#level-2} + + +### TODO Level 3 {#level-3} + + +#### TODO Level 4 {#level-4} + + +##### TODO Level 5 {#level-5} + + +###### TODO Level 6 {#level-6} + +- TODO Level 7 diff --git a/test/site/content/posts/deeply-nested-org-todo-headings--h6.md b/test/site/content/posts/deeply-nested-org-todo-headings--h6.md new file mode 100644 index 0000000..cd6eb33 --- /dev/null +++ b/test/site/content/posts/deeply-nested-org-todo-headings--h6.md @@ -0,0 +1,26 @@ ++++ +title = "Deeply nested Org TODO headings –h6" +tags = ["todo", "nested"] +draft = false ++++ + +`ox-hugo` Issue #[250](https://github.com/kaushalmodi/ox-hugo/issues/250) + + +## TODO Level 1 {#level-1} + + +### TODO Level 2 {#level-2} + + +#### TODO Level 3 {#level-3} + + +##### TODO Level 4 {#level-4} + + +###### TODO Level 5 {#level-5} + +- TODO Level 6 + + - TODO Level 7