diff --git a/example-site/content-org/all-posts.org b/example-site/content-org/all-posts.org index 60c707e..91d9343 100644 --- a/example-site/content-org/all-posts.org +++ b/example-site/content-org/all-posts.org @@ -392,6 +392,15 @@ Here the front matter format is set to YAML using the =HUGO_FRONT_MATTER_FORMAT= key in property drawer. Here there is white space in menu name property. +* Post body +** Summary Splitter +:PROPERTIES: +:EXPORT_FILE_NAME: summary-splitter +:EXPORT_DATE: 2017-07-21 +:END: +Here is the summary. +#+HUGO: more +Here is text after the [[https://gohugo.io/content-management/summaries#user-defined-manual-summary-splitting][summary splitter]]. * TODO Pre-Draft State :PROPERTIES: :EXPORT_FILE_NAME: draft-state-todo diff --git a/example-site/content/posts/summary-splitter.md b/example-site/content/posts/summary-splitter.md new file mode 100644 index 0000000..517b75e --- /dev/null +++ b/example-site/content/posts/summary-splitter.md @@ -0,0 +1,12 @@ ++++ +title = "Summary Splitter" +date = 2017-07-21 +tags = [] +draft = false ++++ + +Here is the summary. + + + +Here is text after the [summary splitter](https://gohugo.io/content-management/summaries#user-defined-manual-summary-splitting). diff --git a/ox-hugo.el b/ox-hugo.el index bd264b8..2e57c8c 100644 --- a/ox-hugo.el +++ b/ox-hugo.el @@ -107,8 +107,9 @@ directory where all Hugo posts should go by default." (lambda (a s v _b) (org-hugo-export-as-md a s v))))) :translate-alist '((headline . org-hugo-headline) - (src-block . org-hugo-src-block) - (link . org-hugo-link)) + (keyword . org-hugo-keyword) + (link . org-hugo-link) + (src-block . org-hugo-src-block)) :filters-alist '((:filter-body . org-hugo-body-filter)) ;; KEY KEYWORD OPTION DEFAULT BEHAVIOR @@ -286,19 +287,21 @@ section as a string." (let ((level-mark (make-string (+ loffset level) ?#))) (concat "\n" level-mark " " title " " anchor "\n\n")))) -;;;; Source Blocks -(defun org-hugo-src-block (src-block _contents info) - "Convert SRC-BLOCK element to Hugo-compatible element. - - If the HUGO_CODE_FENCE property is set to t (default), the - Markdown style triple-backquoted code blocks are created. - Otherwise, the code block is wrapped in Hugo `highlight' - shortcode." - (if (string= "t" (org-export-data (plist-get info :hugo-code-fence) info)) - (org-blackfriday-src-block src-block nil info) - (let* ((lang (org-element-property :language src-block)) - (code (org-export-format-code-default src-block info))) - (format "{{< highlight %s>}}\n%s{{< /highlight >}}\n" lang code)))) +;;;; Keyword +(defun org-hugo-keyword (keyword contents info) + "Transcode a KEYWORD element into Hugo-compatible Markdown format. +CONTENTS is nil. INFO is a plist used as a communication +channel." + (let ((kwd (org-element-property :key keyword)) + (value (org-element-property :value keyword))) + (cond + ((and (equal "HUGO" kwd) ;Hugo summary splitting + (stringp value) + (string-match-p "\\`\\s-*more\\s-*\\'" value)) + ;; https://gohugo.io/content-management/summaries#user-defined-manual-summary-splitting + "") + (t + (org-md-keyword keyword contents info))))) ;;;; Links (defun org-hugo-link (link contents info) @@ -436,6 +439,20 @@ INFO is a plist used as a communication channel." (concat "/" (file-name-as-directory (plist-get info :hugo-static-images)) file-name)) path))) +;;;; Source Blocks +(defun org-hugo-src-block (src-block _contents info) + "Convert SRC-BLOCK element to Hugo-compatible element. + + If the HUGO_CODE_FENCE property is set to t (default), the + Markdown style triple-backquoted code blocks are created. + Otherwise, the code block is wrapped in Hugo `highlight' + shortcode." + (if (string= "t" (org-export-data (plist-get info :hugo-code-fence) info)) + (org-blackfriday-src-block src-block nil info) + (let* ((lang (org-element-property :language src-block)) + (code (org-export-format-code-default src-block info))) + (format "{{< highlight %s>}}\n%s{{< /highlight >}}\n" lang code)))) + ;;; Filter Functions