Add support for Export Snippets and Export Blocks

Now these work:

* Export Snippets

  @@hugo:foo@@

* Export Blocks

  #+BEGIN_EXPORT hugo
  foo
  #+END_EXPORT
master
Kaushal Modi 8 years ago
parent a4131a2deb
commit 1149f20cd7
  1. 32
      ox-hugo.el
  2. 10
      test/site/content-org/all-posts.org
  3. 14
      test/site/content/posts/export_snippets_and_blocks.md

@ -606,6 +606,8 @@ newer."
(org-hugo-export-as-md a s v)))))
:translate-alist '((code . org-hugo-kbd-tags-maybe)
(example-block . org-hugo-example-block)
(export-block . org-hugo-export-block)
(export-snippet . org-hugo-export-snippet)
(headline . org-hugo-headline)
(inner-template . org-hugo-inner-template)
(keyword . org-hugo-keyword)
@ -988,6 +990,36 @@ information."
(format "{{< highlight text %s>}}\n%s{{< /highlight >}}\n" linenos-str text))
(org-blackfriday-example-block example-block nil info))))
;;;; Export Snippet
(defun org-hugo-export-snippet (export-snippet _contents _info)
"Transcode a EXPORT-SNIPPET object from Org to Hugo-compatible Markdown.
CONTENTS is nil. INFO is a plist holding contextual information.
Example:
\"@@hugo:foo@@\"
exports verbatim to \"foo\" only when exported using `hugo'
backend."
(when (eq (org-export-snippet-backend export-snippet) 'hugo)
(org-element-property :value export-snippet)))
;;;; Export Block
(defun org-hugo-export-block (export-block _contents info)
"Transcode a EXPORT-BLOCK element from Org to Hugo-compatible Markdown.
CONTENTS is nil. INFO is a plist holding contextual information.
Example:
#+BEGIN_EXPORT hugo
foo
#+END_EXPORT
exports verbatim to \"foo\" only when exported using `hugo'
backend."
(when (string= (org-element-property :type export-block) "HUGO")
(org-element-property :value export-block)))
;;;; Headline
(defun org-hugo-headline (headline contents info)
"Transcode HEADLINE element into Markdown format.

@ -2638,6 +2638,16 @@ The front-matter for this post contains the default Creator string.
:EXPORT_FILE_NAME: custom-creator
:END:
The front-matter for this post contains a custom Creator string.
* Export snippets and blocks :export_snippet:export_block:
:PROPERTIES:
:EXPORT_FILE_NAME: export_snippets_and_blocks
:END:
** Export snippet
@@hugo:This will get exported only for Hugo exports, `verbatim`.@@
** Export block
#+BEGIN_EXPORT hugo
and **this too**.. `verbatim`.
#+END_EXPORT
* Miscellaneous Front Matter :front_matter:
** Hugo Aliases :aliases:
*** Alias without section portion 1

@ -0,0 +1,14 @@
+++
title = "Export snippets and blocks"
tags = ["export-snippet", "export-block"]
draft = false
+++
## Export snippet {#export-snippet}
This will get exported only for Hugo exports, `verbatim`.
## Export block {#export-block}
and **this too**.. `verbatim`.
Loading…
Cancel
Save