config

Personal configuration.
git clone git://code.dwrz.net/config
Log | Files | Refs

ox-html.el (156764B)


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