blob: f9d2d32f1fdade18f008874133139b0d0be5380e (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
|
;; -*- 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
"<article class=\"h-entry\">"
;; Title
(format "<h1 class=\"p-name\">%s</h1>\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 "<p>In other languages: %s</p>"
(mapconcat
(pcase-lambda (`(,lang . ,slug))
(replace-regexp-in-string
"<a " (format "<a hreflang=\"%s\" " lang)
(ennum-link-export-post
slug
(map-elt ennum--iso-639-1-alist lang)
(org-export-backend-name (plist-get info :back-end))
info)))
translations
", ")))
;; Tags
(when-let (tags (plist-get info :filetags))
(format "<p>Tags: %s</p>"
(mapconcat
(lambda (tag)
(replace-regexp-in-string
"<a " "<a class=\"p-category\" "
(ennum-link-export-tag
(ennum-add-tongue-suffix tag (plist-get info :language))
tag
(org-export-backend-name (plist-get info :back-end))
info)))
tags
", ")))
;; Summary
(format "<div class=\"p-summary\">%s</div>"
(org-export-data (plist-get info :summary) info))
;; Document contents
(format "<div class=\"e-content\">%s</div>" contents)
;; Footnotes section
(org-html-footnote-section info)
"</article>"))
(provide 'ennum-html)
|