Skip to content

Commit

Permalink
Use the Hugo "figure" shortcode instead of standard md images
Browse files Browse the repository at this point in the history
Using the "figure" shortcode allows us to support class attributes and
captions for exported images, which are not available in
blackfriday-flavoured markdown.

Begins to address #3 and
#4.
  • Loading branch information
titaniumbones committed Jul 8, 2017
1 parent 44a3a0d commit f771160
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions ox-hugo.el
Original file line number Diff line number Diff line change
Expand Up @@ -185,18 +185,21 @@ and rewrite link paths to make blogging more seamless."
((org-export-inline-image-p link org-html-inline-image-rules)
(message "org-hugo-link processing an image %s" contents)

(let ((path (org-hugo--attachment-rewrite
(let* ((path (org-hugo--attachment-rewrite
(let ((raw-path (org-element-property :path link)))
(if (not (file-name-absolute-p raw-path)) raw-path
(expand-file-name raw-path)))
info))
(caption (org-export-data
(org-export-get-caption
(org-export-get-parent-element link))
info)))
(format "![img](%s)"
(if (not (org-string-nw-p caption)) path
(format "%s \"%s\"" path caption)))))
info))
(parent (org-export-get-parent link))
(attr (org-export-read-attribute :attr_html parent))
(class (plist-get attr :class)))
(format "{{<figure src=\"%s\" caption=\"%s\" class=\"%s\">}}"
path caption class
)))
((string= type "coderef")
(let ((ref (org-element-property :path link)))
(format (org-export-get-coderef-format ref contents)
Expand Down

0 comments on commit f771160

Please sign in to comment.