-
Notifications
You must be signed in to change notification settings - Fork 13
/
lentic-ox.el
89 lines (69 loc) · 2.72 KB
/
lentic-ox.el
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
85
86
87
88
89
;;; lentic-ox.el --- Exporter backend for orgel documentation -*- lexical-binding: t -*-
;;; Header:
;; This file is not part of Emacs
;; The contents of this file are subject to the GPL License, Version 3.0.
;; Copyright (C) 2015-2022 Free Software Foundation, Inc.
;; This program is free software: you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.
;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License
;; along with this program. If not, see <http://www.gnu.org/licenses/>.
;;; Commentary:
;; An org-mode exporter for lentic.
;;; Code:
;; #+begin_src emacs-lisp
(require 'ox-html)
(require 'dash)
;; Define an exporter
(org-export-define-derived-backend 'lentic
'html
:filters-alist
'((:filter-parse-tree . lentic-ox-filter-parse-tree)
(:filter-section . lentic-ox-filter-section)))
;; Main export function
(defun lentic-ox-html-export-to-html ()
"Export the current buffer to a HTML file."
(interactive)
(let* ((extension (concat "." org-html-extension))
(file (org-export-output-file-name extension))
(org-export-coding-system org-html-coding-system)
(org-html-htmlize-output-type 'css)
(org-html-postamble nil)
(org-html-use-infojs t)
(org-html-head
"<link rel=\"stylesheet\" type=\"text/css\" href=\"http://phillord.github.io/lentic/include/lenticular.css\" />"))
(org-export-to-file 'lentic file)))
(defvar lentic-ox-no-export-headers '("Header")
"List of headers to which noexport tags should be added.")
(defun lentic-ox-filter-parse-tree (tree _back-end _info)
"Filter preventing the export of specific headers.
TREE is the parse tree. BACK-END is the symbol specifying
back-end used for export. INFO is a plist used as a communication
channel."
(org-element-map tree 'headline
(lambda (head)
(if (-contains?
lentic-ox-no-export-headers
(org-element-property
:raw-value
head))
(org-element-put-property
head :tags
(cons "noexport"
(org-element-property :tags head)))
head)))
tree)
(defun lentic-ox-filter-section (section back-end info)
"Currently does nothing useful."
section back-end info
(org-element-property :parent section)
section
)
(provide 'lentic-ox)
;;; lentic-ox.el ends here
;; #+end_src