commit | author | age
|
76bbd0
|
1 |
;;; ox-html.el --- HTML Back-End for Org Export Engine -*- lexical-binding: t; -*- |
C |
2 |
|
|
3 |
;; Copyright (C) 2011-2018 Free Software Foundation, Inc. |
|
4 |
|
|
5 |
;; Author: Carsten Dominik <carsten at orgmode dot org> |
|
6 |
;; Jambunathan K <kjambunathan at gmail dot com> |
|
7 |
;; Keywords: outlines, hypermedia, calendar, wp |
|
8 |
|
|
9 |
;; This file is part of GNU Emacs. |
|
10 |
|
|
11 |
;; GNU Emacs is free software: you can redistribute it and/or modify |
|
12 |
;; it under the terms of the GNU General Public License as published by |
|
13 |
;; the Free Software Foundation, either version 3 of the License, or |
|
14 |
;; (at your option) any later version. |
|
15 |
|
|
16 |
;; GNU Emacs is distributed in the hope that it will be useful, |
|
17 |
;; but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
18 |
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
19 |
;; GNU General Public License for more details. |
|
20 |
|
|
21 |
;; You should have received a copy of the GNU General Public License |
|
22 |
;; along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>. |
|
23 |
|
|
24 |
;;; Commentary: |
|
25 |
|
|
26 |
;; This library implements a HTML back-end for Org generic exporter. |
|
27 |
;; See Org manual for more information. |
|
28 |
|
|
29 |
;;; Code: |
|
30 |
|
|
31 |
;;; Dependencies |
|
32 |
|
|
33 |
(require 'cl-lib) |
|
34 |
(require 'format-spec) |
|
35 |
(require 'ox) |
|
36 |
(require 'ox-publish) |
|
37 |
(require 'table) |
|
38 |
|
|
39 |
|
|
40 |
;;; Function Declarations |
|
41 |
|
|
42 |
(declare-function org-id-find-id-file "org-id" (id)) |
|
43 |
(declare-function htmlize-region "ext:htmlize" (beg end)) |
|
44 |
(declare-function mm-url-decode-entities "mm-url" ()) |
|
45 |
|
|
46 |
(defvar htmlize-css-name-prefix) |
|
47 |
(defvar htmlize-output-type) |
|
48 |
(defvar htmlize-output-type) |
|
49 |
(defvar htmlize-css-name-prefix) |
|
50 |
|
|
51 |
;;; Define Back-End |
|
52 |
|
|
53 |
(org-export-define-backend 'html |
|
54 |
'((bold . org-html-bold) |
|
55 |
(center-block . org-html-center-block) |
|
56 |
(clock . org-html-clock) |
|
57 |
(code . org-html-code) |
|
58 |
(drawer . org-html-drawer) |
|
59 |
(dynamic-block . org-html-dynamic-block) |
|
60 |
(entity . org-html-entity) |
|
61 |
(example-block . org-html-example-block) |
|
62 |
(export-block . org-html-export-block) |
|
63 |
(export-snippet . org-html-export-snippet) |
|
64 |
(fixed-width . org-html-fixed-width) |
|
65 |
(footnote-definition . org-html-footnote-definition) |
|
66 |
(footnote-reference . org-html-footnote-reference) |
|
67 |
(headline . org-html-headline) |
|
68 |
(horizontal-rule . org-html-horizontal-rule) |
|
69 |
(inline-src-block . org-html-inline-src-block) |
|
70 |
(inlinetask . org-html-inlinetask) |
|
71 |
(inner-template . org-html-inner-template) |
|
72 |
(italic . org-html-italic) |
|
73 |
(item . org-html-item) |
|
74 |
(keyword . org-html-keyword) |
|
75 |
(latex-environment . org-html-latex-environment) |
|
76 |
(latex-fragment . org-html-latex-fragment) |
|
77 |
(line-break . org-html-line-break) |
|
78 |
(link . org-html-link) |
|
79 |
(node-property . org-html-node-property) |
|
80 |
(paragraph . org-html-paragraph) |
|
81 |
(plain-list . org-html-plain-list) |
|
82 |
(plain-text . org-html-plain-text) |
|
83 |
(planning . org-html-planning) |
|
84 |
(property-drawer . org-html-property-drawer) |
|
85 |
(quote-block . org-html-quote-block) |
|
86 |
(radio-target . org-html-radio-target) |
|
87 |
(section . org-html-section) |
|
88 |
(special-block . org-html-special-block) |
|
89 |
(src-block . org-html-src-block) |
|
90 |
(statistics-cookie . org-html-statistics-cookie) |
|
91 |
(strike-through . org-html-strike-through) |
|
92 |
(subscript . org-html-subscript) |
|
93 |
(superscript . org-html-superscript) |
|
94 |
(table . org-html-table) |
|
95 |
(table-cell . org-html-table-cell) |
|
96 |
(table-row . org-html-table-row) |
|
97 |
(target . org-html-target) |
|
98 |
(template . org-html-template) |
|
99 |
(timestamp . org-html-timestamp) |
|
100 |
(underline . org-html-underline) |
|
101 |
(verbatim . org-html-verbatim) |
|
102 |
(verse-block . org-html-verse-block)) |
|
103 |
:filters-alist '((:filter-options . org-html-infojs-install-script) |
|
104 |
(:filter-parse-tree . org-html-image-link-filter) |
|
105 |
(:filter-final-output . org-html-final-function)) |
|
106 |
:menu-entry |
|
107 |
'(?h "Export to HTML" |
|
108 |
((?H "As HTML buffer" org-html-export-as-html) |
|
109 |
(?h "As HTML file" org-html-export-to-html) |
|
110 |
(?o "As HTML file and open" |
|
111 |
(lambda (a s v b) |
|
112 |
(if a (org-html-export-to-html t s v b) |
|
113 |
(org-open-file (org-html-export-to-html nil s v b))))))) |
|
114 |
:options-alist |
|
115 |
'((:html-doctype "HTML_DOCTYPE" nil org-html-doctype) |
|
116 |
(:html-container "HTML_CONTAINER" nil org-html-container-element) |
|
117 |
(:description "DESCRIPTION" nil nil newline) |
|
118 |
(:keywords "KEYWORDS" nil nil space) |
|
119 |
(:html-html5-fancy nil "html5-fancy" org-html-html5-fancy) |
|
120 |
(:html-link-use-abs-url nil "html-link-use-abs-url" org-html-link-use-abs-url) |
|
121 |
(:html-link-home "HTML_LINK_HOME" nil org-html-link-home) |
|
122 |
(:html-link-up "HTML_LINK_UP" nil org-html-link-up) |
|
123 |
(:html-mathjax "HTML_MATHJAX" nil "" space) |
|
124 |
(:html-postamble nil "html-postamble" org-html-postamble) |
|
125 |
(:html-preamble nil "html-preamble" org-html-preamble) |
|
126 |
(:html-head "HTML_HEAD" nil org-html-head newline) |
|
127 |
(:html-head-extra "HTML_HEAD_EXTRA" nil org-html-head-extra newline) |
|
128 |
(:subtitle "SUBTITLE" nil nil parse) |
|
129 |
(:html-head-include-default-style |
|
130 |
nil "html-style" org-html-head-include-default-style) |
|
131 |
(:html-head-include-scripts nil "html-scripts" org-html-head-include-scripts) |
|
132 |
(:html-allow-name-attribute-in-anchors |
|
133 |
nil nil org-html-allow-name-attribute-in-anchors) |
|
134 |
(:html-divs nil nil org-html-divs) |
|
135 |
(:html-checkbox-type nil nil org-html-checkbox-type) |
|
136 |
(:html-extension nil nil org-html-extension) |
|
137 |
(:html-footnote-format nil nil org-html-footnote-format) |
|
138 |
(:html-footnote-separator nil nil org-html-footnote-separator) |
|
139 |
(:html-footnotes-section nil nil org-html-footnotes-section) |
|
140 |
(:html-format-drawer-function nil nil org-html-format-drawer-function) |
|
141 |
(:html-format-headline-function nil nil org-html-format-headline-function) |
|
142 |
(:html-format-inlinetask-function |
|
143 |
nil nil org-html-format-inlinetask-function) |
|
144 |
(:html-home/up-format nil nil org-html-home/up-format) |
|
145 |
(:html-indent nil nil org-html-indent) |
|
146 |
(:html-infojs-options nil nil org-html-infojs-options) |
|
147 |
(:html-infojs-template nil nil org-html-infojs-template) |
|
148 |
(:html-inline-image-rules nil nil org-html-inline-image-rules) |
|
149 |
(:html-link-org-files-as-html nil nil org-html-link-org-files-as-html) |
|
150 |
(:html-mathjax-options nil nil org-html-mathjax-options) |
|
151 |
(:html-mathjax-template nil nil org-html-mathjax-template) |
|
152 |
(:html-metadata-timestamp-format nil nil org-html-metadata-timestamp-format) |
|
153 |
(:html-postamble-format nil nil org-html-postamble-format) |
|
154 |
(:html-preamble-format nil nil org-html-preamble-format) |
|
155 |
(:html-table-align-individual-fields |
|
156 |
nil nil org-html-table-align-individual-fields) |
|
157 |
(:html-table-caption-above nil nil org-html-table-caption-above) |
|
158 |
(:html-table-data-tags nil nil org-html-table-data-tags) |
|
159 |
(:html-table-header-tags nil nil org-html-table-header-tags) |
|
160 |
(:html-table-use-header-tags-for-first-column |
|
161 |
nil nil org-html-table-use-header-tags-for-first-column) |
|
162 |
(:html-tag-class-prefix nil nil org-html-tag-class-prefix) |
|
163 |
(:html-text-markup-alist nil nil org-html-text-markup-alist) |
|
164 |
(:html-todo-kwd-class-prefix nil nil org-html-todo-kwd-class-prefix) |
|
165 |
(:html-toplevel-hlevel nil nil org-html-toplevel-hlevel) |
|
166 |
(:html-use-infojs nil nil org-html-use-infojs) |
|
167 |
(:html-validation-link nil nil org-html-validation-link) |
|
168 |
(:html-viewport nil nil org-html-viewport) |
|
169 |
(:html-inline-images nil nil org-html-inline-images) |
|
170 |
(:html-table-attributes nil nil org-html-table-default-attributes) |
|
171 |
(:html-table-row-open-tag nil nil org-html-table-row-open-tag) |
|
172 |
(:html-table-row-close-tag nil nil org-html-table-row-close-tag) |
|
173 |
(:html-xml-declaration nil nil org-html-xml-declaration) |
|
174 |
(:html-klipsify-src nil nil org-html-klipsify-src) |
|
175 |
(:html-klipse-css nil nil org-html-klipse-css) |
|
176 |
(:html-klipse-js nil nil org-html-klipse-js) |
|
177 |
(:html-klipse-selection-script nil nil org-html-klipse-selection-script) |
|
178 |
(:infojs-opt "INFOJS_OPT" nil nil) |
|
179 |
;; Redefine regular options. |
|
180 |
(:creator "CREATOR" nil org-html-creator-string) |
|
181 |
(:with-latex nil "tex" org-html-with-latex) |
|
182 |
;; Retrieve LaTeX header for fragments. |
|
183 |
(:latex-header "LATEX_HEADER" nil nil newline))) |
|
184 |
|
|
185 |
|
|
186 |
;;; Internal Variables |
|
187 |
|
|
188 |
(defvar org-html-format-table-no-css) |
|
189 |
(defvar htmlize-buffer-places) ; from htmlize.el |
|
190 |
|
|
191 |
(defvar org-html--pre/postamble-class "status" |
|
192 |
"CSS class used for pre/postamble") |
|
193 |
|
|
194 |
(defconst org-html-doctype-alist |
|
195 |
'(("html4-strict" . "<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01//EN\" |
|
196 |
\"http://www.w3.org/TR/html4/strict.dtd\">") |
|
197 |
("html4-transitional" . "<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" |
|
198 |
\"http://www.w3.org/TR/html4/loose.dtd\">") |
|
199 |
("html4-frameset" . "<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01 Frameset//EN\" |
|
200 |
\"http://www.w3.org/TR/html4/frameset.dtd\">") |
|
201 |
|
|
202 |
("xhtml-strict" . "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\" |
|
203 |
\"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">") |
|
204 |
("xhtml-transitional" . "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" |
|
205 |
\"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">") |
|
206 |
("xhtml-frameset" . "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Frameset//EN\" |
|
207 |
\"http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd\">") |
|
208 |
("xhtml-11" . "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.1//EN\" |
|
209 |
\"http://www.w3.org/TR/xhtml1/DTD/xhtml11.dtd\">") |
|
210 |
|
|
211 |
("html5" . "<!DOCTYPE html>") |
|
212 |
("xhtml5" . "<!DOCTYPE html>")) |
|
213 |
"An alist mapping (x)html flavors to specific doctypes.") |
|
214 |
|
|
215 |
(defconst org-html-html5-elements |
|
216 |
'("article" "aside" "audio" "canvas" "details" "figcaption" |
|
217 |
"figure" "footer" "header" "menu" "meter" "nav" "output" |
|
218 |
"progress" "section" "video") |
|
219 |
"New elements in html5. |
|
220 |
|
|
221 |
For blocks that should contain headlines, use the HTML_CONTAINER |
|
222 |
property on the headline itself.") |
|
223 |
|
|
224 |
(defconst org-html-special-string-regexps |
|
225 |
'(("\\\\-" . "­") ; shy |
|
226 |
("---\\([^-]\\)" . "—\\1") ; mdash |
|
227 |
("--\\([^-]\\)" . "–\\1") ; ndash |
|
228 |
("\\.\\.\\." . "…")) ; hellip |
|
229 |
"Regular expressions for special string conversion.") |
|
230 |
|
|
231 |
(defconst org-html-scripts |
|
232 |
"<script type=\"text/javascript\"> |
|
233 |
/* |
|
234 |
@licstart The following is the entire license notice for the |
|
235 |
JavaScript code in this tag. |
|
236 |
|
|
237 |
Copyright (C) 2012-2018 Free Software Foundation, Inc. |
|
238 |
|
|
239 |
The JavaScript code in this tag is free software: you can |
|
240 |
redistribute it and/or modify it under the terms of the GNU |
|
241 |
General Public License (GNU GPL) as published by the Free Software |
|
242 |
Foundation, either version 3 of the License, or (at your option) |
|
243 |
any later version. The code is distributed WITHOUT ANY WARRANTY; |
|
244 |
without even the implied warranty of MERCHANTABILITY or FITNESS |
|
245 |
FOR A PARTICULAR PURPOSE. See the GNU GPL for more details. |
|
246 |
|
|
247 |
As additional permission under GNU GPL version 3 section 7, you |
|
248 |
may distribute non-source (e.g., minimized or compacted) forms of |
|
249 |
that code without the copy of the GNU GPL normally required by |
|
250 |
section 4, provided you include this license notice and a URL |
|
251 |
through which recipients can access the Corresponding Source. |
|
252 |
|
|
253 |
|
|
254 |
@licend The above is the entire license notice |
|
255 |
for the JavaScript code in this tag. |
|
256 |
*/ |
|
257 |
<!--/*--><![CDATA[/*><!--*/ |
|
258 |
function CodeHighlightOn(elem, id) |
|
259 |
{ |
|
260 |
var target = document.getElementById(id); |
|
261 |
if(null != target) { |
|
262 |
elem.cacheClassElem = elem.className; |
|
263 |
elem.cacheClassTarget = target.className; |
|
264 |
target.className = \"code-highlighted\"; |
|
265 |
elem.className = \"code-highlighted\"; |
|
266 |
} |
|
267 |
} |
|
268 |
function CodeHighlightOff(elem, id) |
|
269 |
{ |
|
270 |
var target = document.getElementById(id); |
|
271 |
if(elem.cacheClassElem) |
|
272 |
elem.className = elem.cacheClassElem; |
|
273 |
if(elem.cacheClassTarget) |
|
274 |
target.className = elem.cacheClassTarget; |
|
275 |
} |
|
276 |
/*]]>*///--> |
|
277 |
</script>" |
|
278 |
"Basic JavaScript that is needed by HTML files produced by Org mode.") |
|
279 |
|
|
280 |
(defconst org-html-style-default |
|
281 |
"<style type=\"text/css\"> |
|
282 |
<!--/*--><![CDATA[/*><!--*/ |
|
283 |
.title { text-align: center; |
|
284 |
margin-bottom: .2em; } |
|
285 |
.subtitle { text-align: center; |
|
286 |
font-size: medium; |
|
287 |
font-weight: bold; |
|
288 |
margin-top:0; } |
|
289 |
.todo { font-family: monospace; color: red; } |
|
290 |
.done { font-family: monospace; color: green; } |
|
291 |
.priority { font-family: monospace; color: orange; } |
|
292 |
.tag { background-color: #eee; font-family: monospace; |
|
293 |
padding: 2px; font-size: 80%; font-weight: normal; } |
|
294 |
.timestamp { color: #bebebe; } |
|
295 |
.timestamp-kwd { color: #5f9ea0; } |
|
296 |
.org-right { margin-left: auto; margin-right: 0px; text-align: right; } |
|
297 |
.org-left { margin-left: 0px; margin-right: auto; text-align: left; } |
|
298 |
.org-center { margin-left: auto; margin-right: auto; text-align: center; } |
|
299 |
.underline { text-decoration: underline; } |
|
300 |
#postamble p, #preamble p { font-size: 90%; margin: .2em; } |
|
301 |
p.verse { margin-left: 3%; } |
|
302 |
pre { |
|
303 |
border: 1px solid #ccc; |
|
304 |
box-shadow: 3px 3px 3px #eee; |
|
305 |
padding: 8pt; |
|
306 |
font-family: monospace; |
|
307 |
overflow: auto; |
|
308 |
margin: 1.2em; |
|
309 |
} |
|
310 |
pre.src { |
|
311 |
position: relative; |
|
312 |
overflow: visible; |
|
313 |
padding-top: 1.2em; |
|
314 |
} |
|
315 |
pre.src:before { |
|
316 |
display: none; |
|
317 |
position: absolute; |
|
318 |
background-color: white; |
|
319 |
top: -10px; |
|
320 |
right: 10px; |
|
321 |
padding: 3px; |
|
322 |
border: 1px solid black; |
|
323 |
} |
|
324 |
pre.src:hover:before { display: inline;} |
|
325 |
/* Languages per Org manual */ |
|
326 |
pre.src-asymptote:before { content: 'Asymptote'; } |
|
327 |
pre.src-awk:before { content: 'Awk'; } |
|
328 |
pre.src-C:before { content: 'C'; } |
|
329 |
/* pre.src-C++ doesn't work in CSS */ |
|
330 |
pre.src-clojure:before { content: 'Clojure'; } |
|
331 |
pre.src-css:before { content: 'CSS'; } |
|
332 |
pre.src-D:before { content: 'D'; } |
|
333 |
pre.src-ditaa:before { content: 'ditaa'; } |
|
334 |
pre.src-dot:before { content: 'Graphviz'; } |
|
335 |
pre.src-calc:before { content: 'Emacs Calc'; } |
|
336 |
pre.src-emacs-lisp:before { content: 'Emacs Lisp'; } |
|
337 |
pre.src-fortran:before { content: 'Fortran'; } |
|
338 |
pre.src-gnuplot:before { content: 'gnuplot'; } |
|
339 |
pre.src-haskell:before { content: 'Haskell'; } |
|
340 |
pre.src-hledger:before { content: 'hledger'; } |
|
341 |
pre.src-java:before { content: 'Java'; } |
|
342 |
pre.src-js:before { content: 'Javascript'; } |
|
343 |
pre.src-latex:before { content: 'LaTeX'; } |
|
344 |
pre.src-ledger:before { content: 'Ledger'; } |
|
345 |
pre.src-lisp:before { content: 'Lisp'; } |
|
346 |
pre.src-lilypond:before { content: 'Lilypond'; } |
|
347 |
pre.src-lua:before { content: 'Lua'; } |
|
348 |
pre.src-matlab:before { content: 'MATLAB'; } |
|
349 |
pre.src-mscgen:before { content: 'Mscgen'; } |
|
350 |
pre.src-ocaml:before { content: 'Objective Caml'; } |
|
351 |
pre.src-octave:before { content: 'Octave'; } |
|
352 |
pre.src-org:before { content: 'Org mode'; } |
|
353 |
pre.src-oz:before { content: 'OZ'; } |
|
354 |
pre.src-plantuml:before { content: 'Plantuml'; } |
|
355 |
pre.src-processing:before { content: 'Processing.js'; } |
|
356 |
pre.src-python:before { content: 'Python'; } |
|
357 |
pre.src-R:before { content: 'R'; } |
|
358 |
pre.src-ruby:before { content: 'Ruby'; } |
|
359 |
pre.src-sass:before { content: 'Sass'; } |
|
360 |
pre.src-scheme:before { content: 'Scheme'; } |
|
361 |
pre.src-screen:before { content: 'Gnu Screen'; } |
|
362 |
pre.src-sed:before { content: 'Sed'; } |
|
363 |
pre.src-sh:before { content: 'shell'; } |
|
364 |
pre.src-sql:before { content: 'SQL'; } |
|
365 |
pre.src-sqlite:before { content: 'SQLite'; } |
|
366 |
/* additional languages in org.el's org-babel-load-languages alist */ |
|
367 |
pre.src-forth:before { content: 'Forth'; } |
|
368 |
pre.src-io:before { content: 'IO'; } |
|
369 |
pre.src-J:before { content: 'J'; } |
|
370 |
pre.src-makefile:before { content: 'Makefile'; } |
|
371 |
pre.src-maxima:before { content: 'Maxima'; } |
|
372 |
pre.src-perl:before { content: 'Perl'; } |
|
373 |
pre.src-picolisp:before { content: 'Pico Lisp'; } |
|
374 |
pre.src-scala:before { content: 'Scala'; } |
|
375 |
pre.src-shell:before { content: 'Shell Script'; } |
|
376 |
pre.src-ebnf2ps:before { content: 'ebfn2ps'; } |
|
377 |
/* additional language identifiers per \"defun org-babel-execute\" |
|
378 |
in ob-*.el */ |
|
379 |
pre.src-cpp:before { content: 'C++'; } |
|
380 |
pre.src-abc:before { content: 'ABC'; } |
|
381 |
pre.src-coq:before { content: 'Coq'; } |
|
382 |
pre.src-groovy:before { content: 'Groovy'; } |
|
383 |
/* additional language identifiers from org-babel-shell-names in |
|
384 |
ob-shell.el: ob-shell is the only babel language using a lambda to put |
|
385 |
the execution function name together. */ |
|
386 |
pre.src-bash:before { content: 'bash'; } |
|
387 |
pre.src-csh:before { content: 'csh'; } |
|
388 |
pre.src-ash:before { content: 'ash'; } |
|
389 |
pre.src-dash:before { content: 'dash'; } |
|
390 |
pre.src-ksh:before { content: 'ksh'; } |
|
391 |
pre.src-mksh:before { content: 'mksh'; } |
|
392 |
pre.src-posh:before { content: 'posh'; } |
|
393 |
/* Additional Emacs modes also supported by the LaTeX listings package */ |
|
394 |
pre.src-ada:before { content: 'Ada'; } |
|
395 |
pre.src-asm:before { content: 'Assembler'; } |
|
396 |
pre.src-caml:before { content: 'Caml'; } |
|
397 |
pre.src-delphi:before { content: 'Delphi'; } |
|
398 |
pre.src-html:before { content: 'HTML'; } |
|
399 |
pre.src-idl:before { content: 'IDL'; } |
|
400 |
pre.src-mercury:before { content: 'Mercury'; } |
|
401 |
pre.src-metapost:before { content: 'MetaPost'; } |
|
402 |
pre.src-modula-2:before { content: 'Modula-2'; } |
|
403 |
pre.src-pascal:before { content: 'Pascal'; } |
|
404 |
pre.src-ps:before { content: 'PostScript'; } |
|
405 |
pre.src-prolog:before { content: 'Prolog'; } |
|
406 |
pre.src-simula:before { content: 'Simula'; } |
|
407 |
pre.src-tcl:before { content: 'tcl'; } |
|
408 |
pre.src-tex:before { content: 'TeX'; } |
|
409 |
pre.src-plain-tex:before { content: 'Plain TeX'; } |
|
410 |
pre.src-verilog:before { content: 'Verilog'; } |
|
411 |
pre.src-vhdl:before { content: 'VHDL'; } |
|
412 |
pre.src-xml:before { content: 'XML'; } |
|
413 |
pre.src-nxml:before { content: 'XML'; } |
|
414 |
/* add a generic configuration mode; LaTeX export needs an additional |
|
415 |
(add-to-list 'org-latex-listings-langs '(conf \" \")) in .emacs */ |
|
416 |
pre.src-conf:before { content: 'Configuration File'; } |
|
417 |
|
|
418 |
table { border-collapse:collapse; } |
|
419 |
caption.t-above { caption-side: top; } |
|
420 |
caption.t-bottom { caption-side: bottom; } |
|
421 |
td, th { vertical-align:top; } |
|
422 |
th.org-right { text-align: center; } |
|
423 |
th.org-left { text-align: center; } |
|
424 |
th.org-center { text-align: center; } |
|
425 |
td.org-right { text-align: right; } |
|
426 |
td.org-left { text-align: left; } |
|
427 |
td.org-center { text-align: center; } |
|
428 |
dt { font-weight: bold; } |
|
429 |
.footpara { display: inline; } |
|
430 |
.footdef { margin-bottom: 1em; } |
|
431 |
.figure { padding: 1em; } |
|
432 |
.figure p { text-align: center; } |
|
433 |
.inlinetask { |
|
434 |
padding: 10px; |
|
435 |
border: 2px solid gray; |
|
436 |
margin: 10px; |
|
437 |
background: #ffffcc; |
|
438 |
} |
|
439 |
#org-div-home-and-up |
|
440 |
{ text-align: right; font-size: 70%; white-space: nowrap; } |
|
441 |
textarea { overflow-x: auto; } |
|
442 |
.linenr { font-size: smaller } |
|
443 |
.code-highlighted { background-color: #ffff00; } |
|
444 |
.org-info-js_info-navigation { border-style: none; } |
|
445 |
#org-info-js_console-label |
|
446 |
{ font-size: 10px; font-weight: bold; white-space: nowrap; } |
|
447 |
.org-info-js_search-highlight |
|
448 |
{ background-color: #ffff00; color: #000000; font-weight: bold; } |
|
449 |
.org-svg { width: 90%; } |
|
450 |
/*]]>*/--> |
|
451 |
</style>" |
|
452 |
"The default style specification for exported HTML files. |
|
453 |
You can use `org-html-head' and `org-html-head-extra' to add to |
|
454 |
this style. If you don't want to include this default style, |
|
455 |
customize `org-html-head-include-default-style'.") |
|
456 |
|
|
457 |
|
|
458 |
;;; User Configuration Variables |
|
459 |
|
|
460 |
(defgroup org-export-html nil |
|
461 |
"Options for exporting Org mode files to HTML." |
|
462 |
:tag "Org Export HTML" |
|
463 |
:group 'org-export) |
|
464 |
|
|
465 |
;;;; Handle infojs |
|
466 |
|
|
467 |
(defvar org-html-infojs-opts-table |
|
468 |
'((path PATH "https://orgmode.org/org-info.js") |
|
469 |
(view VIEW "info") |
|
470 |
(toc TOC :with-toc) |
|
471 |
(ftoc FIXED_TOC "0") |
|
472 |
(tdepth TOC_DEPTH "max") |
|
473 |
(sdepth SECTION_DEPTH "max") |
|
474 |
(mouse MOUSE_HINT "underline") |
|
475 |
(buttons VIEW_BUTTONS "0") |
|
476 |
(ltoc LOCAL_TOC "1") |
|
477 |
(up LINK_UP :html-link-up) |
|
478 |
(home LINK_HOME :html-link-home)) |
|
479 |
"JavaScript options, long form for script, default values.") |
|
480 |
|
|
481 |
(defcustom org-html-use-infojs 'when-configured |
|
482 |
"Non-nil when Sebastian Rose's Java Script org-info.js should be active. |
|
483 |
This option can be nil or t to never or always use the script. |
|
484 |
It can also be the symbol `when-configured', meaning that the |
|
485 |
script will be linked into the export file if and only if there |
|
486 |
is a \"#+INFOJS_OPT:\" line in the buffer. See also the variable |
|
487 |
`org-html-infojs-options'." |
|
488 |
:group 'org-export-html |
|
489 |
:version "24.4" |
|
490 |
:package-version '(Org . "8.0") |
|
491 |
:type '(choice |
|
492 |
(const :tag "Never" nil) |
|
493 |
(const :tag "When configured in buffer" when-configured) |
|
494 |
(const :tag "Always" t))) |
|
495 |
|
|
496 |
(defcustom org-html-infojs-options |
|
497 |
(mapcar (lambda (x) (cons (car x) (nth 2 x))) org-html-infojs-opts-table) |
|
498 |
"Options settings for the INFOJS JavaScript. |
|
499 |
Each of the options must have an entry in `org-html-infojs-opts-table'. |
|
500 |
The value can either be a string that will be passed to the script, or |
|
501 |
a property. This property is then assumed to be a property that is defined |
|
502 |
by the Export/Publishing setup of Org. |
|
503 |
The `sdepth' and `tdepth' parameters can also be set to \"max\", which |
|
504 |
means to use the maximum value consistent with other options." |
|
505 |
:group 'org-export-html |
|
506 |
:version "24.4" |
|
507 |
:package-version '(Org . "8.0") |
|
508 |
:type |
|
509 |
`(set :greedy t :inline t |
|
510 |
,@(mapcar |
|
511 |
(lambda (x) |
|
512 |
(list 'cons (list 'const (car x)) |
|
513 |
'(choice |
|
514 |
(symbol :tag "Publishing/Export property") |
|
515 |
(string :tag "Value")))) |
|
516 |
org-html-infojs-opts-table))) |
|
517 |
|
|
518 |
(defcustom org-html-infojs-template |
|
519 |
"<script type=\"text/javascript\" src=\"%SCRIPT_PATH\"> |
|
520 |
/** |
|
521 |
* |
|
522 |
* @source: %SCRIPT_PATH |
|
523 |
* |
|
524 |
* @licstart The following is the entire license notice for the |
|
525 |
* JavaScript code in %SCRIPT_PATH. |
|
526 |
* |
|
527 |
* Copyright (C) 2012-2018 Free Software Foundation, Inc. |
|
528 |
* |
|
529 |
* |
|
530 |
* The JavaScript code in this tag is free software: you can |
|
531 |
* redistribute it and/or modify it under the terms of the GNU |
|
532 |
* General Public License (GNU GPL) as published by the Free Software |
|
533 |
* Foundation, either version 3 of the License, or (at your option) |
|
534 |
* any later version. The code is distributed WITHOUT ANY WARRANTY; |
|
535 |
* without even the implied warranty of MERCHANTABILITY or FITNESS |
|
536 |
* FOR A PARTICULAR PURPOSE. See the GNU GPL for more details. |
|
537 |
* |
|
538 |
* As additional permission under GNU GPL version 3 section 7, you |
|
539 |
* may distribute non-source (e.g., minimized or compacted) forms of |
|
540 |
* that code without the copy of the GNU GPL normally required by |
|
541 |
* section 4, provided you include this license notice and a URL |
|
542 |
* through which recipients can access the Corresponding Source. |
|
543 |
* |
|
544 |
* @licend The above is the entire license notice |
|
545 |
* for the JavaScript code in %SCRIPT_PATH. |
|
546 |
* |
|
547 |
*/ |
|
548 |
</script> |
|
549 |
|
|
550 |
<script type=\"text/javascript\"> |
|
551 |
|
|
552 |
/* |
|
553 |
@licstart The following is the entire license notice for the |
|
554 |
JavaScript code in this tag. |
|
555 |
|
|
556 |
Copyright (C) 2012-2018 Free Software Foundation, Inc. |
|
557 |
|
|
558 |
The JavaScript code in this tag is free software: you can |
|
559 |
redistribute it and/or modify it under the terms of the GNU |
|
560 |
General Public License (GNU GPL) as published by the Free Software |
|
561 |
Foundation, either version 3 of the License, or (at your option) |
|
562 |
any later version. The code is distributed WITHOUT ANY WARRANTY; |
|
563 |
without even the implied warranty of MERCHANTABILITY or FITNESS |
|
564 |
FOR A PARTICULAR PURPOSE. See the GNU GPL for more details. |
|
565 |
|
|
566 |
As additional permission under GNU GPL version 3 section 7, you |
|
567 |
may distribute non-source (e.g., minimized or compacted) forms of |
|
568 |
that code without the copy of the GNU GPL normally required by |
|
569 |
section 4, provided you include this license notice and a URL |
|
570 |
through which recipients can access the Corresponding Source. |
|
571 |
|
|
572 |
|
|
573 |
@licend The above is the entire license notice |
|
574 |
for the JavaScript code in this tag. |
|
575 |
*/ |
|
576 |
|
|
577 |
<!--/*--><![CDATA[/*><!--*/ |
|
578 |
%MANAGER_OPTIONS |
|
579 |
org_html_manager.setup(); // activate after the parameters are set |
|
580 |
/*]]>*///--> |
|
581 |
</script>" |
|
582 |
"The template for the export style additions when org-info.js is used. |
|
583 |
Option settings will replace the %MANAGER-OPTIONS cookie." |
|
584 |
:group 'org-export-html |
|
585 |
:version "24.4" |
|
586 |
:package-version '(Org . "8.0") |
|
587 |
:type 'string) |
|
588 |
|
|
589 |
(defun org-html-infojs-install-script (exp-plist _backend) |
|
590 |
"Install script in export options when appropriate. |
|
591 |
EXP-PLIST is a plist containing export options. BACKEND is the |
|
592 |
export back-end currently used." |
|
593 |
(unless (or (memq 'body-only (plist-get exp-plist :export-options)) |
|
594 |
(not (plist-get exp-plist :html-use-infojs)) |
|
595 |
(and (eq (plist-get exp-plist :html-use-infojs) 'when-configured) |
|
596 |
(let ((opt (plist-get exp-plist :infojs-opt))) |
|
597 |
(or (not opt) |
|
598 |
(string= "" opt) |
|
599 |
(string-match "\\<view:nil\\>" opt))))) |
|
600 |
(let* ((template (plist-get exp-plist :html-infojs-template)) |
|
601 |
(ptoc (plist-get exp-plist :with-toc)) |
|
602 |
(hlevels (plist-get exp-plist :headline-levels)) |
|
603 |
(sdepth hlevels) |
|
604 |
(tdepth (if (integerp ptoc) (min ptoc hlevels) hlevels)) |
|
605 |
(options (plist-get exp-plist :infojs-opt)) |
|
606 |
(infojs-opt (plist-get exp-plist :html-infojs-options)) |
|
607 |
(table org-html-infojs-opts-table) |
|
608 |
style) |
|
609 |
(dolist (entry table) |
|
610 |
(let* ((opt (car entry)) |
|
611 |
(var (nth 1 entry)) |
|
612 |
;; Compute default values for script option OPT from |
|
613 |
;; `org-html-infojs-options' variable. |
|
614 |
(default |
|
615 |
(let ((default (cdr (assq opt infojs-opt)))) |
|
616 |
(if (and (symbolp default) (not (memq default '(t nil)))) |
|
617 |
(plist-get exp-plist default) |
|
618 |
default))) |
|
619 |
;; Value set through INFOJS_OPT keyword has precedence |
|
620 |
;; over the default one. |
|
621 |
(val (if (and options |
|
622 |
(string-match (format "\\<%s:\\(\\S-+\\)" opt) |
|
623 |
options)) |
|
624 |
(match-string 1 options) |
|
625 |
default))) |
|
626 |
(pcase opt |
|
627 |
(`path (setq template |
|
628 |
(replace-regexp-in-string |
|
629 |
"%SCRIPT_PATH" val template t t))) |
|
630 |
(`sdepth (when (integerp (read val)) |
|
631 |
(setq sdepth (min (read val) sdepth)))) |
|
632 |
(`tdepth (when (integerp (read val)) |
|
633 |
(setq tdepth (min (read val) tdepth)))) |
|
634 |
(_ (setq val |
|
635 |
(cond |
|
636 |
((or (eq val t) (equal val "t")) "1") |
|
637 |
((or (eq val nil) (equal val "nil")) "0") |
|
638 |
((stringp val) val) |
|
639 |
(t (format "%s" val)))) |
|
640 |
(push (cons var val) style))))) |
|
641 |
;; Now we set the depth of the *generated* TOC to SDEPTH, |
|
642 |
;; because the toc will actually determine the splitting. How |
|
643 |
;; much of the toc will actually be displayed is governed by the |
|
644 |
;; TDEPTH option. |
|
645 |
(setq exp-plist (plist-put exp-plist :with-toc sdepth)) |
|
646 |
;; The table of contents should not show more sections than we |
|
647 |
;; generate. |
|
648 |
(setq tdepth (min tdepth sdepth)) |
|
649 |
(push (cons "TOC_DEPTH" tdepth) style) |
|
650 |
;; Build style string. |
|
651 |
(setq style (mapconcat |
|
652 |
(lambda (x) |
|
653 |
(format "org_html_manager.set(\"%s\", \"%s\");" |
|
654 |
(car x) (cdr x))) |
|
655 |
style "\n")) |
|
656 |
(when (and style (> (length style) 0)) |
|
657 |
(and (string-match "%MANAGER_OPTIONS" template) |
|
658 |
(setq style (replace-match style t t template)) |
|
659 |
(setq exp-plist |
|
660 |
(plist-put |
|
661 |
exp-plist :html-head-extra |
|
662 |
(concat (or (plist-get exp-plist :html-head-extra) "") |
|
663 |
"\n" |
|
664 |
style))))) |
|
665 |
;; This script absolutely needs the table of contents, so we |
|
666 |
;; change that setting. |
|
667 |
(unless (plist-get exp-plist :with-toc) |
|
668 |
(setq exp-plist (plist-put exp-plist :with-toc t))) |
|
669 |
;; Return the modified property list. |
|
670 |
exp-plist))) |
|
671 |
|
|
672 |
;;;; Bold, etc. |
|
673 |
|
|
674 |
(defcustom org-html-text-markup-alist |
|
675 |
'((bold . "<b>%s</b>") |
|
676 |
(code . "<code>%s</code>") |
|
677 |
(italic . "<i>%s</i>") |
|
678 |
(strike-through . "<del>%s</del>") |
|
679 |
(underline . "<span class=\"underline\">%s</span>") |
|
680 |
(verbatim . "<code>%s</code>")) |
|
681 |
"Alist of HTML expressions to convert text markup. |
|
682 |
|
|
683 |
The key must be a symbol among `bold', `code', `italic', |
|
684 |
`strike-through', `underline' and `verbatim'. The value is |
|
685 |
a formatting string to wrap fontified text with. |
|
686 |
|
|
687 |
If no association can be found for a given markup, text will be |
|
688 |
returned as-is." |
|
689 |
:group 'org-export-html |
|
690 |
:version "24.4" |
|
691 |
:package-version '(Org . "8.0") |
|
692 |
:type '(alist :key-type (symbol :tag "Markup type") |
|
693 |
:value-type (string :tag "Format string")) |
|
694 |
:options '(bold code italic strike-through underline verbatim)) |
|
695 |
|
|
696 |
(defcustom org-html-indent nil |
|
697 |
"Non-nil means to indent the generated HTML. |
|
698 |
Warning: non-nil may break indentation of source code blocks." |
|
699 |
:group 'org-export-html |
|
700 |
:version "24.4" |
|
701 |
:package-version '(Org . "8.0") |
|
702 |
:type 'boolean) |
|
703 |
|
|
704 |
;;;; Drawers |
|
705 |
|
|
706 |
(defcustom org-html-format-drawer-function (lambda (_name contents) contents) |
|
707 |
"Function called to format a drawer in HTML code. |
|
708 |
|
|
709 |
The function must accept two parameters: |
|
710 |
NAME the drawer name, like \"LOGBOOK\" |
|
711 |
CONTENTS the contents of the drawer. |
|
712 |
|
|
713 |
The function should return the string to be exported. |
|
714 |
|
|
715 |
For example, the variable could be set to the following function |
|
716 |
in order to mimic default behavior: |
|
717 |
|
|
718 |
The default value simply returns the value of CONTENTS." |
|
719 |
:group 'org-export-html |
|
720 |
:version "24.4" |
|
721 |
:package-version '(Org . "8.0") |
|
722 |
:type 'function) |
|
723 |
|
|
724 |
;;;; Footnotes |
|
725 |
|
|
726 |
(defcustom org-html-footnotes-section "<div id=\"footnotes\"> |
|
727 |
<h2 class=\"footnotes\">%s: </h2> |
|
728 |
<div id=\"text-footnotes\"> |
|
729 |
%s |
|
730 |
</div> |
|
731 |
</div>" |
|
732 |
"Format for the footnotes section. |
|
733 |
Should contain a two instances of %s. The first will be replaced with the |
|
734 |
language-specific word for \"Footnotes\", the second one will be replaced |
|
735 |
by the footnotes themselves." |
|
736 |
:group 'org-export-html |
|
737 |
:type 'string) |
|
738 |
|
|
739 |
(defcustom org-html-footnote-format "<sup>%s</sup>" |
|
740 |
"The format for the footnote reference. |
|
741 |
%s will be replaced by the footnote reference itself." |
|
742 |
:group 'org-export-html |
|
743 |
:type 'string) |
|
744 |
|
|
745 |
(defcustom org-html-footnote-separator "<sup>, </sup>" |
|
746 |
"Text used to separate footnotes." |
|
747 |
:group 'org-export-html |
|
748 |
:type 'string) |
|
749 |
|
|
750 |
;;;; Headline |
|
751 |
|
|
752 |
(defcustom org-html-toplevel-hlevel 2 |
|
753 |
"The <H> level for level 1 headings in HTML export. |
|
754 |
This is also important for the classes that will be wrapped around headlines |
|
755 |
and outline structure. If this variable is 1, the top-level headlines will |
|
756 |
be <h1>, and the corresponding classes will be outline-1, section-number-1, |
|
757 |
and outline-text-1. If this is 2, all of these will get a 2 instead. |
|
758 |
The default for this variable is 2, because we use <h1> for formatting the |
|
759 |
document title." |
|
760 |
:group 'org-export-html |
|
761 |
:type 'integer) |
|
762 |
|
|
763 |
(defcustom org-html-format-headline-function |
|
764 |
'org-html-format-headline-default-function |
|
765 |
"Function to format headline text. |
|
766 |
|
|
767 |
This function will be called with six arguments: |
|
768 |
TODO the todo keyword (string or nil). |
|
769 |
TODO-TYPE the type of todo (symbol: `todo', `done', nil) |
|
770 |
PRIORITY the priority of the headline (integer or nil) |
|
771 |
TEXT the main headline text (string). |
|
772 |
TAGS the tags (string or nil). |
|
773 |
INFO the export options (plist). |
|
774 |
|
|
775 |
The function result will be used in the section format string." |
|
776 |
:group 'org-export-html |
|
777 |
:version "26.1" |
|
778 |
:package-version '(Org . "8.3") |
|
779 |
:type 'function) |
|
780 |
|
|
781 |
;;;; HTML-specific |
|
782 |
|
|
783 |
(defcustom org-html-allow-name-attribute-in-anchors nil |
|
784 |
"When nil, do not set \"name\" attribute in anchors. |
|
785 |
By default, when appropriate, anchors are formatted with \"id\" |
|
786 |
but without \"name\" attribute." |
|
787 |
:group 'org-export-html |
|
788 |
:version "24.4" |
|
789 |
:package-version '(Org . "8.0") |
|
790 |
:type 'boolean) |
|
791 |
|
|
792 |
;;;; Inlinetasks |
|
793 |
|
|
794 |
(defcustom org-html-format-inlinetask-function |
|
795 |
'org-html-format-inlinetask-default-function |
|
796 |
"Function called to format an inlinetask in HTML code. |
|
797 |
|
|
798 |
The function must accept seven parameters: |
|
799 |
TODO the todo keyword, as a string |
|
800 |
TODO-TYPE the todo type, a symbol among `todo', `done' and nil. |
|
801 |
PRIORITY the inlinetask priority, as a string |
|
802 |
NAME the inlinetask name, as a string. |
|
803 |
TAGS the inlinetask tags, as a list of strings. |
|
804 |
CONTENTS the contents of the inlinetask, as a string. |
|
805 |
INFO the export options, as a plist |
|
806 |
|
|
807 |
The function should return the string to be exported." |
|
808 |
:group 'org-export-html |
|
809 |
:version "26.1" |
|
810 |
:package-version '(Org . "8.3") |
|
811 |
:type 'function) |
|
812 |
|
|
813 |
;;;; LaTeX |
|
814 |
|
|
815 |
(defcustom org-html-with-latex org-export-with-latex |
|
816 |
"Non-nil means process LaTeX math snippets. |
|
817 |
|
|
818 |
When set, the exporter will process LaTeX environments and |
|
819 |
fragments. |
|
820 |
|
|
821 |
This option can also be set with the +OPTIONS line, |
|
822 |
e.g. \"tex:mathjax\". Allowed values are: |
|
823 |
|
|
824 |
nil Ignore math snippets. |
|
825 |
`verbatim' Keep everything in verbatim |
|
826 |
`mathjax', t Do MathJax preprocessing and arrange for MathJax.js to |
|
827 |
be loaded. |
|
828 |
SYMBOL Any symbol defined in `org-preview-latex-process-alist', |
|
829 |
e.g., `dvipng'." |
|
830 |
:group 'org-export-html |
|
831 |
:version "24.4" |
|
832 |
:package-version '(Org . "8.0") |
|
833 |
:type '(choice |
|
834 |
(const :tag "Do not process math in any way" nil) |
|
835 |
(const :tag "Leave math verbatim" verbatim) |
|
836 |
(const :tag "Use MathJax to display math" mathjax) |
|
837 |
(symbol :tag "Convert to image to display math" :value dvipng))) |
|
838 |
|
|
839 |
;;;; Links :: Generic |
|
840 |
|
|
841 |
(defcustom org-html-link-org-files-as-html t |
|
842 |
"Non-nil means make file links to `file.org' point to `file.html'. |
|
843 |
When `org-mode' is exporting an `org-mode' file to HTML, links to |
|
844 |
non-html files are directly put into a href tag in HTML. |
|
845 |
However, links to other Org files (recognized by the extension |
|
846 |
\".org\") should become links to the corresponding HTML |
|
847 |
file, assuming that the linked `org-mode' file will also be |
|
848 |
converted to HTML. |
|
849 |
When nil, the links still point to the plain \".org\" file." |
|
850 |
:group 'org-export-html |
|
851 |
:type 'boolean) |
|
852 |
|
|
853 |
;;;; Links :: Inline images |
|
854 |
|
|
855 |
(defcustom org-html-inline-images t |
|
856 |
"Non-nil means inline images into exported HTML pages. |
|
857 |
This is done using an <img> tag. When nil, an anchor with href is used to |
|
858 |
link to the image." |
|
859 |
:group 'org-export-html |
|
860 |
:version "24.4" |
|
861 |
:package-version '(Org . "8.1") |
|
862 |
:type 'boolean) |
|
863 |
|
|
864 |
(defcustom org-html-inline-image-rules |
|
865 |
'(("file" . "\\.\\(jpeg\\|jpg\\|png\\|gif\\|svg\\)\\'") |
|
866 |
("http" . "\\.\\(jpeg\\|jpg\\|png\\|gif\\|svg\\)\\'") |
|
867 |
("https" . "\\.\\(jpeg\\|jpg\\|png\\|gif\\|svg\\)\\'")) |
|
868 |
"Rules characterizing image files that can be inlined into HTML. |
|
869 |
A rule consists in an association whose key is the type of link |
|
870 |
to consider, and value is a regexp that will be matched against |
|
871 |
link's path." |
|
872 |
:group 'org-export-html |
|
873 |
:version "24.4" |
|
874 |
:package-version '(Org . "8.0") |
|
875 |
:type '(alist :key-type (string :tag "Type") |
|
876 |
:value-type (regexp :tag "Path"))) |
|
877 |
|
|
878 |
;;;; Plain Text |
|
879 |
|
|
880 |
(defvar org-html-protect-char-alist |
|
881 |
'(("&" . "&") |
|
882 |
("<" . "<") |
|
883 |
(">" . ">")) |
|
884 |
"Alist of characters to be converted by `org-html-encode-plain-text'.") |
|
885 |
|
|
886 |
;;;; Src Block |
|
887 |
|
|
888 |
(defcustom org-html-htmlize-output-type 'inline-css |
|
889 |
"Output type to be used by htmlize when formatting code snippets. |
|
890 |
Choices are `css' to export the CSS selectors only,`inline-css' |
|
891 |
to export the CSS attribute values inline in the HTML or `nil' to |
|
892 |
export plain text. We use as default `inline-css', in order to |
|
893 |
make the resulting HTML self-containing. |
|
894 |
|
|
895 |
However, this will fail when using Emacs in batch mode for export, because |
|
896 |
then no rich font definitions are in place. It will also not be good if |
|
897 |
people with different Emacs setup contribute HTML files to a website, |
|
898 |
because the fonts will represent the individual setups. In these cases, |
|
899 |
it is much better to let Org/Htmlize assign classes only, and to use |
|
900 |
a style file to define the look of these classes. |
|
901 |
To get a start for your css file, start Emacs session and make sure that |
|
902 |
all the faces you are interested in are defined, for example by loading files |
|
903 |
in all modes you want. Then, use the command |
|
904 |
`\\[org-html-htmlize-generate-css]' to extract class definitions." |
|
905 |
:group 'org-export-html |
|
906 |
:type '(choice (const css) (const inline-css) (const nil))) |
|
907 |
|
|
908 |
(defcustom org-html-htmlize-font-prefix "org-" |
|
909 |
"The prefix for CSS class names for htmlize font specifications." |
|
910 |
:group 'org-export-html |
|
911 |
:type 'string) |
|
912 |
|
|
913 |
;;;; Table |
|
914 |
|
|
915 |
(defcustom org-html-table-default-attributes |
|
916 |
'(:border "2" :cellspacing "0" :cellpadding "6" :rules "groups" :frame "hsides") |
|
917 |
"Default attributes and values which will be used in table tags. |
|
918 |
This is a plist where attributes are symbols, starting with |
|
919 |
colons, and values are strings. |
|
920 |
|
|
921 |
When exporting to HTML5, these values will be disregarded." |
|
922 |
:group 'org-export-html |
|
923 |
:version "24.4" |
|
924 |
:package-version '(Org . "8.0") |
|
925 |
:type '(plist :key-type (symbol :tag "Property") |
|
926 |
:value-type (string :tag "Value"))) |
|
927 |
|
|
928 |
(defcustom org-html-table-header-tags '("<th scope=\"%s\"%s>" . "</th>") |
|
929 |
"The opening and ending tags for table header fields. |
|
930 |
This is customizable so that alignment options can be specified. |
|
931 |
The first %s will be filled with the scope of the field, either row or col. |
|
932 |
The second %s will be replaced by a style entry to align the field. |
|
933 |
See also the variable `org-html-table-use-header-tags-for-first-column'. |
|
934 |
See also the variable `org-html-table-align-individual-fields'." |
|
935 |
:group 'org-export-html |
|
936 |
:type '(cons (string :tag "Opening tag") (string :tag "Closing tag"))) |
|
937 |
|
|
938 |
(defcustom org-html-table-data-tags '("<td%s>" . "</td>") |
|
939 |
"The opening and ending tags for table data fields. |
|
940 |
This is customizable so that alignment options can be specified. |
|
941 |
The first %s will be filled with the scope of the field, either row or col. |
|
942 |
The second %s will be replaced by a style entry to align the field. |
|
943 |
See also the variable `org-html-table-align-individual-fields'." |
|
944 |
:group 'org-export-html |
|
945 |
:type '(cons (string :tag "Opening tag") (string :tag "Closing tag"))) |
|
946 |
|
|
947 |
(defcustom org-html-table-row-open-tag "<tr>" |
|
948 |
"The opening tag for table rows. |
|
949 |
This is customizable so that alignment options can be specified. |
|
950 |
Instead of strings, these can be a Lisp function that will be |
|
951 |
evaluated for each row in order to construct the table row tags. |
|
952 |
|
|
953 |
The function will be called with these arguments: |
|
954 |
|
|
955 |
`number': row number (0 is the first row) |
|
956 |
`group-number': group number of current row |
|
957 |
`start-group?': non-nil means the row starts a group |
|
958 |
`end-group?': non-nil means the row ends a group |
|
959 |
`top?': non-nil means this is the top row |
|
960 |
`bottom?': non-nil means this is the bottom row |
|
961 |
|
|
962 |
For example: |
|
963 |
|
|
964 |
(setq org-html-table-row-open-tag |
|
965 |
(lambda (number group-number start-group? end-group-p top? bottom?) |
|
966 |
(cond (top? \"<tr class=\\\"tr-top\\\">\") |
|
967 |
(bottom? \"<tr class=\\\"tr-bottom\\\">\") |
|
968 |
(t (if (= (mod number 2) 1) |
|
969 |
\"<tr class=\\\"tr-odd\\\">\" |
|
970 |
\"<tr class=\\\"tr-even\\\">\"))))) |
|
971 |
|
|
972 |
will use the \"tr-top\" and \"tr-bottom\" classes for the top row |
|
973 |
and the bottom row, and otherwise alternate between \"tr-odd\" and |
|
974 |
\"tr-even\" for odd and even rows." |
|
975 |
:group 'org-export-html |
|
976 |
:type '(choice :tag "Opening tag" |
|
977 |
(string :tag "Specify") |
|
978 |
(function))) |
|
979 |
|
|
980 |
(defcustom org-html-table-row-close-tag "</tr>" |
|
981 |
"The closing tag for table rows. |
|
982 |
This is customizable so that alignment options can be specified. |
|
983 |
Instead of strings, this can be a Lisp function that will be |
|
984 |
evaluated for each row in order to construct the table row tags. |
|
985 |
|
|
986 |
See documentation of `org-html-table-row-open-tag'." |
|
987 |
:group 'org-export-html |
|
988 |
:type '(choice :tag "Closing tag" |
|
989 |
(string :tag "Specify") |
|
990 |
(function))) |
|
991 |
|
|
992 |
(defcustom org-html-table-align-individual-fields t |
|
993 |
"Non-nil means attach style attributes for alignment to each table field. |
|
994 |
When nil, alignment will only be specified in the column tags, but this |
|
995 |
is ignored by some browsers (like Firefox, Safari). Opera does it right |
|
996 |
though." |
|
997 |
:group 'org-export-html |
|
998 |
:type 'boolean) |
|
999 |
|
|
1000 |
(defcustom org-html-table-use-header-tags-for-first-column nil |
|
1001 |
"Non-nil means format column one in tables with header tags. |
|
1002 |
When nil, also column one will use data tags." |
|
1003 |
:group 'org-export-html |
|
1004 |
:type 'boolean) |
|
1005 |
|
|
1006 |
(defcustom org-html-table-caption-above t |
|
1007 |
"When non-nil, place caption string at the beginning of the table. |
|
1008 |
Otherwise, place it near the end." |
|
1009 |
:group 'org-export-html |
|
1010 |
:type 'boolean) |
|
1011 |
|
|
1012 |
;;;; Tags |
|
1013 |
|
|
1014 |
(defcustom org-html-tag-class-prefix "" |
|
1015 |
"Prefix to class names for TODO keywords. |
|
1016 |
Each tag gets a class given by the tag itself, with this prefix. |
|
1017 |
The default prefix is empty because it is nice to just use the keyword |
|
1018 |
as a class name. But if you get into conflicts with other, existing |
|
1019 |
CSS classes, then this prefix can be very useful." |
|
1020 |
:group 'org-export-html |
|
1021 |
:type 'string) |
|
1022 |
|
|
1023 |
;;;; Template :: Generic |
|
1024 |
|
|
1025 |
(defcustom org-html-extension "html" |
|
1026 |
"The extension for exported HTML files." |
|
1027 |
:group 'org-export-html |
|
1028 |
:type 'string) |
|
1029 |
|
|
1030 |
(defcustom org-html-xml-declaration |
|
1031 |
'(("html" . "<?xml version=\"1.0\" encoding=\"%s\"?>") |
|
1032 |
("php" . "<?php echo \"<?xml version=\\\"1.0\\\" encoding=\\\"%s\\\" ?>\"; ?>")) |
|
1033 |
"The extension for exported HTML files. |
|
1034 |
%s will be replaced with the charset of the exported file. |
|
1035 |
This may be a string, or an alist with export extensions |
|
1036 |
and corresponding declarations. |
|
1037 |
|
|
1038 |
This declaration only applies when exporting to XHTML." |
|
1039 |
:group 'org-export-html |
|
1040 |
:type '(choice |
|
1041 |
(string :tag "Single declaration") |
|
1042 |
(repeat :tag "Dependent on extension" |
|
1043 |
(cons (string :tag "Extension") |
|
1044 |
(string :tag "Declaration"))))) |
|
1045 |
|
|
1046 |
(defcustom org-html-coding-system 'utf-8 |
|
1047 |
"Coding system for HTML export. |
|
1048 |
Use utf-8 as the default value." |
|
1049 |
:group 'org-export-html |
|
1050 |
:version "24.4" |
|
1051 |
:package-version '(Org . "8.0") |
|
1052 |
:type 'coding-system) |
|
1053 |
|
|
1054 |
(defcustom org-html-doctype "xhtml-strict" |
|
1055 |
"Document type definition to use for exported HTML files. |
|
1056 |
Can be set with the in-buffer HTML_DOCTYPE property or for |
|
1057 |
publishing, with :html-doctype." |
|
1058 |
:group 'org-export-html |
|
1059 |
:version "24.4" |
|
1060 |
:package-version '(Org . "8.0") |
|
1061 |
:type (append |
|
1062 |
'(choice) |
|
1063 |
(mapcar (lambda (x) `(const ,(car x))) org-html-doctype-alist) |
|
1064 |
'((string :tag "Custom doctype" )))) |
|
1065 |
|
|
1066 |
(defcustom org-html-html5-fancy nil |
|
1067 |
"Non-nil means using new HTML5 elements. |
|
1068 |
This variable is ignored for anything other than HTML5 export. |
|
1069 |
|
|
1070 |
For compatibility with Internet Explorer, it's probably a good |
|
1071 |
idea to download some form of the html5shiv (for instance |
|
1072 |
https://code.google.com/p/html5shiv/) and add it to your |
|
1073 |
HTML_HEAD_EXTRA, so that your pages don't break for users of IE |
|
1074 |
versions 8 and below." |
|
1075 |
:group 'org-export-html |
|
1076 |
:version "24.4" |
|
1077 |
:package-version '(Org . "8.0") |
|
1078 |
:type 'boolean) |
|
1079 |
|
|
1080 |
(defcustom org-html-container-element "div" |
|
1081 |
"HTML element to use for wrapping top level sections. |
|
1082 |
Can be set with the in-buffer HTML_CONTAINER property or for |
|
1083 |
publishing, with :html-container. |
|
1084 |
|
|
1085 |
Note that changing the default will prevent you from using |
|
1086 |
org-info.js for your website." |
|
1087 |
:group 'org-export-html |
|
1088 |
:version "24.4" |
|
1089 |
:package-version '(Org . "8.0") |
|
1090 |
:type 'string) |
|
1091 |
|
|
1092 |
(defcustom org-html-divs |
|
1093 |
'((preamble "div" "preamble") |
|
1094 |
(content "div" "content") |
|
1095 |
(postamble "div" "postamble")) |
|
1096 |
"Alist of the three section elements for HTML export. |
|
1097 |
The car of each entry is one of `preamble', `content' or `postamble'. |
|
1098 |
The cdrs of each entry are the ELEMENT_TYPE and ID for each |
|
1099 |
section of the exported document. |
|
1100 |
|
|
1101 |
Note that changing the default will prevent you from using |
|
1102 |
org-info.js for your website." |
|
1103 |
:group 'org-export-html |
|
1104 |
:version "24.4" |
|
1105 |
:package-version '(Org . "8.0") |
|
1106 |
:type '(list :greedy t |
|
1107 |
(list :tag "Preamble" |
|
1108 |
(const :format "" preamble) |
|
1109 |
(string :tag "element") (string :tag " id")) |
|
1110 |
(list :tag "Content" |
|
1111 |
(const :format "" content) |
|
1112 |
(string :tag "element") (string :tag " id")) |
|
1113 |
(list :tag "Postamble" (const :format "" postamble) |
|
1114 |
(string :tag " id") (string :tag "element")))) |
|
1115 |
|
|
1116 |
(defconst org-html-checkbox-types |
|
1117 |
'((unicode . |
|
1118 |
((on . "☑") (off . "☐") (trans . "☐"))) |
|
1119 |
(ascii . |
|
1120 |
((on . "<code>[X]</code>") |
|
1121 |
(off . "<code>[ ]</code>") |
|
1122 |
(trans . "<code>[-]</code>"))) |
|
1123 |
(html . |
|
1124 |
((on . "<input type='checkbox' checked='checked' />") |
|
1125 |
(off . "<input type='checkbox' />") |
|
1126 |
(trans . "<input type='checkbox' />")))) |
|
1127 |
"Alist of checkbox types. |
|
1128 |
The cdr of each entry is an alist list three checkbox types for |
|
1129 |
HTML export: `on', `off' and `trans'. |
|
1130 |
|
|
1131 |
The choices are: |
|
1132 |
`unicode' Unicode characters (HTML entities) |
|
1133 |
`ascii' ASCII characters |
|
1134 |
`html' HTML checkboxes |
|
1135 |
|
|
1136 |
Note that only the ascii characters implement tri-state |
|
1137 |
checkboxes. The other two use the `off' checkbox for `trans'.") |
|
1138 |
|
|
1139 |
(defcustom org-html-checkbox-type 'ascii |
|
1140 |
"The type of checkboxes to use for HTML export. |
|
1141 |
See `org-html-checkbox-types' for for the values used for each |
|
1142 |
option." |
|
1143 |
:group 'org-export-html |
|
1144 |
:version "24.4" |
|
1145 |
:package-version '(Org . "8.0") |
|
1146 |
:type '(choice |
|
1147 |
(const :tag "ASCII characters" ascii) |
|
1148 |
(const :tag "Unicode characters" unicode) |
|
1149 |
(const :tag "HTML checkboxes" html))) |
|
1150 |
|
|
1151 |
(defcustom org-html-metadata-timestamp-format "%Y-%m-%d %a %H:%M" |
|
1152 |
"Format used for timestamps in preamble, postamble and metadata. |
|
1153 |
See `format-time-string' for more information on its components." |
|
1154 |
:group 'org-export-html |
|
1155 |
:version "24.4" |
|
1156 |
:package-version '(Org . "8.0") |
|
1157 |
:type 'string) |
|
1158 |
|
|
1159 |
;;;; Template :: Mathjax |
|
1160 |
|
|
1161 |
(defcustom org-html-mathjax-options |
|
1162 |
'((path "https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.0/MathJax.js?config=TeX-AMS_HTML" ) |
|
1163 |
(scale "100") |
|
1164 |
(align "center") |
|
1165 |
(font "TeX") |
|
1166 |
(linebreaks "false") |
|
1167 |
(autonumber "AMS") |
|
1168 |
(indent "0em") |
|
1169 |
(multlinewidth "85%") |
|
1170 |
(tagindent ".8em") |
|
1171 |
(tagside "right")) |
|
1172 |
"Options for MathJax setup. |
|
1173 |
|
|
1174 |
Alist of the following elements. All values are strings. |
|
1175 |
|
|
1176 |
path The path to MathJax. |
|
1177 |
scale Scaling with HTML-CSS, MathML and SVG output engines. |
|
1178 |
align How to align display math: left, center, or right. |
|
1179 |
font The font to use with HTML-CSS and SVG output. As of MathJax 2.5 |
|
1180 |
the following values are understood: \"TeX\", \"STIX-Web\", |
|
1181 |
\"Asana-Math\", \"Neo-Euler\", \"Gyre-Pagella\", |
|
1182 |
\"Gyre-Termes\", and \"Latin-Modern\". |
|
1183 |
linebreaks Let MathJax perform automatic linebreaks. Valid values |
|
1184 |
are \"true\" and \"false\". |
|
1185 |
indent If align is not center, how far from the left/right side? |
|
1186 |
Valid values are \"left\" and \"right\" |
|
1187 |
multlinewidth The width of the multline environment. |
|
1188 |
autonumber How to number equations. Valid values are \"None\", |
|
1189 |
\"all\" and \"AMS Math\". |
|
1190 |
tagindent The amount tags are indented. |
|
1191 |
tagside Which side to show tags/labels on. Valid values are |
|
1192 |
\"left\" and \"right\" |
|
1193 |
|
|
1194 |
You can also customize this for each buffer, using something like |
|
1195 |
|
|
1196 |
#+HTML_MATHJAX: align: left indent: 5em tagside: left font: Neo-Euler |
|
1197 |
|
|
1198 |
For further information about MathJax options, see the MathJax documentation: |
|
1199 |
|
|
1200 |
http://docs.mathjax.org/" |
|
1201 |
:group 'org-export-html |
|
1202 |
:package-version '(Org . "8.3") |
|
1203 |
:type '(list :greedy t |
|
1204 |
(list :tag "path (the path from where to load MathJax.js)" |
|
1205 |
(const :format " " path) (string)) |
|
1206 |
(list :tag "scale (scaling for the displayed math)" |
|
1207 |
(const :format " " scale) (string)) |
|
1208 |
(list :tag "align (alignment of displayed equations)" |
|
1209 |
(const :format " " align) (string)) |
|
1210 |
(list :tag "font (used to display math)" |
|
1211 |
(const :format " " font) |
|
1212 |
(choice (const "TeX") |
|
1213 |
(const "STIX-Web") |
|
1214 |
(const "Asana-Math") |
|
1215 |
(const "Neo-Euler") |
|
1216 |
(const "Gyre-Pagella") |
|
1217 |
(const "Gyre-Termes") |
|
1218 |
(const "Latin-Modern"))) |
|
1219 |
(list :tag "linebreaks (automatic line-breaking)" |
|
1220 |
(const :format " " linebreaks) |
|
1221 |
(choice (const "true") |
|
1222 |
(const "false"))) |
|
1223 |
(list :tag "autonumber (when should equations be numbered)" |
|
1224 |
(const :format " " autonumber) |
|
1225 |
(choice (const "AMS") |
|
1226 |
(const "None") |
|
1227 |
(const "All"))) |
|
1228 |
(list :tag "indent (indentation with left or right alignment)" |
|
1229 |
(const :format " " indent) (string)) |
|
1230 |
(list :tag "multlinewidth (width to use for the multline environment)" |
|
1231 |
(const :format " " multlinewidth) (string)) |
|
1232 |
(list :tag "tagindent (the indentation of tags from left or right)" |
|
1233 |
(const :format " " tagindent) (string)) |
|
1234 |
(list :tag "tagside (location of tags)" |
|
1235 |
(const :format " " tagside) |
|
1236 |
(choice (const "left") |
|
1237 |
(const "right"))))) |
|
1238 |
|
|
1239 |
(defcustom org-html-mathjax-template |
|
1240 |
"<script type=\"text/x-mathjax-config\"> |
|
1241 |
MathJax.Hub.Config({ |
|
1242 |
displayAlign: \"%ALIGN\", |
|
1243 |
displayIndent: \"%INDENT\", |
|
1244 |
|
|
1245 |
\"HTML-CSS\": { scale: %SCALE, |
|
1246 |
linebreaks: { automatic: \"%LINEBREAKS\" }, |
|
1247 |
webFont: \"%FONT\" |
|
1248 |
}, |
|
1249 |
SVG: {scale: %SCALE, |
|
1250 |
linebreaks: { automatic: \"%LINEBREAKS\" }, |
|
1251 |
font: \"%FONT\"}, |
|
1252 |
NativeMML: {scale: %SCALE}, |
|
1253 |
TeX: { equationNumbers: {autoNumber: \"%AUTONUMBER\"}, |
|
1254 |
MultLineWidth: \"%MULTLINEWIDTH\", |
|
1255 |
TagSide: \"%TAGSIDE\", |
|
1256 |
TagIndent: \"%TAGINDENT\" |
|
1257 |
} |
|
1258 |
}); |
|
1259 |
</script> |
|
1260 |
<script type=\"text/javascript\" |
|
1261 |
src=\"%PATH\"></script>" |
|
1262 |
"The MathJax template. See also `org-html-mathjax-options'." |
|
1263 |
:group 'org-export-html |
|
1264 |
:type 'string) |
|
1265 |
|
|
1266 |
;;;; Template :: Postamble |
|
1267 |
|
|
1268 |
(defcustom org-html-postamble 'auto |
|
1269 |
"Non-nil means insert a postamble in HTML export. |
|
1270 |
|
|
1271 |
When set to `auto', check against the |
|
1272 |
`org-export-with-author/email/creator/date' variables to set the |
|
1273 |
content of the postamble. When set to a string, use this string |
|
1274 |
as the postamble. When t, insert a string as defined by the |
|
1275 |
formatting string in `org-html-postamble-format'. |
|
1276 |
|
|
1277 |
When set to a function, apply this function and insert the |
|
1278 |
returned string. The function takes the property list of export |
|
1279 |
options as its only argument. |
|
1280 |
|
|
1281 |
Setting :html-postamble in publishing projects will take |
|
1282 |
precedence over this variable." |
|
1283 |
:group 'org-export-html |
|
1284 |
:type '(choice (const :tag "No postamble" nil) |
|
1285 |
(const :tag "Auto postamble" auto) |
|
1286 |
(const :tag "Default formatting string" t) |
|
1287 |
(string :tag "Custom formatting string") |
|
1288 |
(function :tag "Function (must return a string)"))) |
|
1289 |
|
|
1290 |
(defcustom org-html-postamble-format |
|
1291 |
'(("en" "<p class=\"author\">Author: %a (%e)</p> |
|
1292 |
<p class=\"date\">Date: %d</p> |
|
1293 |
<p class=\"creator\">%c</p> |
|
1294 |
<p class=\"validation\">%v</p>")) |
|
1295 |
"Alist of languages and format strings for the HTML postamble. |
|
1296 |
|
|
1297 |
The first element of each list is the language code, as used for |
|
1298 |
the LANGUAGE keyword. See `org-export-default-language'. |
|
1299 |
|
|
1300 |
The second element of each list is a format string to format the |
|
1301 |
postamble itself. This format string can contain these elements: |
|
1302 |
|
|
1303 |
%t stands for the title. |
|
1304 |
%s stands for the subtitle. |
|
1305 |
%a stands for the author's name. |
|
1306 |
%e stands for the author's email. |
|
1307 |
%d stands for the date. |
|
1308 |
%c will be replaced by `org-html-creator-string'. |
|
1309 |
%v will be replaced by `org-html-validation-link'. |
|
1310 |
%T will be replaced by the export time. |
|
1311 |
%C will be replaced by the last modification time. |
|
1312 |
|
|
1313 |
If you need to use a \"%\" character, you need to escape it |
|
1314 |
like that: \"%%\"." |
|
1315 |
:group 'org-export-html |
|
1316 |
:type '(repeat |
|
1317 |
(list (string :tag "Language") |
|
1318 |
(string :tag "Format string")))) |
|
1319 |
|
|
1320 |
(defcustom org-html-validation-link |
|
1321 |
"<a href=\"http://validator.w3.org/check?uri=referer\">Validate</a>" |
|
1322 |
"Link to HTML validation service." |
|
1323 |
:group 'org-export-html |
|
1324 |
:type 'string) |
|
1325 |
|
|
1326 |
(defcustom org-html-creator-string |
|
1327 |
(format "<a href=\"https://www.gnu.org/software/emacs/\">Emacs</a> %s (<a href=\"https://orgmode.org\">Org</a> mode %s)" |
|
1328 |
emacs-version |
|
1329 |
(if (fboundp 'org-version) (org-version) "unknown version")) |
|
1330 |
"Information about the creator of the HTML document. |
|
1331 |
This option can also be set on with the CREATOR keyword." |
|
1332 |
:group 'org-export-html |
|
1333 |
:version "24.4" |
|
1334 |
:package-version '(Org . "8.0") |
|
1335 |
:type '(string :tag "Creator string")) |
|
1336 |
|
|
1337 |
;;;; Template :: Preamble |
|
1338 |
|
|
1339 |
(defcustom org-html-preamble t |
|
1340 |
"Non-nil means insert a preamble in HTML export. |
|
1341 |
|
|
1342 |
When t, insert a string as defined by the formatting string in |
|
1343 |
`org-html-preamble-format'. When set to a string, use this |
|
1344 |
formatting string instead (see `org-html-postamble-format' for an |
|
1345 |
example of such a formatting string). |
|
1346 |
|
|
1347 |
When set to a function, apply this function and insert the |
|
1348 |
returned string. The function takes the property list of export |
|
1349 |
options as its only argument. |
|
1350 |
|
|
1351 |
Setting :html-preamble in publishing projects will take |
|
1352 |
precedence over this variable." |
|
1353 |
:group 'org-export-html |
|
1354 |
:type '(choice (const :tag "No preamble" nil) |
|
1355 |
(const :tag "Default preamble" t) |
|
1356 |
(string :tag "Custom formatting string") |
|
1357 |
(function :tag "Function (must return a string)"))) |
|
1358 |
|
|
1359 |
(defcustom org-html-preamble-format '(("en" "")) |
|
1360 |
"Alist of languages and format strings for the HTML preamble. |
|
1361 |
|
|
1362 |
The first element of each list is the language code, as used for |
|
1363 |
the LANGUAGE keyword. See `org-export-default-language'. |
|
1364 |
|
|
1365 |
The second element of each list is a format string to format the |
|
1366 |
preamble itself. This format string can contain these elements: |
|
1367 |
|
|
1368 |
%t stands for the title. |
|
1369 |
%s stands for the subtitle. |
|
1370 |
%a stands for the author's name. |
|
1371 |
%e stands for the author's email. |
|
1372 |
%d stands for the date. |
|
1373 |
%c will be replaced by `org-html-creator-string'. |
|
1374 |
%v will be replaced by `org-html-validation-link'. |
|
1375 |
%T will be replaced by the export time. |
|
1376 |
%C will be replaced by the last modification time. |
|
1377 |
|
|
1378 |
If you need to use a \"%\" character, you need to escape it |
|
1379 |
like that: \"%%\". |
|
1380 |
|
|
1381 |
See the default value of `org-html-postamble-format' for an |
|
1382 |
example." |
|
1383 |
:group 'org-export-html |
|
1384 |
:type '(repeat |
|
1385 |
(list (string :tag "Language") |
|
1386 |
(string :tag "Format string")))) |
|
1387 |
|
|
1388 |
(defcustom org-html-link-up "" |
|
1389 |
"Where should the \"UP\" link of exported HTML pages lead?" |
|
1390 |
:group 'org-export-html |
|
1391 |
:type '(string :tag "File or URL")) |
|
1392 |
|
|
1393 |
(defcustom org-html-link-home "" |
|
1394 |
"Where should the \"HOME\" link of exported HTML pages lead?" |
|
1395 |
:group 'org-export-html |
|
1396 |
:type '(string :tag "File or URL")) |
|
1397 |
|
|
1398 |
(defcustom org-html-link-use-abs-url nil |
|
1399 |
"Should we prepend relative links with HTML_LINK_HOME?" |
|
1400 |
:group 'org-export-html |
|
1401 |
:version "24.4" |
|
1402 |
:package-version '(Org . "8.1") |
|
1403 |
:type 'boolean) |
|
1404 |
|
|
1405 |
(defcustom org-html-home/up-format |
|
1406 |
"<div id=\"org-div-home-and-up\"> |
|
1407 |
<a accesskey=\"h\" href=\"%s\"> UP </a> |
|
1408 |
| |
|
1409 |
<a accesskey=\"H\" href=\"%s\"> HOME </a> |
|
1410 |
</div>" |
|
1411 |
"Snippet used to insert the HOME and UP links. |
|
1412 |
This is a format string, the first %s will receive the UP link, |
|
1413 |
the second the HOME link. If both `org-html-link-up' and |
|
1414 |
`org-html-link-home' are empty, the entire snippet will be |
|
1415 |
ignored." |
|
1416 |
:group 'org-export-html |
|
1417 |
:type 'string) |
|
1418 |
|
|
1419 |
;;;; Template :: Scripts |
|
1420 |
|
|
1421 |
(defcustom org-html-head-include-scripts t |
|
1422 |
"Non-nil means include the JavaScript snippets in exported HTML files. |
|
1423 |
The actual script is defined in `org-html-scripts' and should |
|
1424 |
not be modified." |
|
1425 |
:group 'org-export-html |
|
1426 |
:version "24.4" |
|
1427 |
:package-version '(Org . "8.0") |
|
1428 |
:type 'boolean) |
|
1429 |
|
|
1430 |
;;;; Template :: Styles |
|
1431 |
|
|
1432 |
(defcustom org-html-head-include-default-style t |
|
1433 |
"Non-nil means include the default style in exported HTML files. |
|
1434 |
The actual style is defined in `org-html-style-default' and |
|
1435 |
should not be modified. Use `org-html-head' to use your own |
|
1436 |
style information." |
|
1437 |
:group 'org-export-html |
|
1438 |
:version "24.4" |
|
1439 |
:package-version '(Org . "8.0") |
|
1440 |
:type 'boolean) |
|
1441 |
;;;###autoload |
|
1442 |
(put 'org-html-head-include-default-style 'safe-local-variable 'booleanp) |
|
1443 |
|
|
1444 |
(defcustom org-html-head "" |
|
1445 |
"Org-wide head definitions for exported HTML files. |
|
1446 |
|
|
1447 |
This variable can contain the full HTML structure to provide a |
|
1448 |
style, including the surrounding HTML tags. You can consider |
|
1449 |
including definitions for the following classes: title, todo, |
|
1450 |
done, timestamp, timestamp-kwd, tag, target. |
|
1451 |
|
|
1452 |
For example, a valid value would be: |
|
1453 |
|
|
1454 |
<style type=\"text/css\"> |
|
1455 |
/*<![CDATA[*/ |
|
1456 |
p { font-weight: normal; color: gray; } |
|
1457 |
h1 { color: black; } |
|
1458 |
.title { text-align: center; } |
|
1459 |
.todo, .timestamp-kwd { color: red; } |
|
1460 |
.done { color: green; } |
|
1461 |
/*]]>*/ |
|
1462 |
</style> |
|
1463 |
|
|
1464 |
If you want to refer to an external style, use something like |
|
1465 |
|
|
1466 |
<link rel=\"stylesheet\" type=\"text/css\" href=\"mystyles.css\" /> |
|
1467 |
|
|
1468 |
As the value of this option simply gets inserted into the HTML |
|
1469 |
<head> header, you can use it to add any arbitrary text to the |
|
1470 |
header. |
|
1471 |
|
|
1472 |
You can set this on a per-file basis using #+HTML_HEAD:, |
|
1473 |
or for publication projects using the :html-head property." |
|
1474 |
:group 'org-export-html |
|
1475 |
:version "24.4" |
|
1476 |
:package-version '(Org . "8.0") |
|
1477 |
:type 'string) |
|
1478 |
;;;###autoload |
|
1479 |
(put 'org-html-head 'safe-local-variable 'stringp) |
|
1480 |
|
|
1481 |
(defcustom org-html-head-extra "" |
|
1482 |
"More head information to add in the HTML output. |
|
1483 |
|
|
1484 |
You can set this on a per-file basis using #+HTML_HEAD_EXTRA:, |
|
1485 |
or for publication projects using the :html-head-extra property." |
|
1486 |
:group 'org-export-html |
|
1487 |
:version "24.4" |
|
1488 |
:package-version '(Org . "8.0") |
|
1489 |
:type 'string) |
|
1490 |
;;;###autoload |
|
1491 |
(put 'org-html-head-extra 'safe-local-variable 'stringp) |
|
1492 |
|
|
1493 |
;;;; Template :: Viewport |
|
1494 |
|
|
1495 |
(defcustom org-html-viewport '((width "device-width") |
|
1496 |
(initial-scale "1") |
|
1497 |
(minimum-scale "") |
|
1498 |
(maximum-scale "") |
|
1499 |
(user-scalable "")) |
|
1500 |
"Viewport options for mobile-optimized sites. |
|
1501 |
|
|
1502 |
The following values are recognized |
|
1503 |
|
|
1504 |
width Size of the viewport. |
|
1505 |
initial-scale Zoom level when the page is first loaded. |
|
1506 |
minimum-scale Minimum allowed zoom level. |
|
1507 |
maximum-scale Maximum allowed zoom level. |
|
1508 |
user-scalable Whether zoom can be changed. |
|
1509 |
|
|
1510 |
The viewport meta tag is inserted if this variable is non-nil. |
|
1511 |
|
|
1512 |
See the following site for a reference: |
|
1513 |
https://developer.mozilla.org/en-US/docs/Mozilla/Mobile/Viewport_meta_tag" |
|
1514 |
:group 'org-export-html |
|
1515 |
:version "26.1" |
|
1516 |
:package-version '(Org . "8.3") |
|
1517 |
:type '(choice (const :tag "Disable" nil) |
|
1518 |
(list :tag "Enable" |
|
1519 |
(list :tag "Width of viewport" |
|
1520 |
(const :format " " width) |
|
1521 |
(choice (const :tag "unset" "") |
|
1522 |
(string))) |
|
1523 |
(list :tag "Initial scale" |
|
1524 |
(const :format " " initial-scale) |
|
1525 |
(choice (const :tag "unset" "") |
|
1526 |
(string))) |
|
1527 |
(list :tag "Minimum scale/zoom" |
|
1528 |
(const :format " " minimum-scale) |
|
1529 |
(choice (const :tag "unset" "") |
|
1530 |
(string))) |
|
1531 |
(list :tag "Maximum scale/zoom" |
|
1532 |
(const :format " " maximum-scale) |
|
1533 |
(choice (const :tag "unset" "") |
|
1534 |
(string))) |
|
1535 |
(list :tag "User scalable/zoomable" |
|
1536 |
(const :format " " user-scalable) |
|
1537 |
(choice (const :tag "unset" "") |
|
1538 |
(const "true") |
|
1539 |
(const "false")))))) |
|
1540 |
|
|
1541 |
;; Handle source code blocks with Klipse |
|
1542 |
|
|
1543 |
(defcustom org-html-klipsify-src nil |
|
1544 |
"When non-nil, source code blocks are editable in exported presentation." |
|
1545 |
:group 'org-export-html |
|
1546 |
:package-version '(Org . "9.1") |
|
1547 |
:type 'boolean) |
|
1548 |
|
|
1549 |
(defcustom org-html-klipse-css |
|
1550 |
"https://storage.googleapis.com/app.klipse.tech/css/codemirror.css" |
|
1551 |
"Location of the codemirror CSS file for use with klipse." |
|
1552 |
:group 'org-export-html |
|
1553 |
:package-version '(Org . "9.1") |
|
1554 |
:type 'string) |
|
1555 |
|
|
1556 |
(defcustom org-html-klipse-js |
|
1557 |
"https://storage.googleapis.com/app.klipse.tech/plugin_prod/js/klipse_plugin.min.js" |
|
1558 |
"Location of the klipse javascript file." |
|
1559 |
:group 'org-export-html |
|
1560 |
:type 'string) |
|
1561 |
|
|
1562 |
(defcustom org-html-klipse-selection-script |
|
1563 |
"window.klipse_settings = {selector_eval_html: '.src-html', |
|
1564 |
selector_eval_js: '.src-js', |
|
1565 |
selector_eval_python_client: '.src-python', |
|
1566 |
selector_eval_scheme: '.src-scheme', |
|
1567 |
selector: '.src-clojure', |
|
1568 |
selector_eval_ruby: '.src-ruby'};" |
|
1569 |
"Javascript snippet to activate klipse." |
|
1570 |
:group 'org-export-html |
|
1571 |
:package-version '(Org . "9.1") |
|
1572 |
:type 'string) |
|
1573 |
|
|
1574 |
|
|
1575 |
;;;; Todos |
|
1576 |
|
|
1577 |
(defcustom org-html-todo-kwd-class-prefix "" |
|
1578 |
"Prefix to class names for TODO keywords. |
|
1579 |
Each TODO keyword gets a class given by the keyword itself, with this prefix. |
|
1580 |
The default prefix is empty because it is nice to just use the keyword |
|
1581 |
as a class name. But if you get into conflicts with other, existing |
|
1582 |
CSS classes, then this prefix can be very useful." |
|
1583 |
:group 'org-export-html |
|
1584 |
:type 'string) |
|
1585 |
|
|
1586 |
|
|
1587 |
;;; Internal Functions |
|
1588 |
|
|
1589 |
(defun org-html-xhtml-p (info) |
|
1590 |
(let ((dt (downcase (plist-get info :html-doctype)))) |
|
1591 |
(string-match-p "xhtml" dt))) |
|
1592 |
|
|
1593 |
(defun org-html-html5-p (info) |
|
1594 |
(let ((dt (downcase (plist-get info :html-doctype)))) |
|
1595 |
(member dt '("html5" "xhtml5" "<!doctype html>")))) |
|
1596 |
|
|
1597 |
(defun org-html--html5-fancy-p (info) |
|
1598 |
"Non-nil when exporting to HTML5 with fancy elements. |
|
1599 |
INFO is the current state of the export process, as a plist." |
|
1600 |
(and (plist-get info :html-html5-fancy) |
|
1601 |
(org-html-html5-p info))) |
|
1602 |
|
|
1603 |
(defun org-html-close-tag (tag attr info) |
|
1604 |
"Return close-tag for string TAG. |
|
1605 |
ATTR specifies additional attributes. INFO is a property list |
|
1606 |
containing current export state." |
|
1607 |
(concat "<" tag |
|
1608 |
(org-string-nw-p (concat " " attr)) |
|
1609 |
(if (org-html-xhtml-p info) " />" ">"))) |
|
1610 |
|
|
1611 |
(defun org-html-doctype (info) |
|
1612 |
"Return correct HTML doctype tag. |
|
1613 |
INFO is a plist used as a communication channel. Doctype tag is |
|
1614 |
extracted from `org-html-doctype-alist', or the literal value |
|
1615 |
of :html-doctype from INFO if :html-doctype is not found in the |
|
1616 |
alist." |
|
1617 |
(let ((dt (plist-get info :html-doctype))) |
|
1618 |
(or (cdr (assoc dt org-html-doctype-alist)) dt))) |
|
1619 |
|
|
1620 |
(defun org-html--make-attribute-string (attributes) |
|
1621 |
"Return a list of attributes, as a string. |
|
1622 |
ATTRIBUTES is a plist where values are either strings or nil. An |
|
1623 |
attribute with a nil value will be omitted from the result." |
|
1624 |
(let (output) |
|
1625 |
(dolist (item attributes (mapconcat 'identity (nreverse output) " ")) |
|
1626 |
(cond ((null item) (pop output)) |
|
1627 |
((symbolp item) (push (substring (symbol-name item) 1) output)) |
|
1628 |
(t (let ((key (car output)) |
|
1629 |
(value (replace-regexp-in-string |
|
1630 |
"\"" """ (org-html-encode-plain-text item)))) |
|
1631 |
(setcar output (format "%s=\"%s\"" key value)))))))) |
|
1632 |
|
|
1633 |
(defun org-html--wrap-image (contents info &optional caption label) |
|
1634 |
"Wrap CONTENTS string within an appropriate environment for images. |
|
1635 |
INFO is a plist used as a communication channel. When optional |
|
1636 |
arguments CAPTION and LABEL are given, use them for caption and |
|
1637 |
\"id\" attribute." |
|
1638 |
(let ((html5-fancy (org-html--html5-fancy-p info))) |
|
1639 |
(format (if html5-fancy "\n<figure%s>\n%s%s\n</figure>" |
|
1640 |
"\n<div%s class=\"figure\">\n%s%s\n</div>") |
|
1641 |
;; ID. |
|
1642 |
(if (org-string-nw-p label) (format " id=\"%s\"" label) "") |
|
1643 |
;; Contents. |
|
1644 |
(if html5-fancy contents (format "<p>%s</p>" contents)) |
|
1645 |
;; Caption. |
|
1646 |
(if (not (org-string-nw-p caption)) "" |
|
1647 |
(format (if html5-fancy "\n<figcaption>%s</figcaption>" |
|
1648 |
"\n<p>%s</p>") |
|
1649 |
caption))))) |
|
1650 |
|
|
1651 |
(defun org-html--format-image (source attributes info) |
|
1652 |
"Return \"img\" tag with given SOURCE and ATTRIBUTES. |
|
1653 |
SOURCE is a string specifying the location of the image. |
|
1654 |
ATTRIBUTES is a plist, as returned by |
|
1655 |
`org-export-read-attribute'. INFO is a plist used as |
|
1656 |
a communication channel." |
|
1657 |
(if (string= "svg" (file-name-extension source)) |
|
1658 |
(org-html--svg-image source attributes info) |
|
1659 |
(org-html-close-tag |
|
1660 |
"img" |
|
1661 |
(org-html--make-attribute-string |
|
1662 |
(org-combine-plists |
|
1663 |
(list :src source |
|
1664 |
:alt (if (string-match-p "^ltxpng/" source) |
|
1665 |
(org-html-encode-plain-text |
|
1666 |
(org-find-text-property-in-string 'org-latex-src source)) |
|
1667 |
(file-name-nondirectory source))) |
|
1668 |
attributes)) |
|
1669 |
info))) |
|
1670 |
|
|
1671 |
(defun org-html--svg-image (source attributes info) |
|
1672 |
"Return \"object\" embedding svg file SOURCE with given ATTRIBUTES. |
|
1673 |
INFO is a plist used as a communication channel. |
|
1674 |
|
|
1675 |
The special attribute \"fallback\" can be used to specify a |
|
1676 |
fallback image file to use if the object embedding is not |
|
1677 |
supported. CSS class \"org-svg\" is assigned as the class of the |
|
1678 |
object unless a different class is specified with an attribute." |
|
1679 |
(let ((fallback (plist-get attributes :fallback)) |
|
1680 |
(attrs (org-html--make-attribute-string |
|
1681 |
(org-combine-plists |
|
1682 |
;; Remove fallback attribute, which is not meant to |
|
1683 |
;; appear directly in the attributes string, and |
|
1684 |
;; provide a default class if none is set. |
|
1685 |
'(:class "org-svg") attributes '(:fallback nil))))) |
|
1686 |
(format "<object type=\"image/svg+xml\" data=\"%s\" %s>\n%s</object>" |
|
1687 |
source |
|
1688 |
attrs |
|
1689 |
(if fallback |
|
1690 |
(org-html-close-tag |
|
1691 |
"img" (format "src=\"%s\" %s" fallback attrs) info) |
|
1692 |
"Sorry, your browser does not support SVG.")))) |
|
1693 |
|
|
1694 |
(defun org-html--textarea-block (element) |
|
1695 |
"Transcode ELEMENT into a textarea block. |
|
1696 |
ELEMENT is either a src block or an example block." |
|
1697 |
(let* ((code (car (org-export-unravel-code element))) |
|
1698 |
(attr (org-export-read-attribute :attr_html element))) |
|
1699 |
(format "<p>\n<textarea cols=\"%s\" rows=\"%s\">\n%s</textarea>\n</p>" |
|
1700 |
(or (plist-get attr :width) 80) |
|
1701 |
(or (plist-get attr :height) (org-count-lines code)) |
|
1702 |
code))) |
|
1703 |
|
|
1704 |
(defun org-html--has-caption-p (element &optional _info) |
|
1705 |
"Non-nil when ELEMENT has a caption affiliated keyword. |
|
1706 |
INFO is a plist used as a communication channel. This function |
|
1707 |
is meant to be used as a predicate for `org-export-get-ordinal' or |
|
1708 |
a value to `org-html-standalone-image-predicate'." |
|
1709 |
(org-element-property :caption element)) |
|
1710 |
|
|
1711 |
;;;; Table |
|
1712 |
|
|
1713 |
(defun org-html-htmlize-region-for-paste (beg end) |
|
1714 |
"Convert the region between BEG and END to HTML, using htmlize.el. |
|
1715 |
This is much like `htmlize-region-for-paste', only that it uses |
|
1716 |
the settings define in the org-... variables." |
|
1717 |
(let* ((htmlize-output-type org-html-htmlize-output-type) |
|
1718 |
(htmlize-css-name-prefix org-html-htmlize-font-prefix) |
|
1719 |
(htmlbuf (htmlize-region beg end))) |
|
1720 |
(unwind-protect |
|
1721 |
(with-current-buffer htmlbuf |
|
1722 |
(buffer-substring (plist-get htmlize-buffer-places 'content-start) |
|
1723 |
(plist-get htmlize-buffer-places 'content-end))) |
|
1724 |
(kill-buffer htmlbuf)))) |
|
1725 |
|
|
1726 |
;;;###autoload |
|
1727 |
(defun org-html-htmlize-generate-css () |
|
1728 |
"Create the CSS for all font definitions in the current Emacs session. |
|
1729 |
Use this to create face definitions in your CSS style file that can then |
|
1730 |
be used by code snippets transformed by htmlize. |
|
1731 |
This command just produces a buffer that contains class definitions for all |
|
1732 |
faces used in the current Emacs session. You can copy and paste the ones you |
|
1733 |
need into your CSS file. |
|
1734 |
|
|
1735 |
If you then set `org-html-htmlize-output-type' to `css', calls |
|
1736 |
to the function `org-html-htmlize-region-for-paste' will |
|
1737 |
produce code that uses these same face definitions." |
|
1738 |
(interactive) |
|
1739 |
(or (require 'htmlize nil t) |
|
1740 |
(error "Please install htmlize from https://github.com/hniksic/emacs-htmlize")) |
|
1741 |
(and (get-buffer "*html*") (kill-buffer "*html*")) |
|
1742 |
(with-temp-buffer |
|
1743 |
(let ((fl (face-list)) |
|
1744 |
(htmlize-css-name-prefix "org-") |
|
1745 |
(htmlize-output-type 'css) |
|
1746 |
f i) |
|
1747 |
(while (setq f (pop fl) |
|
1748 |
i (and f (face-attribute f :inherit))) |
|
1749 |
(when (and (symbolp f) (or (not i) (not (listp i)))) |
|
1750 |
(insert (org-add-props (copy-sequence "1") nil 'face f)))) |
|
1751 |
(htmlize-region (point-min) (point-max)))) |
|
1752 |
(pop-to-buffer-same-window "*html*") |
|
1753 |
(goto-char (point-min)) |
|
1754 |
(if (re-search-forward "<style" nil t) |
|
1755 |
(delete-region (point-min) (match-beginning 0))) |
|
1756 |
(if (re-search-forward "</style>" nil t) |
|
1757 |
(delete-region (1+ (match-end 0)) (point-max))) |
|
1758 |
(beginning-of-line 1) |
|
1759 |
(if (looking-at " +") (replace-match "")) |
|
1760 |
(goto-char (point-min))) |
|
1761 |
|
|
1762 |
(defun org-html--make-string (n string) |
|
1763 |
"Build a string by concatenating N times STRING." |
|
1764 |
(let (out) (dotimes (_ n out) (setq out (concat string out))))) |
|
1765 |
|
|
1766 |
(defun org-html-fix-class-name (kwd) ; audit callers of this function |
|
1767 |
"Turn todo keyword KWD into a valid class name. |
|
1768 |
Replaces invalid characters with \"_\"." |
|
1769 |
(replace-regexp-in-string "[^a-zA-Z0-9_]" "_" kwd nil t)) |
|
1770 |
|
|
1771 |
(defun org-html-footnote-section (info) |
|
1772 |
"Format the footnote section. |
|
1773 |
INFO is a plist used as a communication channel." |
|
1774 |
(let* ((fn-alist (org-export-collect-footnote-definitions info)) |
|
1775 |
(fn-alist |
|
1776 |
(cl-loop for (n _type raw) in fn-alist collect |
|
1777 |
(cons n (if (eq (org-element-type raw) 'org-data) |
|
1778 |
(org-trim (org-export-data raw info)) |
|
1779 |
(format "<div class=\"footpara\">%s</div>" |
|
1780 |
(org-trim (org-export-data raw info)))))))) |
|
1781 |
(when fn-alist |
|
1782 |
(format |
|
1783 |
(plist-get info :html-footnotes-section) |
|
1784 |
(org-html--translate "Footnotes" info) |
|
1785 |
(format |
|
1786 |
"\n%s\n" |
|
1787 |
(mapconcat |
|
1788 |
(lambda (fn) |
|
1789 |
(let ((n (car fn)) (def (cdr fn))) |
|
1790 |
(format |
|
1791 |
"<div class=\"footdef\">%s %s</div>\n" |
|
1792 |
(format |
|
1793 |
(plist-get info :html-footnote-format) |
|
1794 |
(org-html--anchor |
|
1795 |
(format "fn.%d" n) |
|
1796 |
n |
|
1797 |
(format " class=\"footnum\" href=\"#fnr.%d\"" n) |
|
1798 |
info)) |
|
1799 |
def))) |
|
1800 |
fn-alist |
|
1801 |
"\n")))))) |
|
1802 |
|
|
1803 |
|
|
1804 |
;;; Template |
|
1805 |
|
|
1806 |
(defun org-html--build-meta-info (info) |
|
1807 |
"Return meta tags for exported document. |
|
1808 |
INFO is a plist used as a communication channel." |
|
1809 |
(let* ((protect-string |
|
1810 |
(lambda (str) |
|
1811 |
(replace-regexp-in-string |
|
1812 |
"\"" """ (org-html-encode-plain-text str)))) |
|
1813 |
(title (org-export-data (plist-get info :title) info)) |
|
1814 |
;; Set title to an invisible character instead of leaving it |
|
1815 |
;; empty, which is invalid. |
|
1816 |
(title (if (org-string-nw-p title) title "‎")) |
|
1817 |
(author (and (plist-get info :with-author) |
|
1818 |
(let ((auth (plist-get info :author))) |
|
1819 |
(and auth |
|
1820 |
;; Return raw Org syntax, skipping non |
|
1821 |
;; exportable objects. |
|
1822 |
(org-element-interpret-data |
|
1823 |
(org-element-map auth |
|
1824 |
(cons 'plain-text org-element-all-objects) |
|
1825 |
'identity info)))))) |
|
1826 |
(description (plist-get info :description)) |
|
1827 |
(keywords (plist-get info :keywords)) |
|
1828 |
(charset (or (and org-html-coding-system |
|
1829 |
(fboundp 'coding-system-get) |
|
1830 |
(coding-system-get org-html-coding-system |
|
1831 |
'mime-charset)) |
|
1832 |
"iso-8859-1"))) |
|
1833 |
(concat |
|
1834 |
(when (plist-get info :time-stamp-file) |
|
1835 |
(format-time-string |
|
1836 |
(concat "<!-- " |
|
1837 |
(plist-get info :html-metadata-timestamp-format) |
|
1838 |
" -->\n"))) |
|
1839 |
(format |
|
1840 |
(if (org-html-html5-p info) |
|
1841 |
(org-html-close-tag "meta" "charset=\"%s\"" info) |
|
1842 |
(org-html-close-tag |
|
1843 |
"meta" "http-equiv=\"Content-Type\" content=\"text/html;charset=%s\"" |
|
1844 |
info)) |
|
1845 |
charset) "\n" |
|
1846 |
(let ((viewport-options |
|
1847 |
(cl-remove-if-not (lambda (cell) (org-string-nw-p (cadr cell))) |
|
1848 |
(plist-get info :html-viewport)))) |
|
1849 |
(and viewport-options |
|
1850 |
(concat |
|
1851 |
(org-html-close-tag |
|
1852 |
"meta" |
|
1853 |
(format "name=\"viewport\" content=\"%s\"" |
|
1854 |
(mapconcat |
|
1855 |
(lambda (elm) (format "%s=%s" (car elm) (cadr elm))) |
|
1856 |
viewport-options ", ")) |
|
1857 |
info) |
|
1858 |
"\n"))) |
|
1859 |
(format "<title>%s</title>\n" title) |
|
1860 |
(org-html-close-tag "meta" "name=\"generator\" content=\"Org mode\"" info) |
|
1861 |
"\n" |
|
1862 |
(and (org-string-nw-p author) |
|
1863 |
(concat |
|
1864 |
(org-html-close-tag "meta" |
|
1865 |
(format "name=\"author\" content=\"%s\"" |
|
1866 |
(funcall protect-string author)) |
|
1867 |
info) |
|
1868 |
"\n")) |
|
1869 |
(and (org-string-nw-p description) |
|
1870 |
(concat |
|
1871 |
(org-html-close-tag "meta" |
|
1872 |
(format "name=\"description\" content=\"%s\"\n" |
|
1873 |
(funcall protect-string description)) |
|
1874 |
info) |
|
1875 |
"\n")) |
|
1876 |
(and (org-string-nw-p keywords) |
|
1877 |
(concat |
|
1878 |
(org-html-close-tag "meta" |
|
1879 |
(format "name=\"keywords\" content=\"%s\"" |
|
1880 |
(funcall protect-string keywords)) |
|
1881 |
info) |
|
1882 |
"\n"))))) |
|
1883 |
|
|
1884 |
(defun org-html--build-head (info) |
|
1885 |
"Return information for the <head>..</head> of the HTML output. |
|
1886 |
INFO is a plist used as a communication channel." |
|
1887 |
(org-element-normalize-string |
|
1888 |
(concat |
|
1889 |
(when (plist-get info :html-head-include-default-style) |
|
1890 |
(org-element-normalize-string org-html-style-default)) |
|
1891 |
(org-element-normalize-string (plist-get info :html-head)) |
|
1892 |
(org-element-normalize-string (plist-get info :html-head-extra)) |
|
1893 |
(when (and (plist-get info :html-htmlized-css-url) |
|
1894 |
(eq org-html-htmlize-output-type 'css)) |
|
1895 |
(org-html-close-tag "link" |
|
1896 |
(format "rel=\"stylesheet\" href=\"%s\" type=\"text/css\"" |
|
1897 |
(plist-get info :html-htmlized-css-url)) |
|
1898 |
info)) |
|
1899 |
(when (plist-get info :html-head-include-scripts) org-html-scripts)))) |
|
1900 |
|
|
1901 |
(defun org-html--build-mathjax-config (info) |
|
1902 |
"Insert the user setup into the mathjax template. |
|
1903 |
INFO is a plist used as a communication channel." |
|
1904 |
(when (and (memq (plist-get info :with-latex) '(mathjax t)) |
|
1905 |
(org-element-map (plist-get info :parse-tree) |
|
1906 |
'(latex-fragment latex-environment) #'identity info t nil t)) |
|
1907 |
(let ((template (plist-get info :html-mathjax-template)) |
|
1908 |
(options (plist-get info :html-mathjax-options)) |
|
1909 |
(in-buffer (or (plist-get info :html-mathjax) ""))) |
|
1910 |
(dolist (e options (org-element-normalize-string template)) |
|
1911 |
(let ((name (car e)) |
|
1912 |
(val (nth 1 e))) |
|
1913 |
(when (string-match (concat "\\<" (symbol-name name) ":") in-buffer) |
|
1914 |
(setq val |
|
1915 |
(car (read-from-string (substring in-buffer (match-end 0)))))) |
|
1916 |
(unless (stringp val) (setq val (format "%s" val))) |
|
1917 |
(while (string-match (concat "%" (upcase (symbol-name name))) |
|
1918 |
template) |
|
1919 |
(setq template (replace-match val t t template)))))))) |
|
1920 |
|
|
1921 |
(defun org-html-format-spec (info) |
|
1922 |
"Return format specification for preamble and postamble. |
|
1923 |
INFO is a plist used as a communication channel." |
|
1924 |
(let ((timestamp-format (plist-get info :html-metadata-timestamp-format))) |
|
1925 |
`((?t . ,(org-export-data (plist-get info :title) info)) |
|
1926 |
(?s . ,(org-export-data (plist-get info :subtitle) info)) |
|
1927 |
(?d . ,(org-export-data (org-export-get-date info timestamp-format) |
|
1928 |
info)) |
|
1929 |
(?T . ,(format-time-string timestamp-format)) |
|
1930 |
(?a . ,(org-export-data (plist-get info :author) info)) |
|
1931 |
(?e . ,(mapconcat |
|
1932 |
(lambda (e) (format "<a href=\"mailto:%s\">%s</a>" e e)) |
|
1933 |
(split-string (plist-get info :email) ",+ *") |
|
1934 |
", ")) |
|
1935 |
(?c . ,(plist-get info :creator)) |
|
1936 |
(?C . ,(let ((file (plist-get info :input-file))) |
|
1937 |
(format-time-string timestamp-format |
|
1938 |
(and file (nth 5 (file-attributes file)))))) |
|
1939 |
(?v . ,(or (plist-get info :html-validation-link) ""))))) |
|
1940 |
|
|
1941 |
(defun org-html--build-pre/postamble (type info) |
|
1942 |
"Return document preamble or postamble as a string, or nil. |
|
1943 |
TYPE is either `preamble' or `postamble', INFO is a plist used as a |
|
1944 |
communication channel." |
|
1945 |
(let ((section (plist-get info (intern (format ":html-%s" type)))) |
|
1946 |
(spec (org-html-format-spec info))) |
|
1947 |
(when section |
|
1948 |
(let ((section-contents |
|
1949 |
(if (functionp section) (funcall section info) |
|
1950 |
(cond |
|
1951 |
((stringp section) (format-spec section spec)) |
|
1952 |
((eq section 'auto) |
|
1953 |
(let ((date (cdr (assq ?d spec))) |
|
1954 |
(author (cdr (assq ?a spec))) |
|
1955 |
(email (cdr (assq ?e spec))) |
|
1956 |
(creator (cdr (assq ?c spec))) |
|
1957 |
(validation-link (cdr (assq ?v spec)))) |
|
1958 |
(concat |
|
1959 |
(when (and (plist-get info :with-date) |
|
1960 |
(org-string-nw-p date)) |
|
1961 |
(format "<p class=\"date\">%s: %s</p>\n" |
|
1962 |
(org-html--translate "Date" info) |
|
1963 |
date)) |
|
1964 |
(when (and (plist-get info :with-author) |
|
1965 |
(org-string-nw-p author)) |
|
1966 |
(format "<p class=\"author\">%s: %s</p>\n" |
|
1967 |
(org-html--translate "Author" info) |
|
1968 |
author)) |
|
1969 |
(when (and (plist-get info :with-email) |
|
1970 |
(org-string-nw-p email)) |
|
1971 |
(format "<p class=\"email\">%s: %s</p>\n" |
|
1972 |
(org-html--translate "Email" info) |
|
1973 |
email)) |
|
1974 |
(when (plist-get info :time-stamp-file) |
|
1975 |
(format |
|
1976 |
"<p class=\"date\">%s: %s</p>\n" |
|
1977 |
(org-html--translate "Created" info) |
|
1978 |
(format-time-string |
|
1979 |
(plist-get info :html-metadata-timestamp-format)))) |
|
1980 |
(when (plist-get info :with-creator) |
|
1981 |
(format "<p class=\"creator\">%s</p>\n" creator)) |
|
1982 |
(format "<p class=\"validation\">%s</p>\n" |
|
1983 |
validation-link)))) |
|
1984 |
(t |
|
1985 |
(let ((formats (plist-get info (if (eq type 'preamble) |
|
1986 |
:html-preamble-format |
|
1987 |
:html-postamble-format))) |
|
1988 |
(language (plist-get info :language))) |
|
1989 |
(format-spec |
|
1990 |
(cadr (or (assoc-string language formats t) |
|
1991 |
(assoc-string "en" formats t))) |
|
1992 |
spec))))))) |
|
1993 |
(let ((div (assq type (plist-get info :html-divs)))) |
|
1994 |
(when (org-string-nw-p section-contents) |
|
1995 |
(concat |
|
1996 |
(format "<%s id=\"%s\" class=\"%s\">\n" |
|
1997 |
(nth 1 div) |
|
1998 |
(nth 2 div) |
|
1999 |
org-html--pre/postamble-class) |
|
2000 |
(org-element-normalize-string section-contents) |
|
2001 |
(format "</%s>\n" (nth 1 div))))))))) |
|
2002 |
|
|
2003 |
(defun org-html-inner-template (contents info) |
|
2004 |
"Return body of document string after HTML conversion. |
|
2005 |
CONTENTS is the transcoded contents string. INFO is a plist |
|
2006 |
holding export options." |
|
2007 |
(concat |
|
2008 |
;; Table of contents. |
|
2009 |
(let ((depth (plist-get info :with-toc))) |
|
2010 |
(when depth (org-html-toc depth info))) |
|
2011 |
;; Document contents. |
|
2012 |
contents |
|
2013 |
;; Footnotes section. |
|
2014 |
(org-html-footnote-section info))) |
|
2015 |
|
|
2016 |
(defun org-html-template (contents info) |
|
2017 |
"Return complete document string after HTML conversion. |
|
2018 |
CONTENTS is the transcoded contents string. INFO is a plist |
|
2019 |
holding export options." |
|
2020 |
(concat |
|
2021 |
(when (and (not (org-html-html5-p info)) (org-html-xhtml-p info)) |
|
2022 |
(let* ((xml-declaration (plist-get info :html-xml-declaration)) |
|
2023 |
(decl (or (and (stringp xml-declaration) xml-declaration) |
|
2024 |
(cdr (assoc (plist-get info :html-extension) |
|
2025 |
xml-declaration)) |
|
2026 |
(cdr (assoc "html" xml-declaration)) |
|
2027 |
""))) |
|
2028 |
(when (not (or (not decl) (string= "" decl))) |
|
2029 |
(format "%s\n" |
|
2030 |
(format decl |
|
2031 |
(or (and org-html-coding-system |
|
2032 |
(fboundp 'coding-system-get) |
|
2033 |
(coding-system-get org-html-coding-system 'mime-charset)) |
|
2034 |
"iso-8859-1")))))) |
|
2035 |
(org-html-doctype info) |
|
2036 |
"\n" |
|
2037 |
(concat "<html" |
|
2038 |
(cond ((org-html-xhtml-p info) |
|
2039 |
(format |
|
2040 |
" xmlns=\"http://www.w3.org/1999/xhtml\" lang=\"%s\" xml:lang=\"%s\"" |
|
2041 |
(plist-get info :language) (plist-get info :language))) |
|
2042 |
((org-html-html5-p info) |
|
2043 |
(format " lang=\"%s\"" (plist-get info :language)))) |
|
2044 |
">\n") |
|
2045 |
"<head>\n" |
|
2046 |
(org-html--build-meta-info info) |
|
2047 |
(org-html--build-head info) |
|
2048 |
(org-html--build-mathjax-config info) |
|
2049 |
"</head>\n" |
|
2050 |
"<body>\n" |
|
2051 |
(let ((link-up (org-trim (plist-get info :html-link-up))) |
|
2052 |
(link-home (org-trim (plist-get info :html-link-home)))) |
|
2053 |
(unless (and (string= link-up "") (string= link-home "")) |
|
2054 |
(format (plist-get info :html-home/up-format) |
|
2055 |
(or link-up link-home) |
|
2056 |
(or link-home link-up)))) |
|
2057 |
;; Preamble. |
|
2058 |
(org-html--build-pre/postamble 'preamble info) |
|
2059 |
;; Document contents. |
|
2060 |
(let ((div (assq 'content (plist-get info :html-divs)))) |
|
2061 |
(format "<%s id=\"%s\">\n" (nth 1 div) (nth 2 div))) |
|
2062 |
;; Document title. |
|
2063 |
(when (plist-get info :with-title) |
|
2064 |
(let ((title (and (plist-get info :with-title) |
|
2065 |
(plist-get info :title))) |
|
2066 |
(subtitle (plist-get info :subtitle)) |
|
2067 |
(html5-fancy (org-html--html5-fancy-p info))) |
|
2068 |
(when title |
|
2069 |
(format |
|
2070 |
(if html5-fancy |
|
2071 |
"<header>\n<h1 class=\"title\">%s</h1>\n%s</header>" |
|
2072 |
"<h1 class=\"title\">%s%s</h1>\n") |
|
2073 |
(org-export-data title info) |
|
2074 |
(if subtitle |
|
2075 |
(format |
|
2076 |
(if html5-fancy |
|
2077 |
"<p class=\"subtitle\">%s</p>\n" |
|
2078 |
(concat "\n" (org-html-close-tag "br" nil info) "\n" |
|
2079 |
"<span class=\"subtitle\">%s</span>\n")) |
|
2080 |
(org-export-data subtitle info)) |
|
2081 |
""))))) |
|
2082 |
contents |
|
2083 |
(format "</%s>\n" (nth 1 (assq 'content (plist-get info :html-divs)))) |
|
2084 |
;; Postamble. |
|
2085 |
(org-html--build-pre/postamble 'postamble info) |
|
2086 |
;; Possibly use the Klipse library live code blocks. |
|
2087 |
(if (plist-get info :html-klipsify-src) |
|
2088 |
(concat "<script>" (plist-get info :html-klipse-selection-script) |
|
2089 |
"</script><script src=\"" |
|
2090 |
org-html-klipse-js |
|
2091 |
"\"></script><link rel=\"stylesheet\" type=\"text/css\" href=\"" |
|
2092 |
org-html-klipse-css "\"/>")) |
|
2093 |
;; Closing document. |
|
2094 |
"</body>\n</html>")) |
|
2095 |
|
|
2096 |
(defun org-html--translate (s info) |
|
2097 |
"Translate string S according to specified language. |
|
2098 |
INFO is a plist used as a communication channel." |
|
2099 |
(org-export-translate s :html info)) |
|
2100 |
|
|
2101 |
;;;; Anchor |
|
2102 |
|
|
2103 |
(defun org-html--anchor (id desc attributes info) |
|
2104 |
"Format a HTML anchor." |
|
2105 |
(let* ((name (and (plist-get info :html-allow-name-attribute-in-anchors) id)) |
|
2106 |
(attributes (concat (and id (format " id=\"%s\"" id)) |
|
2107 |
(and name (format " name=\"%s\"" name)) |
|
2108 |
attributes))) |
|
2109 |
(format "<a%s>%s</a>" attributes (or desc "")))) |
|
2110 |
|
|
2111 |
;;;; Todo |
|
2112 |
|
|
2113 |
(defun org-html--todo (todo info) |
|
2114 |
"Format TODO keywords into HTML." |
|
2115 |
(when todo |
|
2116 |
(format "<span class=\"%s %s%s\">%s</span>" |
|
2117 |
(if (member todo org-done-keywords) "done" "todo") |
|
2118 |
(or (plist-get info :html-todo-kwd-class-prefix) "") |
|
2119 |
(org-html-fix-class-name todo) |
|
2120 |
todo))) |
|
2121 |
|
|
2122 |
;;;; Priority |
|
2123 |
|
|
2124 |
(defun org-html--priority (priority _info) |
|
2125 |
"Format a priority into HTML. |
|
2126 |
PRIORITY is the character code of the priority or nil. INFO is |
|
2127 |
a plist containing export options." |
|
2128 |
(and priority (format "<span class=\"priority\">[%c]</span>" priority))) |
|
2129 |
|
|
2130 |
;;;; Tags |
|
2131 |
|
|
2132 |
(defun org-html--tags (tags info) |
|
2133 |
"Format TAGS into HTML. |
|
2134 |
INFO is a plist containing export options." |
|
2135 |
(when tags |
|
2136 |
(format "<span class=\"tag\">%s</span>" |
|
2137 |
(mapconcat |
|
2138 |
(lambda (tag) |
|
2139 |
(format "<span class=\"%s\">%s</span>" |
|
2140 |
(concat (plist-get info :html-tag-class-prefix) |
|
2141 |
(org-html-fix-class-name tag)) |
|
2142 |
tag)) |
|
2143 |
tags " ")))) |
|
2144 |
|
|
2145 |
;;;; Src Code |
|
2146 |
|
|
2147 |
(defun org-html-fontify-code (code lang) |
|
2148 |
"Color CODE with htmlize library. |
|
2149 |
CODE is a string representing the source code to colorize. LANG |
|
2150 |
is the language used for CODE, as a string, or nil." |
|
2151 |
(when code |
|
2152 |
(cond |
|
2153 |
;; No language. Possibly an example block. |
|
2154 |
((not lang) (org-html-encode-plain-text code)) |
|
2155 |
;; Plain text explicitly set. |
|
2156 |
((not org-html-htmlize-output-type) (org-html-encode-plain-text code)) |
|
2157 |
;; No htmlize library or an inferior version of htmlize. |
|
2158 |
((not (and (or (require 'htmlize nil t) |
|
2159 |
(error "Please install htmlize from \ |
|
2160 |
https://github.com/hniksic/emacs-htmlize")) |
|
2161 |
(fboundp 'htmlize-region-for-paste))) |
|
2162 |
;; Emit a warning. |
|
2163 |
(message "Cannot fontify src block (htmlize.el >= 1.34 required)") |
|
2164 |
(org-html-encode-plain-text code)) |
|
2165 |
(t |
|
2166 |
;; Map language |
|
2167 |
(setq lang (or (assoc-default lang org-src-lang-modes) lang)) |
|
2168 |
(let* ((lang-mode (and lang (intern (format "%s-mode" lang))))) |
|
2169 |
(cond |
|
2170 |
;; Case 1: Language is not associated with any Emacs mode |
|
2171 |
((not (functionp lang-mode)) |
|
2172 |
(org-html-encode-plain-text code)) |
|
2173 |
;; Case 2: Default. Fontify code. |
|
2174 |
(t |
|
2175 |
;; htmlize |
|
2176 |
(setq code |
|
2177 |
(let ((output-type org-html-htmlize-output-type) |
|
2178 |
(font-prefix org-html-htmlize-font-prefix)) |
|
2179 |
(with-temp-buffer |
|
2180 |
;; Switch to language-specific mode. |
|
2181 |
(funcall lang-mode) |
|
2182 |
(insert code) |
|
2183 |
;; Fontify buffer. |
|
2184 |
(org-font-lock-ensure) |
|
2185 |
;; Remove formatting on newline characters. |
|
2186 |
(save-excursion |
|
2187 |
(let ((beg (point-min)) |
|
2188 |
(end (point-max))) |
|
2189 |
(goto-char beg) |
|
2190 |
(while (progn (end-of-line) (< (point) end)) |
|
2191 |
(put-text-property (point) (1+ (point)) 'face nil) |
|
2192 |
(forward-char 1)))) |
|
2193 |
(org-src-mode) |
|
2194 |
(set-buffer-modified-p nil) |
|
2195 |
;; Htmlize region. |
|
2196 |
(let ((org-html-htmlize-output-type output-type) |
|
2197 |
(org-html-htmlize-font-prefix font-prefix)) |
|
2198 |
(org-html-htmlize-region-for-paste |
|
2199 |
(point-min) (point-max)))))) |
|
2200 |
;; Strip any enclosing <pre></pre> tags. |
|
2201 |
(let* ((beg (and (string-match "\\`<pre[^>]*>\n?" code) (match-end 0))) |
|
2202 |
(end (and beg (string-match "</pre>\\'" code)))) |
|
2203 |
(if (and beg end) (substring code beg end) code))))))))) |
|
2204 |
|
|
2205 |
(defun org-html-do-format-code |
|
2206 |
(code &optional lang refs retain-labels num-start) |
|
2207 |
"Format CODE string as source code. |
|
2208 |
Optional arguments LANG, REFS, RETAIN-LABELS and NUM-START are, |
|
2209 |
respectively, the language of the source code, as a string, an |
|
2210 |
alist between line numbers and references (as returned by |
|
2211 |
`org-export-unravel-code'), a boolean specifying if labels should |
|
2212 |
appear in the source code, and the number associated to the first |
|
2213 |
line of code." |
|
2214 |
(let* ((code-lines (split-string code "\n")) |
|
2215 |
(code-length (length code-lines)) |
|
2216 |
(num-fmt |
|
2217 |
(and num-start |
|
2218 |
(format "%%%ds: " |
|
2219 |
(length (number-to-string (+ code-length num-start)))))) |
|
2220 |
(code (org-html-fontify-code code lang))) |
|
2221 |
(org-export-format-code |
|
2222 |
code |
|
2223 |
(lambda (loc line-num ref) |
|
2224 |
(setq loc |
|
2225 |
(concat |
|
2226 |
;; Add line number, if needed. |
|
2227 |
(when num-start |
|
2228 |
(format "<span class=\"linenr\">%s</span>" |
|
2229 |
(format num-fmt line-num))) |
|
2230 |
;; Transcoded src line. |
|
2231 |
loc |
|
2232 |
;; Add label, if needed. |
|
2233 |
(when (and ref retain-labels) (format " (%s)" ref)))) |
|
2234 |
;; Mark transcoded line as an anchor, if needed. |
|
2235 |
(if (not ref) loc |
|
2236 |
(format "<span id=\"coderef-%s\" class=\"coderef-off\">%s</span>" |
|
2237 |
ref loc))) |
|
2238 |
num-start refs))) |
|
2239 |
|
|
2240 |
(defun org-html-format-code (element info) |
|
2241 |
"Format contents of ELEMENT as source code. |
|
2242 |
ELEMENT is either an example block or a src block. INFO is |
|
2243 |
a plist used as a communication channel." |
|
2244 |
(let* ((lang (org-element-property :language element)) |
|
2245 |
;; Extract code and references. |
|
2246 |
(code-info (org-export-unravel-code element)) |
|
2247 |
(code (car code-info)) |
|
2248 |
(refs (cdr code-info)) |
|
2249 |
;; Does the src block contain labels? |
|
2250 |
(retain-labels (org-element-property :retain-labels element)) |
|
2251 |
;; Does it have line numbers? |
|
2252 |
(num-start (org-export-get-loc element info))) |
|
2253 |
(org-html-do-format-code code lang refs retain-labels num-start))) |
|
2254 |
|
|
2255 |
|
|
2256 |
;;; Tables of Contents |
|
2257 |
|
|
2258 |
(defun org-html-toc (depth info &optional scope) |
|
2259 |
"Build a table of contents. |
|
2260 |
DEPTH is an integer specifying the depth of the table. INFO is |
|
2261 |
a plist used as a communication channel. Optional argument SCOPE |
|
2262 |
is an element defining the scope of the table. Return the table |
|
2263 |
of contents as a string, or nil if it is empty." |
|
2264 |
(let ((toc-entries |
|
2265 |
(mapcar (lambda (headline) |
|
2266 |
(cons (org-html--format-toc-headline headline info) |
|
2267 |
(org-export-get-relative-level headline info))) |
|
2268 |
(org-export-collect-headlines info depth scope)))) |
|
2269 |
(when toc-entries |
|
2270 |
(let ((toc (concat "<div id=\"text-table-of-contents\">" |
|
2271 |
(org-html--toc-text toc-entries) |
|
2272 |
"</div>\n"))) |
|
2273 |
(if scope toc |
|
2274 |
(let ((outer-tag (if (org-html--html5-fancy-p info) |
|
2275 |
"nav" |
|
2276 |
"div"))) |
|
2277 |
(concat (format "<%s id=\"table-of-contents\">\n" outer-tag) |
|
2278 |
(let ((top-level (plist-get info :html-toplevel-hlevel))) |
|
2279 |
(format "<h%d>%s</h%d>\n" |
|
2280 |
top-level |
|
2281 |
(org-html--translate "Table of Contents" info) |
|
2282 |
top-level)) |
|
2283 |
toc |
|
2284 |
(format "</%s>\n" outer-tag)))))))) |
|
2285 |
|
|
2286 |
(defun org-html--toc-text (toc-entries) |
|
2287 |
"Return innards of a table of contents, as a string. |
|
2288 |
TOC-ENTRIES is an alist where key is an entry title, as a string, |
|
2289 |
and value is its relative level, as an integer." |
|
2290 |
(let* ((prev-level (1- (cdar toc-entries))) |
|
2291 |
(start-level prev-level)) |
|
2292 |
(concat |
|
2293 |
(mapconcat |
|
2294 |
(lambda (entry) |
|
2295 |
(let ((headline (car entry)) |
|
2296 |
(level (cdr entry))) |
|
2297 |
(concat |
|
2298 |
(let* ((cnt (- level prev-level)) |
|
2299 |
(times (if (> cnt 0) (1- cnt) (- cnt)))) |
|
2300 |
(setq prev-level level) |
|
2301 |
(concat |
|
2302 |
(org-html--make-string |
|
2303 |
times (cond ((> cnt 0) "\n<ul>\n<li>") |
|
2304 |
((< cnt 0) "</li>\n</ul>\n"))) |
|
2305 |
(if (> cnt 0) "\n<ul>\n<li>" "</li>\n<li>"))) |
|
2306 |
headline))) |
|
2307 |
toc-entries "") |
|
2308 |
(org-html--make-string (- prev-level start-level) "</li>\n</ul>\n")))) |
|
2309 |
|
|
2310 |
(defun org-html--format-toc-headline (headline info) |
|
2311 |
"Return an appropriate table of contents entry for HEADLINE. |
|
2312 |
INFO is a plist used as a communication channel." |
|
2313 |
(let* ((headline-number (org-export-get-headline-number headline info)) |
|
2314 |
(todo (and (plist-get info :with-todo-keywords) |
|
2315 |
(let ((todo (org-element-property :todo-keyword headline))) |
|
2316 |
(and todo (org-export-data todo info))))) |
|
2317 |
(todo-type (and todo (org-element-property :todo-type headline))) |
|
2318 |
(priority (and (plist-get info :with-priority) |
|
2319 |
(org-element-property :priority headline))) |
|
2320 |
(text (org-export-data-with-backend |
|
2321 |
(org-export-get-alt-title headline info) |
|
2322 |
(org-export-toc-entry-backend 'html) |
|
2323 |
info)) |
|
2324 |
(tags (and (eq (plist-get info :with-tags) t) |
|
2325 |
(org-export-get-tags headline info)))) |
|
2326 |
(format "<a href=\"#%s\">%s</a>" |
|
2327 |
;; Label. |
|
2328 |
(or (org-element-property :CUSTOM_ID headline) |
|
2329 |
(org-export-get-reference headline info)) |
|
2330 |
;; Body. |
|
2331 |
(concat |
|
2332 |
(and (not (org-export-low-level-p headline info)) |
|
2333 |
(org-export-numbered-headline-p headline info) |
|
2334 |
(concat (mapconcat #'number-to-string headline-number ".") |
|
2335 |
". ")) |
|
2336 |
(apply (plist-get info :html-format-headline-function) |
|
2337 |
todo todo-type priority text tags :section-number nil))))) |
|
2338 |
|
|
2339 |
(defun org-html-list-of-listings (info) |
|
2340 |
"Build a list of listings. |
|
2341 |
INFO is a plist used as a communication channel. Return the list |
|
2342 |
of listings as a string, or nil if it is empty." |
|
2343 |
(let ((lol-entries (org-export-collect-listings info))) |
|
2344 |
(when lol-entries |
|
2345 |
(concat "<div id=\"list-of-listings\">\n" |
|
2346 |
(let ((top-level (plist-get info :html-toplevel-hlevel))) |
|
2347 |
(format "<h%d>%s</h%d>\n" |
|
2348 |
top-level |
|
2349 |
(org-html--translate "List of Listings" info) |
|
2350 |
top-level)) |
|
2351 |
"<div id=\"text-list-of-listings\">\n<ul>\n" |
|
2352 |
(let ((count 0) |
|
2353 |
(initial-fmt (format "<span class=\"listing-number\">%s</span>" |
|
2354 |
(org-html--translate "Listing %d:" info)))) |
|
2355 |
(mapconcat |
|
2356 |
(lambda (entry) |
|
2357 |
(let ((label (and (org-element-property :name entry) |
|
2358 |
(org-export-get-reference entry info))) |
|
2359 |
(title (org-trim |
|
2360 |
(org-export-data |
|
2361 |
(or (org-export-get-caption entry t) |
|
2362 |
(org-export-get-caption entry)) |
|
2363 |
info)))) |
|
2364 |
(concat |
|
2365 |
"<li>" |
|
2366 |
(if (not label) |
|
2367 |
(concat (format initial-fmt (cl-incf count)) |
|
2368 |
" " |
|
2369 |
title) |
|
2370 |
(format "<a href=\"#%s\">%s %s</a>" |
|
2371 |
label |
|
2372 |
(format initial-fmt (cl-incf count)) |
|
2373 |
title)) |
|
2374 |
"</li>"))) |
|
2375 |
lol-entries "\n")) |
|
2376 |
"\n</ul>\n</div>\n</div>")))) |
|
2377 |
|
|
2378 |
(defun org-html-list-of-tables (info) |
|
2379 |
"Build a list of tables. |
|
2380 |
INFO is a plist used as a communication channel. Return the list |
|
2381 |
of tables as a string, or nil if it is empty." |
|
2382 |
(let ((lol-entries (org-export-collect-tables info))) |
|
2383 |
(when lol-entries |
|
2384 |
(concat "<div id=\"list-of-tables\">\n" |
|
2385 |
(let ((top-level (plist-get info :html-toplevel-hlevel))) |
|
2386 |
(format "<h%d>%s</h%d>\n" |
|
2387 |
top-level |
|
2388 |
(org-html--translate "List of Tables" info) |
|
2389 |
top-level)) |
|
2390 |
"<div id=\"text-list-of-tables\">\n<ul>\n" |
|
2391 |
(let ((count 0) |
|
2392 |
(initial-fmt (format "<span class=\"table-number\">%s</span>" |
|
2393 |
(org-html--translate "Table %d:" info)))) |
|
2394 |
(mapconcat |
|
2395 |
(lambda (entry) |
|
2396 |
(let ((label (and (org-element-property :name entry) |
|
2397 |
(org-export-get-reference entry info))) |
|
2398 |
(title (org-trim |
|
2399 |
(org-export-data |
|
2400 |
(or (org-export-get-caption entry t) |
|
2401 |
(org-export-get-caption entry)) |
|
2402 |
info)))) |
|
2403 |
(concat |
|
2404 |
"<li>" |
|
2405 |
(if (not label) |
|
2406 |
(concat (format initial-fmt (cl-incf count)) |
|
2407 |
" " |
|
2408 |
title) |
|
2409 |
(format "<a href=\"#%s\">%s %s</a>" |
|
2410 |
label |
|
2411 |
(format initial-fmt (cl-incf count)) |
|
2412 |
title)) |
|
2413 |
"</li>"))) |
|
2414 |
lol-entries "\n")) |
|
2415 |
"\n</ul>\n</div>\n</div>")))) |
|
2416 |
|
|
2417 |
|
|
2418 |
;;; Transcode Functions |
|
2419 |
|
|
2420 |
;;;; Bold |
|
2421 |
|
|
2422 |
(defun org-html-bold (_bold contents info) |
|
2423 |
"Transcode BOLD from Org to HTML. |
|
2424 |
CONTENTS is the text with bold markup. INFO is a plist holding |
|
2425 |
contextual information." |
|
2426 |
(format (or (cdr (assq 'bold (plist-get info :html-text-markup-alist))) "%s") |
|
2427 |
contents)) |
|
2428 |
|
|
2429 |
;;;; Center Block |
|
2430 |
|
|
2431 |
(defun org-html-center-block (_center-block contents _info) |
|
2432 |
"Transcode a CENTER-BLOCK element from Org to HTML. |
|
2433 |
CONTENTS holds the contents of the block. INFO is a plist |
|
2434 |
holding contextual information." |
|
2435 |
(format "<div class=\"org-center\">\n%s</div>" contents)) |
|
2436 |
|
|
2437 |
;;;; Clock |
|
2438 |
|
|
2439 |
(defun org-html-clock (clock _contents _info) |
|
2440 |
"Transcode a CLOCK element from Org to HTML. |
|
2441 |
CONTENTS is nil. INFO is a plist used as a communication |
|
2442 |
channel." |
|
2443 |
(format "<p> |
|
2444 |
<span class=\"timestamp-wrapper\"> |
|
2445 |
<span class=\"timestamp-kwd\">%s</span> <span class=\"timestamp\">%s</span>%s |
|
2446 |
</span> |
|
2447 |
</p>" |
|
2448 |
org-clock-string |
|
2449 |
(org-timestamp-translate (org-element-property :value clock)) |
|
2450 |
(let ((time (org-element-property :duration clock))) |
|
2451 |
(and time (format " <span class=\"timestamp\">(%s)</span>" time))))) |
|
2452 |
|
|
2453 |
;;;; Code |
|
2454 |
|
|
2455 |
(defun org-html-code (code _contents info) |
|
2456 |
"Transcode CODE from Org to HTML. |
|
2457 |
CONTENTS is nil. INFO is a plist holding contextual |
|
2458 |
information." |
|
2459 |
(format (or (cdr (assq 'code (plist-get info :html-text-markup-alist))) "%s") |
|
2460 |
(org-html-encode-plain-text (org-element-property :value code)))) |
|
2461 |
|
|
2462 |
;;;; Drawer |
|
2463 |
|
|
2464 |
(defun org-html-drawer (drawer contents info) |
|
2465 |
"Transcode a DRAWER element from Org to HTML. |
|
2466 |
CONTENTS holds the contents of the block. INFO is a plist |
|
2467 |
holding contextual information." |
|
2468 |
(funcall (plist-get info :html-format-drawer-function) |
|
2469 |
(org-element-property :drawer-name drawer) |
|
2470 |
contents)) |
|
2471 |
|
|
2472 |
;;;; Dynamic Block |
|
2473 |
|
|
2474 |
(defun org-html-dynamic-block (_dynamic-block contents _info) |
|
2475 |
"Transcode a DYNAMIC-BLOCK element from Org to HTML. |
|
2476 |
CONTENTS holds the contents of the block. INFO is a plist |
|
2477 |
holding contextual information. See `org-export-data'." |
|
2478 |
contents) |
|
2479 |
|
|
2480 |
;;;; Entity |
|
2481 |
|
|
2482 |
(defun org-html-entity (entity _contents _info) |
|
2483 |
"Transcode an ENTITY object from Org to HTML. |
|
2484 |
CONTENTS are the definition itself. INFO is a plist holding |
|
2485 |
contextual information." |
|
2486 |
(org-element-property :html entity)) |
|
2487 |
|
|
2488 |
;;;; Example Block |
|
2489 |
|
|
2490 |
(defun org-html-example-block (example-block _contents info) |
|
2491 |
"Transcode a EXAMPLE-BLOCK element from Org to HTML. |
|
2492 |
CONTENTS is nil. INFO is a plist holding contextual |
|
2493 |
information." |
|
2494 |
(let ((attributes (org-export-read-attribute :attr_html example-block))) |
|
2495 |
(if (plist-get attributes :textarea) |
|
2496 |
(org-html--textarea-block example-block) |
|
2497 |
(format "<pre class=\"example\"%s>\n%s</pre>" |
|
2498 |
(let* ((name (org-element-property :name example-block)) |
|
2499 |
(a (org-html--make-attribute-string |
|
2500 |
(if (or (not name) (plist-member attributes :id)) |
|
2501 |
attributes |
|
2502 |
(plist-put attributes :id name))))) |
|
2503 |
(if (org-string-nw-p a) (concat " " a) "")) |
|
2504 |
(org-html-format-code example-block info))))) |
|
2505 |
|
|
2506 |
;;;; Export Snippet |
|
2507 |
|
|
2508 |
(defun org-html-export-snippet (export-snippet _contents _info) |
|
2509 |
"Transcode a EXPORT-SNIPPET object from Org to HTML. |
|
2510 |
CONTENTS is nil. INFO is a plist holding contextual |
|
2511 |
information." |
|
2512 |
(when (eq (org-export-snippet-backend export-snippet) 'html) |
|
2513 |
(org-element-property :value export-snippet))) |
|
2514 |
|
|
2515 |
;;;; Export Block |
|
2516 |
|
|
2517 |
(defun org-html-export-block (export-block _contents _info) |
|
2518 |
"Transcode a EXPORT-BLOCK element from Org to HTML. |
|
2519 |
CONTENTS is nil. INFO is a plist holding contextual information." |
|
2520 |
(when (string= (org-element-property :type export-block) "HTML") |
|
2521 |
(org-remove-indentation (org-element-property :value export-block)))) |
|
2522 |
|
|
2523 |
;;;; Fixed Width |
|
2524 |
|
|
2525 |
(defun org-html-fixed-width (fixed-width _contents _info) |
|
2526 |
"Transcode a FIXED-WIDTH element from Org to HTML. |
|
2527 |
CONTENTS is nil. INFO is a plist holding contextual information." |
|
2528 |
(format "<pre class=\"example\">\n%s</pre>" |
|
2529 |
(org-html-do-format-code |
|
2530 |
(org-remove-indentation |
|
2531 |
(org-element-property :value fixed-width))))) |
|
2532 |
|
|
2533 |
;;;; Footnote Reference |
|
2534 |
|
|
2535 |
(defun org-html-footnote-reference (footnote-reference _contents info) |
|
2536 |
"Transcode a FOOTNOTE-REFERENCE element from Org to HTML. |
|
2537 |
CONTENTS is nil. INFO is a plist holding contextual information." |
|
2538 |
(concat |
|
2539 |
;; Insert separator between two footnotes in a row. |
|
2540 |
(let ((prev (org-export-get-previous-element footnote-reference info))) |
|
2541 |
(when (eq (org-element-type prev) 'footnote-reference) |
|
2542 |
(plist-get info :html-footnote-separator))) |
|
2543 |
(let* ((n (org-export-get-footnote-number footnote-reference info)) |
|
2544 |
(id (format "fnr.%d%s" |
|
2545 |
n |
|
2546 |
(if (org-export-footnote-first-reference-p |
|
2547 |
footnote-reference info) |
|
2548 |
"" |
|
2549 |
".100")))) |
|
2550 |
(format |
|
2551 |
(plist-get info :html-footnote-format) |
|
2552 |
(org-html--anchor |
|
2553 |
id n (format " class=\"footref\" href=\"#fn.%d\"" n) info))))) |
|
2554 |
|
|
2555 |
;;;; Headline |
|
2556 |
|
|
2557 |
(defun org-html-headline (headline contents info) |
|
2558 |
"Transcode a HEADLINE element from Org to HTML. |
|
2559 |
CONTENTS holds the contents of the headline. INFO is a plist |
|
2560 |
holding contextual information." |
|
2561 |
(unless (org-element-property :footnote-section-p headline) |
|
2562 |
(let* ((numberedp (org-export-numbered-headline-p headline info)) |
|
2563 |
(numbers (org-export-get-headline-number headline info)) |
|
2564 |
(level (+ (org-export-get-relative-level headline info) |
|
2565 |
(1- (plist-get info :html-toplevel-hlevel)))) |
|
2566 |
(todo (and (plist-get info :with-todo-keywords) |
|
2567 |
(let ((todo (org-element-property :todo-keyword headline))) |
|
2568 |
(and todo (org-export-data todo info))))) |
|
2569 |
(todo-type (and todo (org-element-property :todo-type headline))) |
|
2570 |
(priority (and (plist-get info :with-priority) |
|
2571 |
(org-element-property :priority headline))) |
|
2572 |
(text (org-export-data (org-element-property :title headline) info)) |
|
2573 |
(tags (and (plist-get info :with-tags) |
|
2574 |
(org-export-get-tags headline info))) |
|
2575 |
(full-text (funcall (plist-get info :html-format-headline-function) |
|
2576 |
todo todo-type priority text tags info)) |
|
2577 |
(contents (or contents "")) |
|
2578 |
(ids (delq nil |
|
2579 |
(list (org-element-property :CUSTOM_ID headline) |
|
2580 |
(org-export-get-reference headline info) |
|
2581 |
(org-element-property :ID headline)))) |
|
2582 |
(preferred-id (car ids)) |
|
2583 |
(extra-ids |
|
2584 |
(mapconcat |
|
2585 |
(lambda (id) |
|
2586 |
(org-html--anchor |
|
2587 |
(if (org-uuidgen-p id) (concat "ID-" id) id) |
|
2588 |
nil nil info)) |
|
2589 |
(cdr ids) ""))) |
|
2590 |
(if (org-export-low-level-p headline info) |
|
2591 |
;; This is a deep sub-tree: export it as a list item. |
|
2592 |
(let* ((html-type (if numberedp "ol" "ul"))) |
|
2593 |
(concat |
|
2594 |
(and (org-export-first-sibling-p headline info) |
|
2595 |
(apply #'format "<%s class=\"org-%s\">\n" |
|
2596 |
(make-list 2 html-type))) |
|
2597 |
(org-html-format-list-item |
|
2598 |
contents (if numberedp 'ordered 'unordered) |
|
2599 |
nil info nil |
|
2600 |
(concat (org-html--anchor preferred-id nil nil info) |
|
2601 |
extra-ids |
|
2602 |
full-text)) "\n" |
|
2603 |
(and (org-export-last-sibling-p headline info) |
|
2604 |
(format "</%s>\n" html-type)))) |
|
2605 |
;; Standard headline. Export it as a section. |
|
2606 |
(let ((extra-class (org-element-property :HTML_CONTAINER_CLASS headline)) |
|
2607 |
(first-content (car (org-element-contents headline)))) |
|
2608 |
(format "<%s id=\"%s\" class=\"%s\">%s%s</%s>\n" |
|
2609 |
(org-html--container headline info) |
|
2610 |
(concat "outline-container-" |
|
2611 |
(org-export-get-reference headline info)) |
|
2612 |
(concat (format "outline-%d" level) |
|
2613 |
(and extra-class " ") |
|
2614 |
extra-class) |
|
2615 |
(format "\n<h%d id=\"%s\">%s%s</h%d>\n" |
|
2616 |
level |
|
2617 |
preferred-id |
|
2618 |
extra-ids |
|
2619 |
(concat |
|
2620 |
(and numberedp |
|
2621 |
(format |
|
2622 |
"<span class=\"section-number-%d\">%s</span> " |
|
2623 |
level |
|
2624 |
(mapconcat #'number-to-string numbers "."))) |
|
2625 |
full-text) |
|
2626 |
level) |
|
2627 |
;; When there is no section, pretend there is an |
|
2628 |
;; empty one to get the correct <div |
|
2629 |
;; class="outline-...> which is needed by |
|
2630 |
;; `org-info.js'. |
|
2631 |
(if (eq (org-element-type first-content) 'section) contents |
|
2632 |
(concat (org-html-section first-content "" info) contents)) |
|
2633 |
(org-html--container headline info))))))) |
|
2634 |
|
|
2635 |
(defun org-html-format-headline-default-function |
|
2636 |
(todo _todo-type priority text tags info) |
|
2637 |
"Default format function for a headline. |
|
2638 |
See `org-html-format-headline-function' for details." |
|
2639 |
(let ((todo (org-html--todo todo info)) |
|
2640 |
(priority (org-html--priority priority info)) |
|
2641 |
(tags (org-html--tags tags info))) |
|
2642 |
(concat todo (and todo " ") |
|
2643 |
priority (and priority " ") |
|
2644 |
text |
|
2645 |
(and tags "   ") tags))) |
|
2646 |
|
|
2647 |
(defun org-html--container (headline info) |
|
2648 |
(or (org-element-property :HTML_CONTAINER headline) |
|
2649 |
(if (= 1 (org-export-get-relative-level headline info)) |
|
2650 |
(plist-get info :html-container) |
|
2651 |
"div"))) |
|
2652 |
|
|
2653 |
;;;; Horizontal Rule |
|
2654 |
|
|
2655 |
(defun org-html-horizontal-rule (_horizontal-rule _contents info) |
|
2656 |
"Transcode an HORIZONTAL-RULE object from Org to HTML. |
|
2657 |
CONTENTS is nil. INFO is a plist holding contextual information." |
|
2658 |
(org-html-close-tag "hr" nil info)) |
|
2659 |
|
|
2660 |
;;;; Inline Src Block |
|
2661 |
|
|
2662 |
(defun org-html-inline-src-block (inline-src-block _contents info) |
|
2663 |
"Transcode an INLINE-SRC-BLOCK element from Org to HTML. |
|
2664 |
CONTENTS holds the contents of the item. INFO is a plist holding |
|
2665 |
contextual information." |
|
2666 |
(let* ((lang (org-element-property :language inline-src-block)) |
|
2667 |
(code (org-html-fontify-code |
|
2668 |
(org-element-property :value inline-src-block) |
|
2669 |
lang)) |
|
2670 |
(label |
|
2671 |
(let ((lbl (and (org-element-property :name inline-src-block) |
|
2672 |
(org-export-get-reference inline-src-block info)))) |
|
2673 |
(if (not lbl) "" (format " id=\"%s\"" lbl))))) |
|
2674 |
(format "<code class=\"src src-%s\"%s>%s</code>" lang label code))) |
|
2675 |
|
|
2676 |
;;;; Inlinetask |
|
2677 |
|
|
2678 |
(defun org-html-inlinetask (inlinetask contents info) |
|
2679 |
"Transcode an INLINETASK element from Org to HTML. |
|
2680 |
CONTENTS holds the contents of the block. INFO is a plist |
|
2681 |
holding contextual information." |
|
2682 |
(let* ((todo (and (plist-get info :with-todo-keywords) |
|
2683 |
(let ((todo (org-element-property :todo-keyword inlinetask))) |
|
2684 |
(and todo (org-export-data todo info))))) |
|
2685 |
(todo-type (and todo (org-element-property :todo-type inlinetask))) |
|
2686 |
(priority (and (plist-get info :with-priority) |
|
2687 |
(org-element-property :priority inlinetask))) |
|
2688 |
(text (org-export-data (org-element-property :title inlinetask) info)) |
|
2689 |
(tags (and (plist-get info :with-tags) |
|
2690 |
(org-export-get-tags inlinetask info)))) |
|
2691 |
(funcall (plist-get info :html-format-inlinetask-function) |
|
2692 |
todo todo-type priority text tags contents info))) |
|
2693 |
|
|
2694 |
(defun org-html-format-inlinetask-default-function |
|
2695 |
(todo todo-type priority text tags contents info) |
|
2696 |
"Default format function for inlinetasks. |
|
2697 |
See `org-html-format-inlinetask-function' for details." |
|
2698 |
(format "<div class=\"inlinetask\">\n<b>%s</b>%s\n%s</div>" |
|
2699 |
(org-html-format-headline-default-function |
|
2700 |
todo todo-type priority text tags info) |
|
2701 |
(org-html-close-tag "br" nil info) |
|
2702 |
contents)) |
|
2703 |
|
|
2704 |
;;;; Italic |
|
2705 |
|
|
2706 |
(defun org-html-italic (_italic contents info) |
|
2707 |
"Transcode ITALIC from Org to HTML. |
|
2708 |
CONTENTS is the text with italic markup. INFO is a plist holding |
|
2709 |
contextual information." |
|
2710 |
(format |
|
2711 |
(or (cdr (assq 'italic (plist-get info :html-text-markup-alist))) "%s") |
|
2712 |
contents)) |
|
2713 |
|
|
2714 |
;;;; Item |
|
2715 |
|
|
2716 |
(defun org-html-checkbox (checkbox info) |
|
2717 |
"Format CHECKBOX into HTML. |
|
2718 |
INFO is a plist holding contextual information. See |
|
2719 |
`org-html-checkbox-type' for customization options." |
|
2720 |
(cdr (assq checkbox |
|
2721 |
(cdr (assq (plist-get info :html-checkbox-type) |
|
2722 |
org-html-checkbox-types))))) |
|
2723 |
|
|
2724 |
(defun org-html-format-list-item (contents type checkbox info |
|
2725 |
&optional term-counter-id |
|
2726 |
headline) |
|
2727 |
"Format a list item into HTML." |
|
2728 |
(let ((class (if checkbox |
|
2729 |
(format " class=\"%s\"" |
|
2730 |
(symbol-name checkbox)) "")) |
|
2731 |
(checkbox (concat (org-html-checkbox checkbox info) |
|
2732 |
(and checkbox " "))) |
|
2733 |
(br (org-html-close-tag "br" nil info)) |
|
2734 |
(extra-newline (if (and (org-string-nw-p contents) headline) "\n" ""))) |
|
2735 |
(concat |
|
2736 |
(pcase type |
|
2737 |
(`ordered |
|
2738 |
(let* ((counter term-counter-id) |
|
2739 |
(extra (if counter (format " value=\"%s\"" counter) ""))) |
|
2740 |
(concat |
|
2741 |
(format "<li%s%s>" class extra) |
|
2742 |
(when headline (concat headline br))))) |
|
2743 |
(`unordered |
|
2744 |
(let* ((id term-counter-id) |
|
2745 |
(extra (if id (format " id=\"%s\"" id) ""))) |
|
2746 |
(concat |
|
2747 |
(format "<li%s%s>" class extra) |
|
2748 |
(when headline (concat headline br))))) |
|
2749 |
(`descriptive |
|
2750 |
(let* ((term term-counter-id)) |
|
2751 |
(setq term (or term "(no term)")) |
|
2752 |
;; Check-boxes in descriptive lists are associated to tag. |
|
2753 |
(concat (format "<dt%s>%s</dt>" |
|
2754 |
class (concat checkbox term)) |
|
2755 |
"<dd>")))) |
|
2756 |
(unless (eq type 'descriptive) checkbox) |
|
2757 |
extra-newline |
|
2758 |
(and (org-string-nw-p contents) (org-trim contents)) |
|
2759 |
extra-newline |
|
2760 |
(pcase type |
|
2761 |
(`ordered "</li>") |
|
2762 |
(`unordered "</li>") |
|
2763 |
(`descriptive "</dd>"))))) |
|
2764 |
|
|
2765 |
(defun org-html-item (item contents info) |
|
2766 |
"Transcode an ITEM element from Org to HTML. |
|
2767 |
CONTENTS holds the contents of the item. INFO is a plist holding |
|
2768 |
contextual information." |
|
2769 |
(let* ((plain-list (org-export-get-parent item)) |
|
2770 |
(type (org-element-property :type plain-list)) |
|
2771 |
(counter (org-element-property :counter item)) |
|
2772 |
(checkbox (org-element-property :checkbox item)) |
|
2773 |
(tag (let ((tag (org-element-property :tag item))) |
|
2774 |
(and tag (org-export-data tag info))))) |
|
2775 |
(org-html-format-list-item |
|
2776 |
contents type checkbox info (or tag counter)))) |
|
2777 |
|
|
2778 |
;;;; Keyword |
|
2779 |
|
|
2780 |
(defun org-html-keyword (keyword _contents info) |
|
2781 |
"Transcode a KEYWORD element from Org to HTML. |
|
2782 |
CONTENTS is nil. INFO is a plist holding contextual information." |
|
2783 |
(let ((key (org-element-property :key keyword)) |
|
2784 |
(value (org-element-property :value keyword))) |
|
2785 |
(cond |
|
2786 |
((string= key "HTML") value) |
|
2787 |
((string= key "TOC") |
|
2788 |
(let ((case-fold-search t)) |
|
2789 |
(cond |
|
2790 |
((string-match "\\<headlines\\>" value) |
|
2791 |
(let ((depth (and (string-match "\\<[0-9]+\\>" value) |
|
2792 |
(string-to-number (match-string 0 value)))) |
|
2793 |
(localp (string-match-p "\\<local\\>" value))) |
|
2794 |
(org-html-toc depth info (and localp keyword)))) |
|
2795 |
((string= "listings" value) (org-html-list-of-listings info)) |
|
2796 |
((string= "tables" value) (org-html-list-of-tables info)))))))) |
|
2797 |
|
|
2798 |
;;;; Latex Environment |
|
2799 |
|
|
2800 |
(defun org-html-format-latex (latex-frag processing-type info) |
|
2801 |
"Format a LaTeX fragment LATEX-FRAG into HTML. |
|
2802 |
PROCESSING-TYPE designates the tool used for conversion. It can |
|
2803 |
be `mathjax', `verbatim', nil, t or symbols in |
|
2804 |
`org-preview-latex-process-alist', e.g., `dvipng', `dvisvgm' or |
|
2805 |
`imagemagick'. See `org-html-with-latex' for more information. |
|
2806 |
INFO is a plist containing export properties." |
|
2807 |
(let ((cache-relpath "") (cache-dir "")) |
|
2808 |
(unless (eq processing-type 'mathjax) |
|
2809 |
(let ((bfn (or (buffer-file-name) |
|
2810 |
(make-temp-name |
|
2811 |
(expand-file-name "latex" temporary-file-directory)))) |
|
2812 |
(latex-header |
|
2813 |
(let ((header (plist-get info :latex-header))) |
|
2814 |
(and header |
|
2815 |
(concat (mapconcat |
|
2816 |
(lambda (line) (concat "#+LATEX_HEADER: " line)) |
|
2817 |
(org-split-string header "\n") |
|
2818 |
"\n") |
|
2819 |
"\n"))))) |
|
2820 |
(setq cache-relpath |
|
2821 |
(concat (file-name-as-directory org-preview-latex-image-directory) |
|
2822 |
(file-name-sans-extension |
|
2823 |
(file-name-nondirectory bfn))) |
|
2824 |
cache-dir (file-name-directory bfn)) |
|
2825 |
;; Re-create LaTeX environment from original buffer in |
|
2826 |
;; temporary buffer so that dvipng/imagemagick can properly |
|
2827 |
;; turn the fragment into an image. |
|
2828 |
(setq latex-frag (concat latex-header latex-frag)))) |
|
2829 |
(with-temp-buffer |
|
2830 |
(insert latex-frag) |
|
2831 |
(org-format-latex cache-relpath nil nil cache-dir nil |
|
2832 |
"Creating LaTeX Image..." nil processing-type) |
|
2833 |
(buffer-string)))) |
|
2834 |
|
|
2835 |
(defun org-html-latex-environment (latex-environment _contents info) |
|
2836 |
"Transcode a LATEX-ENVIRONMENT element from Org to HTML. |
|
2837 |
CONTENTS is nil. INFO is a plist holding contextual information." |
|
2838 |
(let ((processing-type (plist-get info :with-latex)) |
|
2839 |
(latex-frag (org-remove-indentation |
|
2840 |
(org-element-property :value latex-environment))) |
|
2841 |
(attributes (org-export-read-attribute :attr_html latex-environment))) |
|
2842 |
(cond |
|
2843 |
((memq processing-type '(t mathjax)) |
|
2844 |
(org-html-format-latex latex-frag 'mathjax info)) |
|
2845 |
((assq processing-type org-preview-latex-process-alist) |
|
2846 |
(let ((formula-link |
|
2847 |
(org-html-format-latex latex-frag processing-type info))) |
|
2848 |
(when (and formula-link (string-match "file:\\([^]]*\\)" formula-link)) |
|
2849 |
;; Do not provide a caption or a name to be consistent with |
|
2850 |
;; `mathjax' handling. |
|
2851 |
(org-html--wrap-image |
|
2852 |
(org-html--format-image |
|
2853 |
(match-string 1 formula-link) attributes info) info)))) |
|
2854 |
(t latex-frag)))) |
|
2855 |
|
|
2856 |
;;;; Latex Fragment |
|
2857 |
|
|
2858 |
(defun org-html-latex-fragment (latex-fragment _contents info) |
|
2859 |
"Transcode a LATEX-FRAGMENT object from Org to HTML. |
|
2860 |
CONTENTS is nil. INFO is a plist holding contextual information." |
|
2861 |
(let ((latex-frag (org-element-property :value latex-fragment)) |
|
2862 |
(processing-type (plist-get info :with-latex))) |
|
2863 |
(cond |
|
2864 |
((memq processing-type '(t mathjax)) |
|
2865 |
(org-html-format-latex latex-frag 'mathjax info)) |
|
2866 |
((assq processing-type org-preview-latex-process-alist) |
|
2867 |
(let ((formula-link |
|
2868 |
(org-html-format-latex latex-frag processing-type info))) |
|
2869 |
(when (and formula-link (string-match "file:\\([^]]*\\)" formula-link)) |
|
2870 |
(org-html--format-image (match-string 1 formula-link) nil info)))) |
|
2871 |
(t latex-frag)))) |
|
2872 |
|
|
2873 |
;;;; Line Break |
|
2874 |
|
|
2875 |
(defun org-html-line-break (_line-break _contents info) |
|
2876 |
"Transcode a LINE-BREAK object from Org to HTML. |
|
2877 |
CONTENTS is nil. INFO is a plist holding contextual information." |
|
2878 |
(concat (org-html-close-tag "br" nil info) "\n")) |
|
2879 |
|
|
2880 |
;;;; Link |
|
2881 |
|
|
2882 |
(defun org-html-image-link-filter (data _backend info) |
|
2883 |
(org-export-insert-image-links data info org-html-inline-image-rules)) |
|
2884 |
|
|
2885 |
(defun org-html-inline-image-p (link info) |
|
2886 |
"Non-nil when LINK is meant to appear as an image. |
|
2887 |
INFO is a plist used as a communication channel. LINK is an |
|
2888 |
inline image when it has no description and targets an image |
|
2889 |
file (see `org-html-inline-image-rules' for more information), or |
|
2890 |
if its description is a single link targeting an image file." |
|
2891 |
(if (not (org-element-contents link)) |
|
2892 |
(org-export-inline-image-p |
|
2893 |
link (plist-get info :html-inline-image-rules)) |
|
2894 |
(not |
|
2895 |
(let ((link-count 0)) |
|
2896 |
(org-element-map (org-element-contents link) |
|
2897 |
(cons 'plain-text org-element-all-objects) |
|
2898 |
(lambda (obj) |
|
2899 |
(pcase (org-element-type obj) |
|
2900 |
(`plain-text (org-string-nw-p obj)) |
|
2901 |
(`link (if (= link-count 1) t |
|
2902 |
(cl-incf link-count) |
|
2903 |
(not (org-export-inline-image-p |
|
2904 |
obj (plist-get info :html-inline-image-rules))))) |
|
2905 |
(_ t))) |
|
2906 |
info t))))) |
|
2907 |
|
|
2908 |
(defvar org-html-standalone-image-predicate) |
|
2909 |
(defun org-html-standalone-image-p (element info) |
|
2910 |
"Non-nil if ELEMENT is a standalone image. |
|
2911 |
|
|
2912 |
INFO is a plist holding contextual information. |
|
2913 |
|
|
2914 |
An element or object is a standalone image when |
|
2915 |
|
|
2916 |
- its type is `paragraph' and its sole content, save for white |
|
2917 |
spaces, is a link that qualifies as an inline image; |
|
2918 |
|
|
2919 |
- its type is `link' and its containing paragraph has no other |
|
2920 |
content save white spaces. |
|
2921 |
|
|
2922 |
Bind `org-html-standalone-image-predicate' to constrain paragraph |
|
2923 |
further. For example, to check for only captioned standalone |
|
2924 |
images, set it to: |
|
2925 |
|
|
2926 |
(lambda (paragraph) (org-element-property :caption paragraph))" |
|
2927 |
(let ((paragraph (pcase (org-element-type element) |
|
2928 |
(`paragraph element) |
|
2929 |
(`link (org-export-get-parent element))))) |
|
2930 |
(and (eq (org-element-type paragraph) 'paragraph) |
|
2931 |
(or (not (fboundp 'org-html-standalone-image-predicate)) |
|
2932 |
(funcall org-html-standalone-image-predicate paragraph)) |
|
2933 |
(catch 'exit |
|
2934 |
(let ((link-count 0)) |
|
2935 |
(org-element-map (org-element-contents paragraph) |
|
2936 |
(cons 'plain-text org-element-all-objects) |
|
2937 |
(lambda (obj) |
|
2938 |
(when (pcase (org-element-type obj) |
|
2939 |
(`plain-text (org-string-nw-p obj)) |
|
2940 |
(`link (or (> (cl-incf link-count) 1) |
|
2941 |
(not (org-html-inline-image-p obj info)))) |
|
2942 |
(_ t)) |
|
2943 |
(throw 'exit nil))) |
|
2944 |
info nil 'link) |
|
2945 |
(= link-count 1)))))) |
|
2946 |
|
|
2947 |
(defun org-html-link (link desc info) |
|
2948 |
"Transcode a LINK object from Org to HTML. |
|
2949 |
DESC is the description part of the link, or the empty string. |
|
2950 |
INFO is a plist holding contextual information. See |
|
2951 |
`org-export-data'." |
|
2952 |
(let* ((link-org-files-as-html-maybe |
|
2953 |
(lambda (raw-path info) |
|
2954 |
;; Treat links to `file.org' as links to `file.html', if |
|
2955 |
;; needed. See `org-html-link-org-files-as-html'. |
|
2956 |
(cond |
|
2957 |
((and (plist-get info :html-link-org-files-as-html) |
|
2958 |
(string= ".org" |
|
2959 |
(downcase (file-name-extension raw-path ".")))) |
|
2960 |
(concat (file-name-sans-extension raw-path) "." |
|
2961 |
(plist-get info :html-extension))) |
|
2962 |
(t raw-path)))) |
|
2963 |
(type (org-element-property :type link)) |
|
2964 |
(raw-path (org-element-property :path link)) |
|
2965 |
;; Ensure DESC really exists, or set it to nil. |
|
2966 |
(desc (org-string-nw-p desc)) |
|
2967 |
(path |
|
2968 |
(cond |
|
2969 |
((member type '("http" "https" "ftp" "mailto" "news")) |
|
2970 |
(url-encode-url (org-link-unescape (concat type ":" raw-path)))) |
|
2971 |
((string= type "file") |
|
2972 |
;; During publishing, turn absolute file names belonging |
|
2973 |
;; to base directory into relative file names. Otherwise, |
|
2974 |
;; append "file" protocol to absolute file name. |
|
2975 |
(setq raw-path |
|
2976 |
(org-export-file-uri |
|
2977 |
(org-publish-file-relative-name raw-path info))) |
|
2978 |
;; Possibly append `:html-link-home' to relative file |
|
2979 |
;; name. |
|
2980 |
(let ((home (and (plist-get info :html-link-home) |
|
2981 |
(org-trim (plist-get info :html-link-home))))) |
|
2982 |
(when (and home |
|
2983 |
(plist-get info :html-link-use-abs-url) |
|
2984 |
(file-name-absolute-p raw-path)) |
|
2985 |
(setq raw-path (concat (file-name-as-directory home) raw-path)))) |
|
2986 |
;; Maybe turn ".org" into ".html". |
|
2987 |
(setq raw-path (funcall link-org-files-as-html-maybe raw-path info)) |
|
2988 |
;; Add search option, if any. A search option can be |
|
2989 |
;; relative to a custom-id, a headline title, a name or |
|
2990 |
;; a target. |
|
2991 |
(let ((option (org-element-property :search-option link))) |
|
2992 |
(cond ((not option) raw-path) |
|
2993 |
;; Since HTML back-end use custom-id value as-is, |
|
2994 |
;; resolving is them is trivial. |
|
2995 |
((eq (string-to-char option) ?#) (concat raw-path option)) |
|
2996 |
(t |
|
2997 |
(concat raw-path |
|
2998 |
"#" |
|
2999 |
(org-publish-resolve-external-link |
|
3000 |
option |
|
3001 |
(org-element-property :path link))))))) |
|
3002 |
(t raw-path))) |
|
3003 |
;; Extract attributes from parent's paragraph. HACK: Only do |
|
3004 |
;; this for the first link in parent (inner image link for |
|
3005 |
;; inline images). This is needed as long as attributes |
|
3006 |
;; cannot be set on a per link basis. |
|
3007 |
(attributes-plist |
|
3008 |
(let* ((parent (org-export-get-parent-element link)) |
|
3009 |
(link (let ((container (org-export-get-parent link))) |
|
3010 |
(if (and (eq (org-element-type container) 'link) |
|
3011 |
(org-html-inline-image-p link info)) |
|
3012 |
container |
|
3013 |
link)))) |
|
3014 |
(and (eq (org-element-map parent 'link 'identity info t) link) |
|
3015 |
(org-export-read-attribute :attr_html parent)))) |
|
3016 |
(attributes |
|
3017 |
(let ((attr (org-html--make-attribute-string attributes-plist))) |
|
3018 |
(if (org-string-nw-p attr) (concat " " attr) "")))) |
|
3019 |
(cond |
|
3020 |
;; Link type is handled by a special function. |
|
3021 |
((org-export-custom-protocol-maybe link desc 'html)) |
|
3022 |
;; Image file. |
|
3023 |
((and (plist-get info :html-inline-images) |
|
3024 |
(org-export-inline-image-p |
|
3025 |
link (plist-get info :html-inline-image-rules))) |
|
3026 |
(org-html--format-image path attributes-plist info)) |
|
3027 |
;; Radio target: Transcode target's contents and use them as |
|
3028 |
;; link's description. |
|
3029 |
((string= type "radio") |
|
3030 |
(let ((destination (org-export-resolve-radio-link link info))) |
|
3031 |
(if (not destination) desc |
|
3032 |
(format "<a href=\"#%s\"%s>%s</a>" |
|
3033 |
(org-export-get-reference destination info) |
|
3034 |
attributes |
|
3035 |
desc)))) |
|
3036 |
;; Links pointing to a headline: Find destination and build |
|
3037 |
;; appropriate referencing command. |
|
3038 |
((member type '("custom-id" "fuzzy" "id")) |
|
3039 |
(let ((destination (if (string= type "fuzzy") |
|
3040 |
(org-export-resolve-fuzzy-link link info) |
|
3041 |
(org-export-resolve-id-link link info)))) |
|
3042 |
(pcase (org-element-type destination) |
|
3043 |
;; ID link points to an external file. |
|
3044 |
(`plain-text |
|
3045 |
(let ((fragment (concat "ID-" path)) |
|
3046 |
;; Treat links to ".org" files as ".html", if needed. |
|
3047 |
(path (funcall link-org-files-as-html-maybe |
|
3048 |
destination info))) |
|
3049 |
(format "<a href=\"%s#%s\"%s>%s</a>" |
|
3050 |
path fragment attributes (or desc destination)))) |
|
3051 |
;; Fuzzy link points nowhere. |
|
3052 |
(`nil |
|
3053 |
(format "<i>%s</i>" |
|
3054 |
(or desc |
|
3055 |
(org-export-data |
|
3056 |
(org-element-property :raw-link link) info)))) |
|
3057 |
;; Link points to a headline. |
|
3058 |
(`headline |
|
3059 |
(let ((href (or (org-element-property :CUSTOM_ID destination) |
|
3060 |
(org-export-get-reference destination info))) |
|
3061 |
;; What description to use? |
|
3062 |
(desc |
|
3063 |
;; Case 1: Headline is numbered and LINK has no |
|
3064 |
;; description. Display section number. |
|
3065 |
(if (and (org-export-numbered-headline-p destination info) |
|
3066 |
(not desc)) |
|
3067 |
(mapconcat #'number-to-string |
|
3068 |
(org-export-get-headline-number |
|
3069 |
destination info) ".") |
|
3070 |
;; Case 2: Either the headline is un-numbered or |
|
3071 |
;; LINK has a custom description. Display LINK's |
|
3072 |
;; description or headline's title. |
|
3073 |
(or desc |
|
3074 |
(org-export-data |
|
3075 |
(org-element-property :title destination) info))))) |
|
3076 |
(format "<a href=\"#%s\"%s>%s</a>" href attributes desc))) |
|
3077 |
;; Fuzzy link points to a target or an element. |
|
3078 |
(_ |
|
3079 |
(let* ((ref (org-export-get-reference destination info)) |
|
3080 |
(org-html-standalone-image-predicate |
|
3081 |
#'org-html--has-caption-p) |
|
3082 |
(number (cond |
|
3083 |
(desc nil) |
|
3084 |
((org-html-standalone-image-p destination info) |
|
3085 |
(org-export-get-ordinal |
|
3086 |
(org-element-map destination 'link |
|
3087 |
#'identity info t) |
|
3088 |
info 'link 'org-html-standalone-image-p)) |
|
3089 |
(t (org-export-get-ordinal |
|
3090 |
destination info nil 'org-html--has-caption-p)))) |
|
3091 |
(desc (cond (desc) |
|
3092 |
((not number) "No description for this link") |
|
3093 |
((numberp number) (number-to-string number)) |
|
3094 |
(t (mapconcat #'number-to-string number "."))))) |
|
3095 |
(format "<a href=\"#%s\"%s>%s</a>" ref attributes desc)))))) |
|
3096 |
;; Coderef: replace link with the reference name or the |
|
3097 |
;; equivalent line number. |
|
3098 |
((string= type "coderef") |
|
3099 |
(let ((fragment (concat "coderef-" (org-html-encode-plain-text path)))) |
|
3100 |
(format "<a href=\"#%s\" %s%s>%s</a>" |
|
3101 |
fragment |
|
3102 |
(format "class=\"coderef\" onmouseover=\"CodeHighlightOn(this, \ |
|
3103 |
'%s');\" onmouseout=\"CodeHighlightOff(this, '%s');\"" |
|
3104 |
fragment fragment) |
|
3105 |
attributes |
|
3106 |
(format (org-export-get-coderef-format path desc) |
|
3107 |
(org-export-resolve-coderef path info))))) |
|
3108 |
;; External link with a description part. |
|
3109 |
((and path desc) (format "<a href=\"%s\"%s>%s</a>" |
|
3110 |
(org-html-encode-plain-text path) |
|
3111 |
attributes |
|
3112 |
desc)) |
|
3113 |
;; External link without a description part. |
|
3114 |
(path (let ((path (org-html-encode-plain-text path))) |
|
3115 |
(format "<a href=\"%s\"%s>%s</a>" |
|
3116 |
path |
|
3117 |
attributes |
|
3118 |
(org-link-unescape path)))) |
|
3119 |
;; No path, only description. Try to do something useful. |
|
3120 |
(t (format "<i>%s</i>" desc))))) |
|
3121 |
|
|
3122 |
;;;; Node Property |
|
3123 |
|
|
3124 |
(defun org-html-node-property (node-property _contents _info) |
|
3125 |
"Transcode a NODE-PROPERTY element from Org to HTML. |
|
3126 |
CONTENTS is nil. INFO is a plist holding contextual |
|
3127 |
information." |
|
3128 |
(format "%s:%s" |
|
3129 |
(org-element-property :key node-property) |
|
3130 |
(let ((value (org-element-property :value node-property))) |
|
3131 |
(if value (concat " " value) "")))) |
|
3132 |
|
|
3133 |
;;;; Paragraph |
|
3134 |
|
|
3135 |
(defun org-html-paragraph (paragraph contents info) |
|
3136 |
"Transcode a PARAGRAPH element from Org to HTML. |
|
3137 |
CONTENTS is the contents of the paragraph, as a string. INFO is |
|
3138 |
the plist used as a communication channel." |
|
3139 |
(let* ((parent (org-export-get-parent paragraph)) |
|
3140 |
(parent-type (org-element-type parent)) |
|
3141 |
(style '((footnote-definition " class=\"footpara\"") |
|
3142 |
(org-data " class=\"footpara\""))) |
|
3143 |
(attributes (org-html--make-attribute-string |
|
3144 |
(org-export-read-attribute :attr_html paragraph))) |
|
3145 |
(extra (or (cadr (assq parent-type style)) ""))) |
|
3146 |
(cond |
|
3147 |
((and (eq parent-type 'item) |
|
3148 |
(not (org-export-get-previous-element paragraph info)) |
|
3149 |
(let ((followers (org-export-get-next-element paragraph info 2))) |
|
3150 |
(and (not (cdr followers)) |
|
3151 |
(memq (org-element-type (car followers)) '(nil plain-list))))) |
|
3152 |
;; First paragraph in an item has no tag if it is alone or |
|
3153 |
;; followed, at most, by a sub-list. |
|
3154 |
contents) |
|
3155 |
((org-html-standalone-image-p paragraph info) |
|
3156 |
;; Standalone image. |
|
3157 |
(let ((caption |
|
3158 |
(let ((raw (org-export-data |
|
3159 |
(org-export-get-caption paragraph) info)) |
|
3160 |
(org-html-standalone-image-predicate |
|
3161 |
#'org-html--has-caption-p)) |
|
3162 |
(if (not (org-string-nw-p raw)) raw |
|
3163 |
(concat "<span class=\"figure-number\">" |
|
3164 |
(format (org-html--translate "Figure %d:" info) |
|
3165 |
(org-export-get-ordinal |
|
3166 |
(org-element-map paragraph 'link |
|
3167 |
#'identity info t) |
|
3168 |
info nil #'org-html-standalone-image-p)) |
|
3169 |
" </span>" |
|
3170 |
raw)))) |
|
3171 |
(label (and (org-element-property :name paragraph) |
|
3172 |
(org-export-get-reference paragraph info)))) |
|
3173 |
(org-html--wrap-image contents info caption label))) |
|
3174 |
;; Regular paragraph. |
|
3175 |
(t (format "<p%s%s>\n%s</p>" |
|
3176 |
(if (org-string-nw-p attributes) |
|
3177 |
(concat " " attributes) "") |
|
3178 |
extra contents))))) |
|
3179 |
|
|
3180 |
;;;; Plain List |
|
3181 |
|
|
3182 |
(defun org-html-plain-list (plain-list contents _info) |
|
3183 |
"Transcode a PLAIN-LIST element from Org to HTML. |
|
3184 |
CONTENTS is the contents of the list. INFO is a plist holding |
|
3185 |
contextual information." |
|
3186 |
(let* ((type (pcase (org-element-property :type plain-list) |
|
3187 |
(`ordered "ol") |
|
3188 |
(`unordered "ul") |
|
3189 |
(`descriptive "dl") |
|
3190 |
(other (error "Unknown HTML list type: %s" other)))) |
|
3191 |
(class (format "org-%s" type)) |
|
3192 |
(attributes (org-export-read-attribute :attr_html plain-list))) |
|
3193 |
(format "<%s %s>\n%s</%s>" |
|
3194 |
type |
|
3195 |
(org-html--make-attribute-string |
|
3196 |
(plist-put attributes :class |
|
3197 |
(org-trim |
|
3198 |
(mapconcat #'identity |
|
3199 |
(list class (plist-get attributes :class)) |
|
3200 |
" ")))) |
|
3201 |
contents |
|
3202 |
type))) |
|
3203 |
|
|
3204 |
;;;; Plain Text |
|
3205 |
|
|
3206 |
(defun org-html-convert-special-strings (string) |
|
3207 |
"Convert special characters in STRING to HTML." |
|
3208 |
(dolist (a org-html-special-string-regexps string) |
|
3209 |
(let ((re (car a)) |
|
3210 |
(rpl (cdr a))) |
|
3211 |
(setq string (replace-regexp-in-string re rpl string t))))) |
|
3212 |
|
|
3213 |
(defun org-html-encode-plain-text (text) |
|
3214 |
"Convert plain text characters from TEXT to HTML equivalent. |
|
3215 |
Possible conversions are set in `org-html-protect-char-alist'." |
|
3216 |
(dolist (pair org-html-protect-char-alist text) |
|
3217 |
(setq text (replace-regexp-in-string (car pair) (cdr pair) text t t)))) |
|
3218 |
|
|
3219 |
(defun org-html-plain-text (text info) |
|
3220 |
"Transcode a TEXT string from Org to HTML. |
|
3221 |
TEXT is the string to transcode. INFO is a plist holding |
|
3222 |
contextual information." |
|
3223 |
(let ((output text)) |
|
3224 |
;; Protect following characters: <, >, &. |
|
3225 |
(setq output (org-html-encode-plain-text output)) |
|
3226 |
;; Handle smart quotes. Be sure to provide original string since |
|
3227 |
;; OUTPUT may have been modified. |
|
3228 |
(when (plist-get info :with-smart-quotes) |
|
3229 |
(setq output (org-export-activate-smart-quotes output :html info text))) |
|
3230 |
;; Handle special strings. |
|
3231 |
(when (plist-get info :with-special-strings) |
|
3232 |
(setq output (org-html-convert-special-strings output))) |
|
3233 |
;; Handle break preservation if required. |
|
3234 |
(when (plist-get info :preserve-breaks) |
|
3235 |
(setq output |
|
3236 |
(replace-regexp-in-string |
|
3237 |
"\\(\\\\\\\\\\)?[ \t]*\n" |
|
3238 |
(concat (org-html-close-tag "br" nil info) "\n") output))) |
|
3239 |
;; Return value. |
|
3240 |
output)) |
|
3241 |
|
|
3242 |
|
|
3243 |
;; Planning |
|
3244 |
|
|
3245 |
(defun org-html-planning (planning _contents info) |
|
3246 |
"Transcode a PLANNING element from Org to HTML. |
|
3247 |
CONTENTS is nil. INFO is a plist used as a communication |
|
3248 |
channel." |
|
3249 |
(format |
|
3250 |
"<p><span class=\"timestamp-wrapper\">%s</span></p>" |
|
3251 |
(org-trim |
|
3252 |
(mapconcat |
|
3253 |
(lambda (pair) |
|
3254 |
(let ((timestamp (cdr pair))) |
|
3255 |
(when timestamp |
|
3256 |
(let ((string (car pair))) |
|
3257 |
(format "<span class=\"timestamp-kwd\">%s</span> \ |
|
3258 |
<span class=\"timestamp\">%s</span> " |
|
3259 |
string |
|
3260 |
(org-html-plain-text (org-timestamp-translate timestamp) |
|
3261 |
info)))))) |
|
3262 |
`((,org-closed-string . ,(org-element-property :closed planning)) |
|
3263 |
(,org-deadline-string . ,(org-element-property :deadline planning)) |
|
3264 |
(,org-scheduled-string . ,(org-element-property :scheduled planning))) |
|
3265 |
"")))) |
|
3266 |
|
|
3267 |
;;;; Property Drawer |
|
3268 |
|
|
3269 |
(defun org-html-property-drawer (_property-drawer contents _info) |
|
3270 |
"Transcode a PROPERTY-DRAWER element from Org to HTML. |
|
3271 |
CONTENTS holds the contents of the drawer. INFO is a plist |
|
3272 |
holding contextual information." |
|
3273 |
(and (org-string-nw-p contents) |
|
3274 |
(format "<pre class=\"example\">\n%s</pre>" contents))) |
|
3275 |
|
|
3276 |
;;;; Quote Block |
|
3277 |
|
|
3278 |
(defun org-html-quote-block (quote-block contents _info) |
|
3279 |
"Transcode a QUOTE-BLOCK element from Org to HTML. |
|
3280 |
CONTENTS holds the contents of the block. INFO is a plist |
|
3281 |
holding contextual information." |
|
3282 |
(format "<blockquote%s>\n%s</blockquote>" |
|
3283 |
(let* ((name (org-element-property :name quote-block)) |
|
3284 |
(attributes (org-export-read-attribute :attr_html quote-block)) |
|
3285 |
(a (org-html--make-attribute-string |
|
3286 |
(if (or (not name) (plist-member attributes :id)) |
|
3287 |
attributes |
|
3288 |
(plist-put attributes :id name))))) |
|
3289 |
(if (org-string-nw-p a) (concat " " a) "")) |
|
3290 |
contents)) |
|
3291 |
|
|
3292 |
;;;; Section |
|
3293 |
|
|
3294 |
(defun org-html-section (section contents info) |
|
3295 |
"Transcode a SECTION element from Org to HTML. |
|
3296 |
CONTENTS holds the contents of the section. INFO is a plist |
|
3297 |
holding contextual information." |
|
3298 |
(let ((parent (org-export-get-parent-headline section))) |
|
3299 |
;; Before first headline: no container, just return CONTENTS. |
|
3300 |
(if (not parent) contents |
|
3301 |
;; Get div's class and id references. |
|
3302 |
(let* ((class-num (+ (org-export-get-relative-level parent info) |
|
3303 |
(1- (plist-get info :html-toplevel-hlevel)))) |
|
3304 |
(section-number |
|
3305 |
(and (org-export-numbered-headline-p parent info) |
|
3306 |
(mapconcat |
|
3307 |
#'number-to-string |
|
3308 |
(org-export-get-headline-number parent info) "-")))) |
|
3309 |
;; Build return value. |
|
3310 |
(format "<div class=\"outline-text-%d\" id=\"text-%s\">\n%s</div>\n" |
|
3311 |
class-num |
|
3312 |
(or (org-element-property :CUSTOM_ID parent) |
|
3313 |
section-number |
|
3314 |
(org-export-get-reference parent info)) |
|
3315 |
(or contents "")))))) |
|
3316 |
|
|
3317 |
;;;; Radio Target |
|
3318 |
|
|
3319 |
(defun org-html-radio-target (radio-target text info) |
|
3320 |
"Transcode a RADIO-TARGET object from Org to HTML. |
|
3321 |
TEXT is the text of the target. INFO is a plist holding |
|
3322 |
contextual information." |
|
3323 |
(let ((ref (org-export-get-reference radio-target info))) |
|
3324 |
(org-html--anchor ref text nil info))) |
|
3325 |
|
|
3326 |
;;;; Special Block |
|
3327 |
|
|
3328 |
(defun org-html-special-block (special-block contents info) |
|
3329 |
"Transcode a SPECIAL-BLOCK element from Org to HTML. |
|
3330 |
CONTENTS holds the contents of the block. INFO is a plist |
|
3331 |
holding contextual information." |
|
3332 |
(let* ((block-type (org-element-property :type special-block)) |
|
3333 |
(html5-fancy (and (org-html--html5-fancy-p info) |
|
3334 |
(member block-type org-html-html5-elements))) |
|
3335 |
(attributes (org-export-read-attribute :attr_html special-block))) |
|
3336 |
(unless html5-fancy |
|
3337 |
(let ((class (plist-get attributes :class))) |
|
3338 |
(setq attributes (plist-put attributes :class |
|
3339 |
(if class (concat class " " block-type) |
|
3340 |
block-type))))) |
|
3341 |
(let* ((contents (or contents "")) |
|
3342 |
(name (org-element-property :name special-block)) |
|
3343 |
(a (org-html--make-attribute-string |
|
3344 |
(if (or (not name) (plist-member attributes :id)) |
|
3345 |
attributes |
|
3346 |
(plist-put attributes :id name)))) |
|
3347 |
(str (if (org-string-nw-p a) (concat " " a) ""))) |
|
3348 |
(if html5-fancy |
|
3349 |
(format "<%s%s>\n%s</%s>" block-type str contents block-type) |
|
3350 |
(format "<div%s>\n%s\n</div>" str contents))))) |
|
3351 |
|
|
3352 |
;;;; Src Block |
|
3353 |
|
|
3354 |
(defun org-html-src-block (src-block _contents info) |
|
3355 |
"Transcode a SRC-BLOCK element from Org to HTML. |
|
3356 |
CONTENTS holds the contents of the item. INFO is a plist holding |
|
3357 |
contextual information." |
|
3358 |
(if (org-export-read-attribute :attr_html src-block :textarea) |
|
3359 |
(org-html--textarea-block src-block) |
|
3360 |
(let* ((lang (org-element-property :language src-block)) |
|
3361 |
(code (org-html-format-code src-block info)) |
|
3362 |
(label (let ((lbl (and (org-element-property :name src-block) |
|
3363 |
(org-export-get-reference src-block info)))) |
|
3364 |
(if lbl (format " id=\"%s\"" lbl) ""))) |
|
3365 |
(klipsify (and (plist-get info :html-klipsify-src) |
|
3366 |
(member lang '("javascript" "js" |
|
3367 |
"ruby" "scheme" "clojure" "php" "html"))))) |
|
3368 |
(if (not lang) (format "<pre class=\"example\"%s>\n%s</pre>" label code) |
|
3369 |
(format "<div class=\"org-src-container\">\n%s%s\n</div>" |
|
3370 |
;; Build caption. |
|
3371 |
(let ((caption (org-export-get-caption src-block))) |
|
3372 |
(if (not caption) "" |
|
3373 |
(let ((listing-number |
|
3374 |
(format |
|
3375 |
"<span class=\"listing-number\">%s </span>" |
|
3376 |
(format |
|
3377 |
(org-html--translate "Listing %d:" info) |
|
3378 |
(org-export-get-ordinal |
|
3379 |
src-block info nil #'org-html--has-caption-p))))) |
|
3380 |
(format "<label class=\"org-src-name\">%s%s</label>" |
|
3381 |
listing-number |
|
3382 |
(org-trim (org-export-data caption info)))))) |
|
3383 |
;; Contents. |
|
3384 |
(if klipsify |
|
3385 |
(format "<pre><code class=\"src src-%s\"%s%s>%s</code></pre>" |
|
3386 |
lang |
|
3387 |
label |
|
3388 |
(if (string= lang "html") |
|
3389 |
" data-editor-type=\"html\"" |
|
3390 |
"") |
|
3391 |
code) |
|
3392 |
(format "<pre class=\"src src-%s\"%s>%s</pre>" |
|
3393 |
lang label code))))))) |
|
3394 |
|
|
3395 |
;;;; Statistics Cookie |
|
3396 |
|
|
3397 |
(defun org-html-statistics-cookie (statistics-cookie _contents _info) |
|
3398 |
"Transcode a STATISTICS-COOKIE object from Org to HTML. |
|
3399 |
CONTENTS is nil. INFO is a plist holding contextual information." |
|
3400 |
(let ((cookie-value (org-element-property :value statistics-cookie))) |
|
3401 |
(format "<code>%s</code>" cookie-value))) |
|
3402 |
|
|
3403 |
;;;; Strike-Through |
|
3404 |
|
|
3405 |
(defun org-html-strike-through (_strike-through contents info) |
|
3406 |
"Transcode STRIKE-THROUGH from Org to HTML. |
|
3407 |
CONTENTS is the text with strike-through markup. INFO is a plist |
|
3408 |
holding contextual information." |
|
3409 |
(format |
|
3410 |
(or (cdr (assq 'strike-through (plist-get info :html-text-markup-alist))) |
|
3411 |
"%s") |
|
3412 |
contents)) |
|
3413 |
|
|
3414 |
;;;; Subscript |
|
3415 |
|
|
3416 |
(defun org-html-subscript (_subscript contents _info) |
|
3417 |
"Transcode a SUBSCRIPT object from Org to HTML. |
|
3418 |
CONTENTS is the contents of the object. INFO is a plist holding |
|
3419 |
contextual information." |
|
3420 |
(format "<sub>%s</sub>" contents)) |
|
3421 |
|
|
3422 |
;;;; Superscript |
|
3423 |
|
|
3424 |
(defun org-html-superscript (_superscript contents _info) |
|
3425 |
"Transcode a SUPERSCRIPT object from Org to HTML. |
|
3426 |
CONTENTS is the contents of the object. INFO is a plist holding |
|
3427 |
contextual information." |
|
3428 |
(format "<sup>%s</sup>" contents)) |
|
3429 |
|
|
3430 |
;;;; Table Cell |
|
3431 |
|
|
3432 |
(defun org-html-table-cell (table-cell contents info) |
|
3433 |
"Transcode a TABLE-CELL element from Org to HTML. |
|
3434 |
CONTENTS is nil. INFO is a plist used as a communication |
|
3435 |
channel." |
|
3436 |
(let* ((table-row (org-export-get-parent table-cell)) |
|
3437 |
(table (org-export-get-parent-table table-cell)) |
|
3438 |
(cell-attrs |
|
3439 |
(if (not (plist-get info :html-table-align-individual-fields)) "" |
|
3440 |
(format (if (and (boundp 'org-html-format-table-no-css) |
|
3441 |
org-html-format-table-no-css) |
|
3442 |
" align=\"%s\"" " class=\"org-%s\"") |
|
3443 |
(org-export-table-cell-alignment table-cell info))))) |
|
3444 |
(when (or (not contents) (string= "" (org-trim contents))) |
|
3445 |
(setq contents " ")) |
|
3446 |
(cond |
|
3447 |
((and (org-export-table-has-header-p table info) |
|
3448 |
(= 1 (org-export-table-row-group table-row info))) |
|
3449 |
(let ((header-tags (plist-get info :html-table-header-tags))) |
|
3450 |
(concat "\n" (format (car header-tags) "col" cell-attrs) |
|
3451 |
contents |
|
3452 |
(cdr header-tags)))) |
|
3453 |
((and (plist-get info :html-table-use-header-tags-for-first-column) |
|
3454 |
(zerop (cdr (org-export-table-cell-address table-cell info)))) |
|
3455 |
(let ((header-tags (plist-get info :html-table-header-tags))) |
|
3456 |
(concat "\n" (format (car header-tags) "row" cell-attrs) |
|
3457 |
contents |
|
3458 |
(cdr header-tags)))) |
|
3459 |
(t (let ((data-tags (plist-get info :html-table-data-tags))) |
|
3460 |
(concat "\n" (format (car data-tags) cell-attrs) |
|
3461 |
contents |
|
3462 |
(cdr data-tags))))))) |
|
3463 |
|
|
3464 |
;;;; Table Row |
|
3465 |
|
|
3466 |
(defun org-html-table-row (table-row contents info) |
|
3467 |
"Transcode a TABLE-ROW element from Org to HTML. |
|
3468 |
CONTENTS is the contents of the row. INFO is a plist used as a |
|
3469 |
communication channel." |
|
3470 |
;; Rules are ignored since table separators are deduced from |
|
3471 |
;; borders of the current row. |
|
3472 |
(when (eq (org-element-property :type table-row) 'standard) |
|
3473 |
(let* ((group (org-export-table-row-group table-row info)) |
|
3474 |
(number (org-export-table-row-number table-row info)) |
|
3475 |
(start-group-p |
|
3476 |
(org-export-table-row-starts-rowgroup-p table-row info)) |
|
3477 |
(end-group-p |
|
3478 |
(org-export-table-row-ends-rowgroup-p table-row info)) |
|
3479 |
(topp (and (equal start-group-p '(top)) |
|
3480 |
(equal end-group-p '(below top)))) |
|
3481 |
(bottomp (and (equal start-group-p '(above)) |
|
3482 |
(equal end-group-p '(bottom above)))) |
|
3483 |
(row-open-tag |
|
3484 |
(pcase (plist-get info :html-table-row-open-tag) |
|
3485 |
((and accessor (pred functionp)) |
|
3486 |
(funcall accessor |
|
3487 |
number group start-group-p end-group-p topp bottomp)) |
|
3488 |
(accessor accessor))) |
|
3489 |
(row-close-tag |
|
3490 |
(pcase (plist-get info :html-table-row-close-tag) |
|
3491 |
((and accessor (pred functionp)) |
|
3492 |
(funcall accessor |
|
3493 |
number group start-group-p end-group-p topp bottomp)) |
|
3494 |
(accessor accessor))) |
|
3495 |
(group-tags |
|
3496 |
(cond |
|
3497 |
;; Row belongs to second or subsequent groups. |
|
3498 |
((not (= 1 group)) '("<tbody>" . "\n</tbody>")) |
|
3499 |
;; Row is from first group. Table has >=1 groups. |
|
3500 |
((org-export-table-has-header-p |
|
3501 |
(org-export-get-parent-table table-row) info) |
|
3502 |
'("<thead>" . "\n</thead>")) |
|
3503 |
;; Row is from first and only group. |
|
3504 |
(t '("<tbody>" . "\n</tbody>"))))) |
|
3505 |
(concat (and start-group-p (car group-tags)) |
|
3506 |
(concat "\n" |
|
3507 |
row-open-tag |
|
3508 |
contents |
|
3509 |
"\n" |
|
3510 |
row-close-tag) |
|
3511 |
(and end-group-p (cdr group-tags)))))) |
|
3512 |
|
|
3513 |
;;;; Table |
|
3514 |
|
|
3515 |
(defun org-html-table-first-row-data-cells (table info) |
|
3516 |
"Transcode the first row of TABLE. |
|
3517 |
INFO is a plist used as a communication channel." |
|
3518 |
(let ((table-row |
|
3519 |
(org-element-map table 'table-row |
|
3520 |
(lambda (row) |
|
3521 |
(unless (eq (org-element-property :type row) 'rule) row)) |
|
3522 |
info 'first-match)) |
|
3523 |
(special-column-p (org-export-table-has-special-column-p table))) |
|
3524 |
(if (not special-column-p) (org-element-contents table-row) |
|
3525 |
(cdr (org-element-contents table-row))))) |
|
3526 |
|
|
3527 |
(defun org-html-table--table.el-table (table _info) |
|
3528 |
"Format table.el tables into HTML. |
|
3529 |
INFO is a plist used as a communication channel." |
|
3530 |
(when (eq (org-element-property :type table) 'table.el) |
|
3531 |
(require 'table) |
|
3532 |
(let ((outbuf (with-current-buffer |
|
3533 |
(get-buffer-create "*org-export-table*") |
|
3534 |
(erase-buffer) (current-buffer)))) |
|
3535 |
(with-temp-buffer |
|
3536 |
(insert (org-element-property :value table)) |
|
3537 |
(goto-char 1) |
|
3538 |
(re-search-forward "^[ \t]*|[^|]" nil t) |
|
3539 |
(table-generate-source 'html outbuf)) |
|
3540 |
(with-current-buffer outbuf |
|
3541 |
(prog1 (org-trim (buffer-string)) |
|
3542 |
(kill-buffer) ))))) |
|
3543 |
|
|
3544 |
(defun org-html-table (table contents info) |
|
3545 |
"Transcode a TABLE element from Org to HTML. |
|
3546 |
CONTENTS is the contents of the table. INFO is a plist holding |
|
3547 |
contextual information." |
|
3548 |
(if (eq (org-element-property :type table) 'table.el) |
|
3549 |
;; "table.el" table. Convert it using appropriate tools. |
|
3550 |
(org-html-table--table.el-table table info) |
|
3551 |
;; Standard table. |
|
3552 |
(let* ((caption (org-export-get-caption table)) |
|
3553 |
(number (org-export-get-ordinal |
|
3554 |
table info nil #'org-html--has-caption-p)) |
|
3555 |
(attributes |
|
3556 |
(org-html--make-attribute-string |
|
3557 |
(org-combine-plists |
|
3558 |
(and (org-element-property :name table) |
|
3559 |
(list :id (org-export-get-reference table info))) |
|
3560 |
(and (not (org-html-html5-p info)) |
|
3561 |
(plist-get info :html-table-attributes)) |
|
3562 |
(org-export-read-attribute :attr_html table)))) |
|
3563 |
(alignspec |
|
3564 |
(if (bound-and-true-p org-html-format-table-no-css) |
|
3565 |
"align=\"%s\"" |
|
3566 |
"class=\"org-%s\"")) |
|
3567 |
(table-column-specs |
|
3568 |
(lambda (table info) |
|
3569 |
(mapconcat |
|
3570 |
(lambda (table-cell) |
|
3571 |
(let ((alignment (org-export-table-cell-alignment |
|
3572 |
table-cell info))) |
|
3573 |
(concat |
|
3574 |
;; Begin a colgroup? |
|
3575 |
(when (org-export-table-cell-starts-colgroup-p |
|
3576 |
table-cell info) |
|
3577 |
"\n<colgroup>") |
|
3578 |
;; Add a column. Also specify its alignment. |
|
3579 |
(format "\n%s" |
|
3580 |
(org-html-close-tag |
|
3581 |
"col" (concat " " (format alignspec alignment)) info)) |
|
3582 |
;; End a colgroup? |
|
3583 |
(when (org-export-table-cell-ends-colgroup-p |
|
3584 |
table-cell info) |
|
3585 |
"\n</colgroup>")))) |
|
3586 |
(org-html-table-first-row-data-cells table info) "\n")))) |
|
3587 |
(format "<table%s>\n%s\n%s\n%s</table>" |
|
3588 |
(if (equal attributes "") "" (concat " " attributes)) |
|
3589 |
(if (not caption) "" |
|
3590 |
(format (if (plist-get info :html-table-caption-above) |
|
3591 |
"<caption class=\"t-above\">%s</caption>" |
|
3592 |
"<caption class=\"t-bottom\">%s</caption>") |
|
3593 |
(concat |
|
3594 |
"<span class=\"table-number\">" |
|
3595 |
(format (org-html--translate "Table %d:" info) number) |
|
3596 |
"</span> " (org-export-data caption info)))) |
|
3597 |
(funcall table-column-specs table info) |
|
3598 |
contents)))) |
|
3599 |
|
|
3600 |
;;;; Target |
|
3601 |
|
|
3602 |
(defun org-html-target (target _contents info) |
|
3603 |
"Transcode a TARGET object from Org to HTML. |
|
3604 |
CONTENTS is nil. INFO is a plist holding contextual |
|
3605 |
information." |
|
3606 |
(let ((ref (org-export-get-reference target info))) |
|
3607 |
(org-html--anchor ref nil nil info))) |
|
3608 |
|
|
3609 |
;;;; Timestamp |
|
3610 |
|
|
3611 |
(defun org-html-timestamp (timestamp _contents info) |
|
3612 |
"Transcode a TIMESTAMP object from Org to HTML. |
|
3613 |
CONTENTS is nil. INFO is a plist holding contextual |
|
3614 |
information." |
|
3615 |
(let ((value (org-html-plain-text (org-timestamp-translate timestamp) info))) |
|
3616 |
(format "<span class=\"timestamp-wrapper\"><span class=\"timestamp\">%s</span></span>" |
|
3617 |
(replace-regexp-in-string "--" "–" value)))) |
|
3618 |
|
|
3619 |
;;;; Underline |
|
3620 |
|
|
3621 |
(defun org-html-underline (_underline contents info) |
|
3622 |
"Transcode UNDERLINE from Org to HTML. |
|
3623 |
CONTENTS is the text with underline markup. INFO is a plist |
|
3624 |
holding contextual information." |
|
3625 |
(format (or (cdr (assq 'underline (plist-get info :html-text-markup-alist))) |
|
3626 |
"%s") |
|
3627 |
contents)) |
|
3628 |
|
|
3629 |
;;;; Verbatim |
|
3630 |
|
|
3631 |
(defun org-html-verbatim (verbatim _contents info) |
|
3632 |
"Transcode VERBATIM from Org to HTML. |
|
3633 |
CONTENTS is nil. INFO is a plist holding contextual |
|
3634 |
information." |
|
3635 |
(format (or (cdr (assq 'verbatim (plist-get info :html-text-markup-alist))) "%s") |
|
3636 |
(org-html-encode-plain-text (org-element-property :value verbatim)))) |
|
3637 |
|
|
3638 |
;;;; Verse Block |
|
3639 |
|
|
3640 |
(defun org-html-verse-block (_verse-block contents info) |
|
3641 |
"Transcode a VERSE-BLOCK element from Org to HTML. |
|
3642 |
CONTENTS is verse block contents. INFO is a plist holding |
|
3643 |
contextual information." |
|
3644 |
(format "<p class=\"verse\">\n%s</p>" |
|
3645 |
;; Replace leading white spaces with non-breaking spaces. |
|
3646 |
(replace-regexp-in-string |
|
3647 |
"^[ \t]+" (lambda (m) (org-html--make-string (length m) " ")) |
|
3648 |
;; Replace each newline character with line break. Also |
|
3649 |
;; remove any trailing "br" close-tag so as to avoid |
|
3650 |
;; duplicates. |
|
3651 |
(let* ((br (org-html-close-tag "br" nil info)) |
|
3652 |
(re (format "\\(?:%s\\)?[ \t]*\n" (regexp-quote br)))) |
|
3653 |
(replace-regexp-in-string re (concat br "\n") contents))))) |
|
3654 |
|
|
3655 |
|
|
3656 |
;;; Filter Functions |
|
3657 |
|
|
3658 |
(defun org-html-final-function (contents _backend info) |
|
3659 |
"Filter to indent the HTML and convert HTML entities." |
|
3660 |
(with-temp-buffer |
|
3661 |
(insert contents) |
|
3662 |
(set-auto-mode t) |
|
3663 |
(if (plist-get info :html-indent) |
|
3664 |
(indent-region (point-min) (point-max))) |
|
3665 |
(buffer-substring-no-properties (point-min) (point-max)))) |
|
3666 |
|
|
3667 |
|
|
3668 |
;;; End-user functions |
|
3669 |
|
|
3670 |
;;;###autoload |
|
3671 |
(defun org-html-export-as-html |
|
3672 |
(&optional async subtreep visible-only body-only ext-plist) |
|
3673 |
"Export current buffer to an HTML buffer. |
|
3674 |
|
|
3675 |
If narrowing is active in the current buffer, only export its |
|
3676 |
narrowed part. |
|
3677 |
|
|
3678 |
If a region is active, export that region. |
|
3679 |
|
|
3680 |
A non-nil optional argument ASYNC means the process should happen |
|
3681 |
asynchronously. The resulting buffer should be accessible |
|
3682 |
through the `org-export-stack' interface. |
|
3683 |
|
|
3684 |
When optional argument SUBTREEP is non-nil, export the sub-tree |
|
3685 |
at point, extracting information from the headline properties |
|
3686 |
first. |
|
3687 |
|
|
3688 |
When optional argument VISIBLE-ONLY is non-nil, don't export |
|
3689 |
contents of hidden elements. |
|
3690 |
|
|
3691 |
When optional argument BODY-ONLY is non-nil, only write code |
|
3692 |
between \"<body>\" and \"</body>\" tags. |
|
3693 |
|
|
3694 |
EXT-PLIST, when provided, is a property list with external |
|
3695 |
parameters overriding Org default settings, but still inferior to |
|
3696 |
file-local settings. |
|
3697 |
|
|
3698 |
Export is done in a buffer named \"*Org HTML Export*\", which |
|
3699 |
will be displayed when `org-export-show-temporary-export-buffer' |
|
3700 |
is non-nil." |
|
3701 |
(interactive) |
|
3702 |
(org-export-to-buffer 'html "*Org HTML Export*" |
|
3703 |
async subtreep visible-only body-only ext-plist |
|
3704 |
(lambda () (set-auto-mode t)))) |
|
3705 |
|
|
3706 |
;;;###autoload |
|
3707 |
(defun org-html-convert-region-to-html () |
|
3708 |
"Assume the current region has Org syntax, and convert it to HTML. |
|
3709 |
This can be used in any buffer. For example, you can write an |
|
3710 |
itemized list in Org syntax in an HTML buffer and use this command |
|
3711 |
to convert it." |
|
3712 |
(interactive) |
|
3713 |
(org-export-replace-region-by 'html)) |
|
3714 |
|
|
3715 |
;;;###autoload |
|
3716 |
(defun org-html-export-to-html |
|
3717 |
(&optional async subtreep visible-only body-only ext-plist) |
|
3718 |
"Export current buffer to a HTML file. |
|
3719 |
|
|
3720 |
If narrowing is active in the current buffer, only export its |
|
3721 |
narrowed part. |
|
3722 |
|
|
3723 |
If a region is active, export that region. |
|
3724 |
|
|
3725 |
A non-nil optional argument ASYNC means the process should happen |
|
3726 |
asynchronously. The resulting file should be accessible through |
|
3727 |
the `org-export-stack' interface. |
|
3728 |
|
|
3729 |
When optional argument SUBTREEP is non-nil, export the sub-tree |
|
3730 |
at point, extracting information from the headline properties |
|
3731 |
first. |
|
3732 |
|
|
3733 |
When optional argument VISIBLE-ONLY is non-nil, don't export |
|
3734 |
contents of hidden elements. |
|
3735 |
|
|
3736 |
When optional argument BODY-ONLY is non-nil, only write code |
|
3737 |
between \"<body>\" and \"</body>\" tags. |
|
3738 |
|
|
3739 |
EXT-PLIST, when provided, is a property list with external |
|
3740 |
parameters overriding Org default settings, but still inferior to |
|
3741 |
file-local settings. |
|
3742 |
|
|
3743 |
Return output file's name." |
|
3744 |
(interactive) |
|
3745 |
(let* ((extension (concat "." (or (plist-get ext-plist :html-extension) |
|
3746 |
org-html-extension |
|
3747 |
"html"))) |
|
3748 |
(file (org-export-output-file-name extension subtreep)) |
|
3749 |
(org-export-coding-system org-html-coding-system)) |
|
3750 |
(org-export-to-file 'html file |
|
3751 |
async subtreep visible-only body-only ext-plist))) |
|
3752 |
|
|
3753 |
;;;###autoload |
|
3754 |
(defun org-html-publish-to-html (plist filename pub-dir) |
|
3755 |
"Publish an org file to HTML. |
|
3756 |
|
|
3757 |
FILENAME is the filename of the Org file to be published. PLIST |
|
3758 |
is the property list for the given project. PUB-DIR is the |
|
3759 |
publishing directory. |
|
3760 |
|
|
3761 |
Return output file name." |
|
3762 |
(org-publish-org-to 'html filename |
|
3763 |
(concat "." (or (plist-get plist :html-extension) |
|
3764 |
org-html-extension |
|
3765 |
"html")) |
|
3766 |
plist pub-dir)) |
|
3767 |
|
|
3768 |
|
|
3769 |
(provide 'ox-html) |
|
3770 |
|
|
3771 |
;; Local variables: |
|
3772 |
;; generated-autoload-file: "org-loaddefs.el" |
|
3773 |
;; End: |
|
3774 |
|
|
3775 |
;;; ox-html.el ends here |