Skip to content

Commit

Permalink
support fullwidth image for html5 page
Browse files Browse the repository at this point in the history
  • Loading branch information
Zilong-Li committed Oct 14, 2024
1 parent 5a467f1 commit 8554d35
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
12 changes: 6 additions & 6 deletions org-tufte.el
Original file line number Diff line number Diff line change
Expand Up @@ -244,16 +244,16 @@ is nil. INFO is a plist used as a communication channel."
(org-html-close-tag "img" (org-html--make-attribute-string attributes) info)))


(defun org-tufte-html-wrap-image (contents info &optional caption label)
(defun org-tufte-html-wrap-image (contents info &optional attributes caption label)
"Wrap CONTENTS string within an appropriate environment for images.
INFO is a plist used as a communication channel. When optional
INFO is a plist used as a communication channel. When optional
arguments CAPTION and LABEL are given, use them for caption and
\"id\" attribute."
\"id\" attribute. When html_doctype is html5, then put ATTRIBUTES in <figure> element"
(let ((html5-fancy (org-html--html5-fancy-p info)))
(format (if html5-fancy "\n<figure%s><p>\n%s%s\n</figure>"
(format (if html5-fancy "\n<figure %s><p>\n%s%s\n</figure>"
"\n<div%s class=\"figure\"><p>\n%s%s\n</div>")
;; ID.
(if (org-string-nw-p label) (format " id=\"%s\"" label) "")
(if html5-fancy attributes (if (org-string-nw-p label) (format " id=\"%s\"" label) ""))
;; Caption.
(if (not (org-string-nw-p caption)) ""
(format
Expand Down Expand Up @@ -302,7 +302,7 @@ the plist used as a communication channel."
" </span>"
raw))))
(label (org-html--reference paragraph info)))
(org-tufte-html-wrap-image contents info caption label)))
(org-tufte-html-wrap-image contents info attributes caption label)))
;; Regular paragraph.
(t (format "<p%s%s>\n%s</p>"
(if (org-string-nw-p attributes)
Expand Down
4 changes: 4 additions & 0 deletions readme.org
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ Just fetch [[file:org-tufte.el]] and save it somewhere. Then load it
(setq org-tufte-htmlize-code t ;; htmlize and beautify source code!
org-tufte-embed-images nil ;; do not embed images. faster!
org-tufte-goto-top-button t ;; add go-to-top button in html
org-html-html5-fancy t ;; enable html5 elements
org-html-doctype "html5" ;; html5 page
)
)
#+end_src
Expand Down Expand Up @@ -66,6 +68,8 @@ configuration.
#+end_src

* Changelog
** v0.8.0
- fullwidth image is supported for html5 page via =#+attr_html: :class fullwidth=
** v0.7.0
- Can work properly with ~rg-publish-org-to~
** v0.6.0
Expand Down

0 comments on commit 8554d35

Please sign in to comment.