;; -*- lexical-binding: t -*-
(require 'ox)
(require 'subr-x)
(require 'xmlgen)
(require 'ennum-lang)
(defun expand-file-name* (name base-directory)
(expand-file-name name (concat "/" base-directory)))
(org-export-define-derived-backend 'ennum-html 'html
:translate-alist
'((inner-template . ennum-html-inner-template))
:options-alist
'((:summary "SUMMARY" nil nil parse)
(:thumbnail "THUMBNAIL" nil nil t)
(:translation-group "TRANSLATION_GROUP" nil nil t)
(:html-doctype "HTML_DOCTYPE" nil "html5")))
(defun ennum-html-inner-template (contents info)
(concat
;; Table of contents
(let ((depth (plist-get info :with-toc)))
(when depth (org-html-toc depth info)))
;; Beginning of h-entry
""
;; Title
(format "%s
\n"
(org-export-data (plist-get info :title) info))
;; Author and date
(let ((author (when (plist-get info :with-author)
(plist-get info :author)))
(date (when (plist-get info :with-date)
(org-export-get-date info))))
(when (or author date)
(xmlgen `(p "Published"
,@(when author
`(" by "
(a :class "p-author h-card"
:href ,(ennum--absolute-uri "")
,(car (plist-get info :author)))))
,@(when date
`(" on "
(time :class "dt-published"
:datetime ,(org-export-get-date info "%Y-%m-%d 12:00:00")
,(org-export-get-date info "%B %d, %Y"))))))))
;; Interlanguage language links
(when-let (translations (ennum-post-translations (plist-get info :ennum-post)))
(format "In other languages: %s
"
(mapconcat
(pcase-lambda (`(,lang . ,slug))
(replace-regexp-in-string
"Tags: %s
"
(mapconcat
(lambda (tag)
(replace-regexp-in-string
"%s"
(org-export-data (plist-get info :summary) info))
;; Document contents
(format "%s
" contents)
;; Footnotes section
(org-html-footnote-section info)
""))
(provide 'ennum-html)