summaryrefslogtreecommitdiff
path: root/lisp/ox-html.el
diff options
context:
space:
mode:
Diffstat (limited to 'lisp/ox-html.el')
-rw-r--r--lisp/ox-html.el949
1 files changed, 533 insertions, 416 deletions
diff --git a/lisp/ox-html.el b/lisp/ox-html.el
index de2e5d9..404b62f 100644
--- a/lisp/ox-html.el
+++ b/lisp/ox-html.el
@@ -1,4 +1,4 @@
-;;; ox-html.el --- HTML Back-End for Org Export Engine
+;;; ox-html.el --- HTML Back-End for Org Export Engine -*- lexical-binding: t; -*-
;; Copyright (C) 2011-2016 Free Software Foundation, Inc.
@@ -30,20 +30,24 @@
;;; Dependencies
+(require 'cl-lib)
+(require 'format-spec)
(require 'ox)
(require 'ox-publish)
-(require 'format-spec)
-(eval-when-compile (require 'cl) (require 'table nil 'noerror))
+(require 'table)
;;; Function Declarations
(declare-function org-id-find-id-file "org-id" (id))
(declare-function htmlize-region "ext:htmlize" (beg end))
-(declare-function org-pop-to-buffer-same-window
- "org-compat" (&optional buffer-or-name norecord label))
(declare-function mm-url-decode-entities "mm-url" ())
+(defvar htmlize-css-name-prefix)
+(defvar htmlize-output-type)
+(defvar htmlize-output-type)
+(defvar htmlize-css-name-prefix)
+
;;; Define Back-End
(org-export-define-backend 'html
@@ -96,7 +100,6 @@
(underline . org-html-underline)
(verbatim . org-html-verbatim)
(verse-block . org-html-verse-block))
- :export-block "HTML"
:filters-alist '((:filter-options . org-html-infojs-install-script)
(:filter-final-output . org-html-final-function))
:menu-entry
@@ -117,7 +120,6 @@
(:html-link-home "HTML_LINK_HOME" nil org-html-link-home)
(:html-link-up "HTML_LINK_UP" nil org-html-link-up)
(:html-mathjax "HTML_MATHJAX" nil "" space)
- (:html-link-use-abs-url nil "html-link-use-abs-url" org-html-link-use-abs-url)
(:html-postamble nil "html-postamble" org-html-postamble)
(:html-preamble nil "html-preamble" org-html-preamble)
(:html-head "HTML_HEAD" nil org-html-head newline)
@@ -165,7 +167,8 @@
(:html-viewport nil nil org-html-viewport)
(:html-inline-images nil nil org-html-inline-images)
(:html-table-attributes nil nil org-html-table-default-attributes)
- (:html-table-row-tags nil nil org-html-table-row-tags)
+ (:html-table-row-open-tag nil nil org-html-table-row-open-tag)
+ (:html-table-row-close-tag nil nil org-html-table-row-close-tag)
(:html-xml-declaration nil nil org-html-xml-declaration)
(:infojs-opt "INFOJS_OPT" nil nil)
;; Redefine regular options.
@@ -314,13 +317,97 @@ for the JavaScript code in this tag.
border: 1px solid black;
}
pre.src:hover:before { display: inline;}
- pre.src-sh:before { content: 'sh'; }
- pre.src-bash:before { content: 'sh'; }
+ /* Languages per Org manual */
+ pre.src-asymptote:before { content: 'Asymptote'; }
+ pre.src-awk:before { content: 'Awk'; }
+ pre.src-C:before { content: 'C'; }
+ /* pre.src-C++ doesn't work in CSS */
+ pre.src-clojure:before { content: 'Clojure'; }
+ pre.src-css:before { content: 'CSS'; }
+ pre.src-D:before { content: 'D'; }
+ pre.src-ditaa:before { content: 'ditaa'; }
+ pre.src-dot:before { content: 'Graphviz'; }
+ pre.src-calc:before { content: 'Emacs Calc'; }
pre.src-emacs-lisp:before { content: 'Emacs Lisp'; }
- pre.src-R:before { content: 'R'; }
- pre.src-perl:before { content: 'Perl'; }
- pre.src-java:before { content: 'Java'; }
- pre.src-sql:before { content: 'SQL'; }
+ pre.src-fortran:before { content: 'Fortran'; }
+ pre.src-gnuplot:before { content: 'gnuplot'; }
+ pre.src-haskell:before { content: 'Haskell'; }
+ pre.src-java:before { content: 'Java'; }
+ pre.src-js:before { content: 'Javascript'; }
+ pre.src-latex:before { content: 'LaTeX'; }
+ pre.src-ledger:before { content: 'Ledger'; }
+ pre.src-lisp:before { content: 'Lisp'; }
+ pre.src-lilypond:before { content: 'Lilypond'; }
+ pre.src-lua:before { content: 'Lua'; }
+ pre.src-matlab:before { content: 'MATLAB'; }
+ pre.src-mscgen:before { content: 'Mscgen'; }
+ pre.src-ocaml:before { content: 'Objective Caml'; }
+ pre.src-octave:before { content: 'Octave'; }
+ pre.src-org:before { content: 'Org mode'; }
+ pre.src-oz:before { content: 'OZ'; }
+ pre.src-plantuml:before { content: 'Plantuml'; }
+ pre.src-processing:before { content: 'Processing.js'; }
+ pre.src-python:before { content: 'Python'; }
+ pre.src-R:before { content: 'R'; }
+ pre.src-ruby:before { content: 'Ruby'; }
+ pre.src-sass:before { content: 'Sass'; }
+ pre.src-scheme:before { content: 'Scheme'; }
+ pre.src-screen:before { content: 'Gnu Screen'; }
+ pre.src-sed:before { content: 'Sed'; }
+ pre.src-sh:before { content: 'shell'; }
+ pre.src-sql:before { content: 'SQL'; }
+ pre.src-sqlite:before { content: 'SQLite'; }
+ /* additional languages in org.el's org-babel-load-languages alist */
+ pre.src-forth:before { content: 'Forth'; }
+ pre.src-io:before { content: 'IO'; }
+ pre.src-J:before { content: 'J'; }
+ pre.src-makefile:before { content: 'Makefile'; }
+ pre.src-maxima:before { content: 'Maxima'; }
+ pre.src-perl:before { content: 'Perl'; }
+ pre.src-picolisp:before { content: 'Pico Lisp'; }
+ pre.src-scala:before { content: 'Scala'; }
+ pre.src-shell:before { content: 'Shell Script'; }
+ pre.src-ebnf2ps:before { content: 'ebfn2ps'; }
+ /* additional language identifiers per \"defun org-babel-execute\"
+ in ob-*.el */
+ pre.src-cpp:before { content: 'C++'; }
+ pre.src-abc:before { content: 'ABC'; }
+ pre.src-coq:before { content: 'Coq'; }
+ pre.src-groovy:before { content: 'Groovy'; }
+ /* additional language identifiers from org-babel-shell-names in
+ ob-shell.el: ob-shell is the only babel language using a lambda to put
+ the execution function name together. */
+ pre.src-bash:before { content: 'bash'; }
+ pre.src-csh:before { content: 'csh'; }
+ pre.src-ash:before { content: 'ash'; }
+ pre.src-dash:before { content: 'dash'; }
+ pre.src-ksh:before { content: 'ksh'; }
+ pre.src-mksh:before { content: 'mksh'; }
+ pre.src-posh:before { content: 'posh'; }
+ /* Additional Emacs modes also supported by the LaTeX listings package */
+ pre.src-ada:before { content: 'Ada'; }
+ pre.src-asm:before { content: 'Assembler'; }
+ pre.src-caml:before { content: 'Caml'; }
+ pre.src-delphi:before { content: 'Delphi'; }
+ pre.src-html:before { content: 'HTML'; }
+ pre.src-idl:before { content: 'IDL'; }
+ pre.src-mercury:before { content: 'Mercury'; }
+ pre.src-metapost:before { content: 'MetaPost'; }
+ pre.src-modula-2:before { content: 'Modula-2'; }
+ pre.src-pascal:before { content: 'Pascal'; }
+ pre.src-ps:before { content: 'PostScript'; }
+ pre.src-prolog:before { content: 'Prolog'; }
+ pre.src-simula:before { content: 'Simula'; }
+ pre.src-tcl:before { content: 'tcl'; }
+ pre.src-tex:before { content: 'TeX'; }
+ pre.src-plain-tex:before { content: 'Plain TeX'; }
+ pre.src-verilog:before { content: 'Verilog'; }
+ pre.src-vhdl:before { content: 'VHDL'; }
+ pre.src-xml:before { content: 'XML'; }
+ pre.src-nxml:before { content: 'XML'; }
+ /* add a generic configuration mode; LaTeX export needs an additional
+ (add-to-list 'org-latex-listings-langs '(conf \" \")) in .emacs */
+ pre.src-conf:before { content: 'Configuration File'; }
table { border-collapse:collapse; }
caption.t-above { caption-side: top; }
@@ -353,6 +440,7 @@ for the JavaScript code in this tag.
{ font-size: 10px; font-weight: bold; white-space: nowrap; }
.org-info-js_search-highlight
{ background-color: #ffff00; color: #000000; font-weight: bold; }
+ .org-svg { width: 90%; }
/*]]>*/-->
</style>"
"The default style specification for exported HTML files.
@@ -492,7 +580,7 @@ Option settings will replace the %MANAGER-OPTIONS cookie."
:package-version '(Org . "8.0")
:type 'string)
-(defun org-html-infojs-install-script (exp-plist backend)
+(defun org-html-infojs-install-script (exp-plist _backend)
"Install script in export options when appropriate.
EXP-PLIST is a plist containing export options. BACKEND is the
export back-end currently used."
@@ -529,21 +617,21 @@ export back-end currently used."
options))
(match-string 1 options)
default)))
- (case opt
- (path (setq template
- (replace-regexp-in-string
- "%SCRIPT_PATH" val template t t)))
- (sdepth (when (integerp (read val))
- (setq sdepth (min (read val) sdepth))))
- (tdepth (when (integerp (read val))
- (setq tdepth (min (read val) tdepth))))
- (otherwise (setq val
- (cond
- ((or (eq val t) (equal val "t")) "1")
- ((or (eq val nil) (equal val "nil")) "0")
- ((stringp val) val)
- (t (format "%s" val))))
- (push (cons var val) style)))))
+ (pcase opt
+ (`path (setq template
+ (replace-regexp-in-string
+ "%SCRIPT_PATH" val template t t)))
+ (`sdepth (when (integerp (read val))
+ (setq sdepth (min (read val) sdepth))))
+ (`tdepth (when (integerp (read val))
+ (setq tdepth (min (read val) tdepth))))
+ (_ (setq val
+ (cond
+ ((or (eq val t) (equal val "t")) "1")
+ ((or (eq val nil) (equal val "nil")) "0")
+ ((stringp val) val)
+ (t (format "%s" val))))
+ (push (cons var val) style)))))
;; Now we set the depth of the *generated* TOC to SDEPTH,
;; because the toc will actually determine the splitting. How
;; much of the toc will actually be displayed is governed by the
@@ -609,7 +697,7 @@ Warning: non-nil may break indentation of source code blocks."
;;;; Drawers
-(defcustom org-html-format-drawer-function (lambda (name contents) contents)
+(defcustom org-html-format-drawer-function (lambda (_name contents) contents)
"Function called to format a drawer in HTML code.
The function must accept two parameters:
@@ -680,7 +768,7 @@ INFO the export options (plist).
The function result will be used in the section format string."
:group 'org-export-html
- :version "25.1"
+ :version "25.2"
:package-version '(Org . "8.3")
:type 'function)
@@ -712,7 +800,7 @@ The function must accept seven parameters:
The function should return the string to be exported."
:group 'org-export-html
- :version "25.1"
+ :version "25.2"
:package-version '(Org . "8.3")
:type 'function)
@@ -727,24 +815,20 @@ fragments.
This option can also be set with the +OPTIONS line,
e.g. \"tex:mathjax\". Allowed values are:
-nil Ignore math snippets.
-`verbatim' Keep everything in verbatim
-`dvipng' Process the LaTeX fragments to images. This will also
- include processing of non-math environments.
-`imagemagick' Convert the LaTeX fragments to pdf files and use
- imagemagick to convert pdf files to png files.
-`mathjax' Do MathJax preprocessing and arrange for MathJax.js to
- be loaded.
-t Synonym for `mathjax'."
+ nil Ignore math snippets.
+ `verbatim' Keep everything in verbatim
+ `mathjax', t Do MathJax preprocessing and arrange for MathJax.js to
+ be loaded.
+ SYMBOL Any symbol defined in `org-preview-latex-process-alist',
+ e.g., `dvipng'."
:group 'org-export-html
:version "24.4"
:package-version '(Org . "8.0")
:type '(choice
(const :tag "Do not process math in any way" nil)
- (const :tag "Use dvipng to make images" dvipng)
- (const :tag "Use imagemagick to make images" imagemagick)
+ (const :tag "Leave math verbatim" verbatim)
(const :tag "Use MathJax to display math" mathjax)
- (const :tag "Leave math verbatim" verbatim)))
+ (symbol :tag "Convert to image to display math" :value dvipng)))
;;;; Links :: Generic
@@ -752,11 +836,11 @@ t Synonym for `mathjax'."
"Non-nil means make file links to `file.org' point to `file.html'.
When `org-mode' is exporting an `org-mode' file to HTML, links to
non-html files are directly put into a href tag in HTML.
-However, links to other Org-mode files (recognized by the
-extension `.org') should become links to the corresponding html
+However, links to other Org files (recognized by the extension
+\".org\") should become links to the corresponding HTML
file, assuming that the linked `org-mode' file will also be
converted to HTML.
-When nil, the links still point to the plain `.org' file."
+When nil, the links still point to the plain \".org\" file."
:group 'org-export-html
:type 'boolean)
@@ -811,7 +895,7 @@ a style file to define the look of these classes.
To get a start for your css file, start Emacs session and make sure that
all the faces you are interested in are defined, for example by loading files
in all modes you want. Then, use the command
-\\[org-html-htmlize-generate-css] to extract class definitions."
+`\\[org-html-htmlize-generate-css]' to extract class definitions."
:group 'org-export-html
:type '(choice (const css) (const inline-css) (const nil)))
@@ -854,43 +938,50 @@ See also the variable `org-html-table-align-individual-fields'."
:group 'org-export-html
:type '(cons (string :tag "Opening tag") (string :tag "Closing tag")))
-(defcustom org-html-table-row-tags '("<tr>" . "</tr>")
- "The opening and ending tags for table rows.
+(defcustom org-html-table-row-open-tag "<tr>"
+ "The opening tag for table rows.
This is customizable so that alignment options can be specified.
-Instead of strings, these can be Lisp forms that will be
+Instead of strings, these can be a Lisp function that will be
evaluated for each row in order to construct the table row tags.
-During evaluation, these variables will be dynamically bound so that
-you can reuse them:
+The function will be called with these arguments:
- `row-number': row number (0 is the first row)
- `rowgroup-number': group number of current row
- `start-rowgroup-p': non-nil means the row starts a group
- `end-rowgroup-p': non-nil means the row ends a group
- `top-row-p': non-nil means this is the top row
- `bottom-row-p': non-nil means this is the bottom row
+ `number': row number (0 is the first row)
+ `group-number': group number of current row
+ `start-group?': non-nil means the row starts a group
+ `end-group?': non-nil means the row ends a group
+ `top?': non-nil means this is the top row
+ `bottom?': non-nil means this is the bottom row
For example:
-\(setq org-html-table-row-tags
- (cons \\='(cond (top-row-p \"<tr class=\\\"tr-top\\\">\")
- (bottom-row-p \"<tr class=\\\"tr-bottom\\\">\")
- (t (if (= (mod row-number 2) 1)
- \"<tr class=\\\"tr-odd\\\">\"
- \"<tr class=\\\"tr-even\\\">\")))
- \"</tr>\"))
+ (setq org-html-table-row-open-tag
+ (lambda (number group-number start-group? end-group-p top? bottom?)
+ (cond (top? \"<tr class=\\\"tr-top\\\">\")
+ (bottom? \"<tr class=\\\"tr-bottom\\\">\")
+ (t (if (= (mod number 2) 1)
+ \"<tr class=\\\"tr-odd\\\">\"
+ \"<tr class=\\\"tr-even\\\">\")))))
will use the \"tr-top\" and \"tr-bottom\" classes for the top row
and the bottom row, and otherwise alternate between \"tr-odd\" and
\"tr-even\" for odd and even rows."
:group 'org-export-html
- :type '(cons
- (choice :tag "Opening tag"
- (string :tag "Specify")
- (sexp))
- (choice :tag "Closing tag"
- (string :tag "Specify")
- (sexp))))
+ :type '(choice :tag "Opening tag"
+ (string :tag "Specify")
+ (function)))
+
+(defcustom org-html-table-row-close-tag "</tr>"
+ "The closing tag for table rows.
+This is customizable so that alignment options can be specified.
+Instead of strings, this can be a Lisp function that will be
+evaluated for each row in order to construct the table row tags.
+
+See documentation of `org-html-table-row-open-tag'."
+ :group 'org-export-html
+ :type '(choice :tag "Closing tag"
+ (string :tag "Specify")
+ (function)))
(defcustom org-html-table-align-individual-fields t
"Non-nil means attach style attributes for alignment to each table field.
@@ -1326,8 +1417,6 @@ ignored."
;;;; Template :: Scripts
-(define-obsolete-variable-alias
- 'org-html-style-include-scripts 'org-html-head-include-scripts "24.4")
(defcustom org-html-head-include-scripts t
"Non-nil means include the JavaScript snippets in exported HTML files.
The actual script is defined in `org-html-scripts' and should
@@ -1339,8 +1428,6 @@ not be modified."
;;;; Template :: Styles
-(define-obsolete-variable-alias
- 'org-html-style-include-default 'org-html-head-include-default-style "24.4")
(defcustom org-html-head-include-default-style t
"Non-nil means include the default style in exported HTML files.
The actual style is defined in `org-html-style-default' and
@@ -1353,7 +1440,6 @@ style information."
;;;###autoload
(put 'org-html-head-include-default-style 'safe-local-variable 'booleanp)
-(define-obsolete-variable-alias 'org-html-style 'org-html-head "24.4")
(defcustom org-html-head ""
"Org-wide head definitions for exported HTML files.
@@ -1425,7 +1511,7 @@ The viewport meta tag is inserted if this variable is non-nil.
See the following site for a reference:
https://developer.mozilla.org/en-US/docs/Mozilla/Mobile/Viewport_meta_tag"
:group 'org-export-html
- :version "25.1"
+ :version "25.2"
:package-version '(Org . "8.3")
:type '(choice (const :tag "Disable" nil)
(list :tag "Enable"
@@ -1543,21 +1629,27 @@ a communication channel."
info)))
(defun org-html--svg-image (source attributes info)
- "Return \"object\" appropriate for embedding svg file SOURCE
-with assoicated ATTRIBUTES. INFO is a plist used as a
-communication channel.
+ "Return \"object\" embedding svg file SOURCE with given ATTRIBUTES.
+INFO is a plist used as a communication channel.
-The special attribute \"fallback\" can be used to specify a fallback
-image file to use if the object embedding is not supported."
+The special attribute \"fallback\" can be used to specify a
+fallback image file to use if the object embedding is not
+supported. CSS class \"org-svg\" is assigned as the class of the
+object unless a different class is specified with an attribute."
(let ((fallback (plist-get attributes :fallback))
(attrs (org-html--make-attribute-string
- (plist-put attributes :fallback nil))))
- (format "<object type=\"image/svg+xml\" data=\"%s\" %s>\n%s</object>"
- source attrs
- (if fallback
- (org-html-close-tag
- "img" (format "src=\"%s\" %s" fallback attrs) info)
- "Sorry, your browser does not support SVG."))))
+ (org-combine-plists
+ ;; Remove fallback attribute, which is not meant to
+ ;; appear directly in the attributes string, and
+ ;; provide a default class if none is set.
+ '(:class "org-svg") attributes '(:fallback nil)))))
+ (format "<object type=\"image/svg+xml\" data=\"%s\" %s>\n%s</object>"
+ source
+ attrs
+ (if fallback
+ (org-html-close-tag
+ "img" (format "src=\"%s\" %s" fallback attrs) info)
+ "Sorry, your browser does not support SVG."))))
(defun org-html--textarea-block (element)
"Transcode ELEMENT into a textarea block.
@@ -1569,7 +1661,7 @@ ELEMENT is either a src block or an example block."
(or (plist-get attr :height) (org-count-lines code))
code)))
-(defun org-html--has-caption-p (element &optional info)
+(defun org-html--has-caption-p (element &optional _info)
"Non-nil when ELEMENT has a caption affiliated keyword.
INFO is a plist used as a communication channel. This function
is meant to be used as a predicate for `org-export-get-ordinal' or
@@ -1616,7 +1708,7 @@ produce code that uses these same face definitions."
(when (and (symbolp f) (or (not i) (not (listp i))))
(insert (org-add-props (copy-sequence "1") nil 'face f))))
(htmlize-region (point-min) (point-max))))
- (org-pop-to-buffer-same-window "*html*")
+ (pop-to-buffer-same-window "*html*")
(goto-char (point-min))
(if (re-search-forward "<style" nil t)
(delete-region (point-min) (match-beginning 0)))
@@ -1628,26 +1720,23 @@ produce code that uses these same face definitions."
(defun org-html--make-string (n string)
"Build a string by concatenating N times STRING."
- (let (out) (dotimes (i n out) (setq out (concat string out)))))
+ (let (out) (dotimes (_ n out) (setq out (concat string out)))))
(defun org-html-fix-class-name (kwd) ; audit callers of this function
"Turn todo keyword KWD into a valid class name.
Replaces invalid characters with \"_\"."
- (save-match-data
- (while (string-match "[^a-zA-Z0-9_]" kwd)
- (setq kwd (replace-match "_" t t kwd))))
- kwd)
+ (replace-regexp-in-string "[^a-zA-Z0-9_]" "_" kwd nil t))
(defun org-html-footnote-section (info)
"Format the footnote section.
INFO is a plist used as a communication channel."
(let* ((fn-alist (org-export-collect-footnote-definitions info))
(fn-alist
- (loop for (n type raw) in fn-alist collect
- (cons n (if (eq (org-element-type raw) 'org-data)
- (org-trim (org-export-data raw info))
- (format "<div class=\"footpara\">%s</div>"
- (org-trim (org-export-data raw info))))))))
+ (cl-loop for (n _type raw) in fn-alist collect
+ (cons n (if (eq (org-element-type raw) 'org-data)
+ (org-trim (org-export-data raw info))
+ (format "<div class=\"footpara\">%s</div>"
+ (org-trim (org-export-data raw info))))))))
(when fn-alist
(format
(plist-get info :html-footnotes-section)
@@ -1705,45 +1794,45 @@ INFO is a plist used as a communication channel."
" -->\n")))
(format
(if (org-html-html5-p info)
- (org-html-close-tag "meta" " charset=\"%s\"" info)
+ (org-html-close-tag "meta" "charset=\"%s\"" info)
(org-html-close-tag
- "meta" " http-equiv=\"Content-Type\" content=\"text/html;charset=%s\""
+ "meta" "http-equiv=\"Content-Type\" content=\"text/html;charset=%s\""
info))
charset) "\n"
(let ((viewport-options
- (org-remove-if-not (lambda (cell) (org-string-nw-p (cadr cell)))
+ (cl-remove-if-not (lambda (cell) (org-string-nw-p (cadr cell)))
(plist-get info :html-viewport))))
(and viewport-options
(concat
(org-html-close-tag
"meta"
- (format " name=\"viewport\" content=\"%s\""
+ (format "name=\"viewport\" content=\"%s\""
(mapconcat
(lambda (elm) (format "%s=%s" (car elm) (cadr elm)))
viewport-options ", "))
info)
"\n")))
(format "<title>%s</title>\n" title)
- (org-html-close-tag "meta" " name=\"generator\" content=\"Org-mode\"" info)
+ (org-html-close-tag "meta" "name=\"generator\" content=\"Org mode\"" info)
"\n"
(and (org-string-nw-p author)
(concat
(org-html-close-tag "meta"
- (format " name=\"author\" content=\"%s\""
+ (format "name=\"author\" content=\"%s\""
(funcall protect-string author))
info)
"\n"))
(and (org-string-nw-p description)
(concat
(org-html-close-tag "meta"
- (format " name=\"description\" content=\"%s\"\n"
+ (format "name=\"description\" content=\"%s\"\n"
(funcall protect-string description))
info)
"\n"))
(and (org-string-nw-p keywords)
(concat
(org-html-close-tag "meta"
- (format " name=\"keywords\" content=\"%s\""
+ (format "name=\"keywords\" content=\"%s\""
(funcall protect-string keywords))
info)
"\n")))))
@@ -1760,7 +1849,7 @@ INFO is a plist used as a communication channel."
(when (and (plist-get info :html-htmlized-css-url)
(eq org-html-htmlize-output-type 'css))
(org-html-close-tag "link"
- (format " rel=\"stylesheet\" href=\"%s\" type=\"text/css\""
+ (format "rel=\"stylesheet\" href=\"%s\" type=\"text/css\""
(plist-get info :html-htmlized-css-url))
info))
(when (plist-get info :html-head-include-scripts) org-html-scripts))))
@@ -1773,20 +1862,17 @@ INFO is a plist used as a communication channel."
'(latex-fragment latex-environment) 'identity info t))
(let ((template (plist-get info :html-mathjax-template))
(options (plist-get info :html-mathjax-options))
- (in-buffer (or (plist-get info :html-mathjax) ""))
- name val x)
- (mapc
- (lambda (e)
- (setq name (car e) val (nth 1 e))
- (if (string-match (concat "\\<" (symbol-name name) ":") in-buffer)
- (setq val (car (read-from-string
- (substring in-buffer (match-end 0))))))
- (if (not (stringp val)) (setq val (format "%s" val)))
- (while (string-match (concat "%" (upcase (symbol-name name))) template)
- (setq template (replace-match val t t template))))
- options)
- ;; Return the modified template.
- (org-element-normalize-string template))))
+ (in-buffer (or (plist-get info :html-mathjax) "")))
+ (dolist (e options (org-element-normalize-string template))
+ (let ((name (car e))
+ (val (nth 1 e)))
+ (when (string-match (concat "\\<" (symbol-name name) ":") in-buffer)
+ (setq val
+ (car (read-from-string (substring in-buffer (match-end 0))))))
+ (unless (stringp val) (setq val (format "%s" val)))
+ (while (string-match (concat "%" (upcase (symbol-name name)))
+ template)
+ (setq template (replace-match val t t template))))))))
(defun org-html-format-spec (info)
"Return format specification for elements that can be
@@ -1825,7 +1911,6 @@ communication channel."
(author (cdr (assq ?a spec)))
(email (cdr (assq ?e spec)))
(creator (cdr (assq ?c spec)))
- (timestamp (cdr (assq ?T spec)))
(validation-link (cdr (assq ?v spec))))
(concat
(when (and (plist-get info :with-date)
@@ -1854,15 +1939,17 @@ communication channel."
(format "<p class=\"validation\">%s</p>\n"
validation-link))))
(t (format-spec
- (or (cadr (assoc
+ (or (cadr (assoc-string
(plist-get info :language)
(eval (intern
- (format "org-html-%s-format" type)))))
+ (format "org-html-%s-format" type)))
+ t))
(cadr
- (assoc
+ (assoc-string
"en"
(eval
- (intern (format "org-html-%s-format" type))))))
+ (intern (format "org-html-%s-format" type)))
+ t)))
spec))))))
(let ((div (assq type (plist-get info :html-divs))))
(when (org-string-nw-p section-contents)
@@ -1909,10 +1996,12 @@ holding export options."
(org-html-doctype info)
"\n"
(concat "<html"
- (when (org-html-xhtml-p info)
- (format
- " xmlns=\"http://www.w3.org/1999/xhtml\" lang=\"%s\" xml:lang=\"%s\""
- (plist-get info :language) (plist-get info :language)))
+ (cond ((org-html-xhtml-p info)
+ (format
+ " xmlns=\"http://www.w3.org/1999/xhtml\" lang=\"%s\" xml:lang=\"%s\""
+ (plist-get info :language) (plist-get info :language)))
+ ((org-html-html5-p info)
+ (format " lang=\"%s\"" (plist-get info :language))))
">\n")
"<head>\n"
(org-html--build-meta-info info)
@@ -1984,7 +2073,7 @@ INFO is a plist used as a communication channel."
;;;; Priority
-(defun org-html--priority (priority info)
+(defun org-html--priority (priority _info)
"Format a priority into HTML.
PRIORITY is the character code of the priority or nil. INFO is
a plist containing export options."
@@ -2115,9 +2204,7 @@ a plist used as a communication channel."
;; Does the src block contain labels?
(retain-labels (org-element-property :retain-labels element))
;; Does it have line numbers?
- (num-start (case (org-element-property :number-lines element)
- (continued (org-export-get-loc element info))
- (new 0))))
+ (num-start (org-export-get-loc element info)))
(org-html-do-format-code code lang refs retain-labels num-start)))
@@ -2164,8 +2251,7 @@ and value is its relative level, as an integer."
(level (cdr entry)))
(concat
(let* ((cnt (- level prev-level))
- (times (if (> cnt 0) (1- cnt) (- cnt)))
- rtn)
+ (times (if (> cnt 0) (1- cnt) (- cnt))))
(setq prev-level level)
(concat
(org-html--make-string
@@ -2241,10 +2327,12 @@ of listings as a string, or nil if it is empty."
(concat
"<li>"
(if (not label)
- (concat (format initial-fmt (incf count)) " " title)
+ (concat (format initial-fmt (cl-incf count))
+ " "
+ title)
(format "<a href=\"#%s\">%s %s</a>"
label
- (format initial-fmt (incf count))
+ (format initial-fmt (cl-incf count))
title))
"</li>")))
lol-entries "\n"))
@@ -2278,10 +2366,12 @@ of tables as a string, or nil if it is empty."
(concat
"<li>"
(if (not label)
- (concat (format initial-fmt (incf count)) " " title)
+ (concat (format initial-fmt (cl-incf count))
+ " "
+ title)
(format "<a href=\"#%s\">%s %s</a>"
label
- (format initial-fmt (incf count))
+ (format initial-fmt (cl-incf count))
title))
"</li>")))
lol-entries "\n"))
@@ -2292,7 +2382,7 @@ of tables as a string, or nil if it is empty."
;;;; Bold
-(defun org-html-bold (bold contents info)
+(defun org-html-bold (_bold contents info)
"Transcode BOLD from Org to HTML.
CONTENTS is the text with bold markup. INFO is a plist holding
contextual information."
@@ -2301,7 +2391,7 @@ contextual information."
;;;; Center Block
-(defun org-html-center-block (center-block contents info)
+(defun org-html-center-block (_center-block contents _info)
"Transcode a CENTER-BLOCK element from Org to HTML.
CONTENTS holds the contents of the block. INFO is a plist
holding contextual information."
@@ -2309,7 +2399,7 @@ holding contextual information."
;;;; Clock
-(defun org-html-clock (clock contents info)
+(defun org-html-clock (clock _contents _info)
"Transcode a CLOCK element from Org to HTML.
CONTENTS is nil. INFO is a plist used as a communication
channel."
@@ -2325,7 +2415,7 @@ channel."
;;;; Code
-(defun org-html-code (code contents info)
+(defun org-html-code (code _contents info)
"Transcode CODE from Org to HTML.
CONTENTS is nil. INFO is a plist holding contextual
information."
@@ -2344,7 +2434,7 @@ holding contextual information."
;;;; Dynamic Block
-(defun org-html-dynamic-block (dynamic-block contents info)
+(defun org-html-dynamic-block (_dynamic-block contents _info)
"Transcode a DYNAMIC-BLOCK element from Org to HTML.
CONTENTS holds the contents of the block. INFO is a plist
holding contextual information. See `org-export-data'."
@@ -2352,7 +2442,7 @@ holding contextual information. See `org-export-data'."
;;;; Entity
-(defun org-html-entity (entity contents info)
+(defun org-html-entity (entity _contents _info)
"Transcode an ENTITY object from Org to HTML.
CONTENTS are the definition itself. INFO is a plist holding
contextual information."
@@ -2360,18 +2450,25 @@ contextual information."
;;;; Example Block
-(defun org-html-example-block (example-block contents info)
+(defun org-html-example-block (example-block _contents info)
"Transcode a EXAMPLE-BLOCK element from Org to HTML.
CONTENTS is nil. INFO is a plist holding contextual
information."
- (if (org-export-read-attribute :attr_html example-block :textarea)
- (org-html--textarea-block example-block)
- (format "<pre class=\"example\">\n%s</pre>"
- (org-html-format-code example-block info))))
+ (let ((attributes (org-export-read-attribute :attr_html example-block)))
+ (if (plist-get attributes :textarea)
+ (org-html--textarea-block example-block)
+ (format "<pre class=\"example\"%s>\n%s</pre>"
+ (let* ((name (org-element-property :name example-block))
+ (a (org-html--make-attribute-string
+ (if (or (not name) (plist-member attributes :id))
+ attributes
+ (plist-put attributes :id name)))))
+ (if (org-string-nw-p a) (concat " " a) ""))
+ (org-html-format-code example-block info)))))
;;;; Export Snippet
-(defun org-html-export-snippet (export-snippet contents info)
+(defun org-html-export-snippet (export-snippet _contents _info)
"Transcode a EXPORT-SNIPPET object from Org to HTML.
CONTENTS is nil. INFO is a plist holding contextual
information."
@@ -2380,7 +2477,7 @@ information."
;;;; Export Block
-(defun org-html-export-block (export-block contents info)
+(defun org-html-export-block (export-block _contents _info)
"Transcode a EXPORT-BLOCK element from Org to HTML.
CONTENTS is nil. INFO is a plist holding contextual information."
(when (string= (org-element-property :type export-block) "HTML")
@@ -2388,7 +2485,7 @@ CONTENTS is nil. INFO is a plist holding contextual information."
;;;; Fixed Width
-(defun org-html-fixed-width (fixed-width contents info)
+(defun org-html-fixed-width (fixed-width _contents _info)
"Transcode a FIXED-WIDTH element from Org to HTML.
CONTENTS is nil. INFO is a plist holding contextual information."
(format "<pre class=\"example\">\n%s</pre>"
@@ -2398,7 +2495,7 @@ CONTENTS is nil. INFO is a plist holding contextual information."
;;;; Footnote Reference
-(defun org-html-footnote-reference (footnote-reference contents info)
+(defun org-html-footnote-reference (footnote-reference _contents info)
"Transcode a FOOTNOTE-REFERENCE element from Org to HTML.
CONTENTS is nil. INFO is a plist holding contextual information."
(concat
@@ -2427,8 +2524,6 @@ holding contextual information."
(unless (org-element-property :footnote-section-p headline)
(let* ((numberedp (org-export-numbered-headline-p headline info))
(numbers (org-export-get-headline-number headline info))
- (section-number (and numbers
- (mapconcat #'number-to-string numbers "-")))
(level (+ (org-export-get-relative-level headline info)
(1- (plist-get info :html-toplevel-hlevel))))
(todo (and (plist-get info :with-todo-keywords)
@@ -2500,7 +2595,7 @@ holding contextual information."
(org-html--container headline info)))))))
(defun org-html-format-headline-default-function
- (todo todo-type priority text tags info)
+ (todo _todo-type priority text tags info)
"Default format function for a headline.
See `org-html-format-headline-function' for details."
(let ((todo (org-html--todo todo info))
@@ -2519,19 +2614,19 @@ See `org-html-format-headline-function' for details."
;;;; Horizontal Rule
-(defun org-html-horizontal-rule (horizontal-rule contents info)
+(defun org-html-horizontal-rule (_horizontal-rule _contents info)
"Transcode an HORIZONTAL-RULE object from Org to HTML.
CONTENTS is nil. INFO is a plist holding contextual information."
(org-html-close-tag "hr" nil info))
;;;; Inline Src Block
-(defun org-html-inline-src-block (inline-src-block contents info)
+(defun org-html-inline-src-block (inline-src-block _contents info)
"Transcode an INLINE-SRC-BLOCK element from Org to HTML.
CONTENTS holds the contents of the item. INFO is a plist holding
contextual information."
(let ((lang (org-element-property :language inline-src-block))
- (code (org-html-format-code inline-src-block info))
+ (code (org-element-property :value inline-src-block))
(label
(let ((lbl (and (org-element-property :name inline-src-block)
(org-export-get-reference inline-src-block info))))
@@ -2568,7 +2663,7 @@ See `org-html-format-inlinetask-function' for details."
;;;; Italic
-(defun org-html-italic (italic contents info)
+(defun org-html-italic (_italic contents info)
"Transcode ITALIC from Org to HTML.
CONTENTS is the text with italic markup. INFO is a plist holding
contextual information."
@@ -2587,8 +2682,8 @@ INFO is a plist holding contextual information. See
org-html-checkbox-types)))))
(defun org-html-format-list-item (contents type checkbox info
- &optional term-counter-id
- headline)
+ &optional term-counter-id
+ headline)
"Format a list item into HTML."
(let ((class (if checkbox
(format " class=\"%s\""
@@ -2597,20 +2692,20 @@ INFO is a plist holding contextual information. See
(and checkbox " ")))
(br (org-html-close-tag "br" nil info)))
(concat
- (case type
- (ordered
+ (pcase type
+ (`ordered
(let* ((counter term-counter-id)
(extra (if counter (format " value=\"%s\"" counter) "")))
(concat
(format "<li%s%s>" class extra)
(when headline (concat headline br)))))
- (unordered
+ (`unordered
(let* ((id term-counter-id)
(extra (if id (format " id=\"%s\"" id) "")))
(concat
(format "<li%s%s>" class extra)
(when headline (concat headline br)))))
- (descriptive
+ (`descriptive
(let* ((term term-counter-id))
(setq term (or term "(no term)"))
;; Check-boxes in descriptive lists are associated to tag.
@@ -2619,10 +2714,10 @@ INFO is a plist holding contextual information. See
"<dd>"))))
(unless (eq type 'descriptive) checkbox)
(and contents (org-trim contents))
- (case type
- (ordered "</li>")
- (unordered "</li>")
- (descriptive "</dd>")))))
+ (pcase type
+ (`ordered "</li>")
+ (`unordered "</li>")
+ (`descriptive "</dd>")))))
(defun org-html-item (item contents info)
"Transcode an ITEM element from Org to HTML.
@@ -2639,7 +2734,7 @@ contextual information."
;;;; Keyword
-(defun org-html-keyword (keyword contents info)
+(defun org-html-keyword (keyword _contents info)
"Transcode a KEYWORD element from Org to HTML.
CONTENTS is nil. INFO is a plist holding contextual information."
(let ((key (org-element-property :key keyword))
@@ -2652,7 +2747,7 @@ CONTENTS is nil. INFO is a plist holding contextual information."
((string-match "\\<headlines\\>" value)
(let ((depth (and (string-match "\\<[0-9]+\\>" value)
(string-to-number (match-string 0 value))))
- (localp (org-string-match-p "\\<local\\>" value)))
+ (localp (string-match-p "\\<local\\>" value)))
(org-html-toc depth info (and localp keyword))))
((string= "listings" value) (org-html-list-of-listings info))
((string= "tables" value) (org-html-list-of-tables info))))))))
@@ -2661,10 +2756,11 @@ CONTENTS is nil. INFO is a plist holding contextual information."
(defun org-html-format-latex (latex-frag processing-type info)
"Format a LaTeX fragment LATEX-FRAG into HTML.
-PROCESSING-TYPE designates the tool used for conversion. It is
-a symbol among `mathjax', `dvipng', `imagemagick', `verbatim' nil
-and t. See `org-html-with-latex' for more information. INFO is
-a plist containing export properties."
+PROCESSING-TYPE designates the tool used for conversion. It can
+be `mathjax', `verbatim', nil, t or symbols in
+`org-preview-latex-process-alist', e.g., `dvipng', `dvisvgm' or
+`imagemagick'. See `org-html-with-latex' for more information.
+INFO is a plist containing export properties."
(let ((cache-relpath "") (cache-dir ""))
(unless (eq processing-type 'mathjax)
(let ((bfn (or (buffer-file-name)
@@ -2679,7 +2775,7 @@ a plist containing export properties."
"\n")
"\n")))))
(setq cache-relpath
- (concat "ltxpng/"
+ (concat (file-name-as-directory org-preview-latex-image-directory)
(file-name-sans-extension
(file-name-nondirectory bfn)))
cache-dir (file-name-directory bfn))
@@ -2689,51 +2785,51 @@ a plist containing export properties."
(setq latex-frag (concat latex-header latex-frag))))
(with-temp-buffer
(insert latex-frag)
- (org-format-latex cache-relpath cache-dir nil "Creating LaTeX Image..."
- nil processing-type)
+ (org-format-latex cache-relpath nil nil cache-dir nil
+ "Creating LaTeX Image..." nil processing-type)
(buffer-string))))
-(defun org-html-latex-environment (latex-environment contents info)
+(defun org-html-latex-environment (latex-environment _contents info)
"Transcode a LATEX-ENVIRONMENT element from Org to HTML.
CONTENTS is nil. INFO is a plist holding contextual information."
(let ((processing-type (plist-get info :with-latex))
(latex-frag (org-remove-indentation
(org-element-property :value latex-environment)))
(attributes (org-export-read-attribute :attr_html latex-environment)))
- (case processing-type
- ((t mathjax)
- (org-html-format-latex latex-frag 'mathjax info))
- ((dvipng imagemagick)
- (let ((formula-link
- (org-html-format-latex latex-frag processing-type info)))
- (when (and formula-link (string-match "file:\\([^]]*\\)" formula-link))
- ;; Do not provide a caption or a name to be consistent with
- ;; `mathjax' handling.
- (org-html--wrap-image
- (org-html--format-image
- (match-string 1 formula-link) attributes info) info))))
- (t latex-frag))))
+ (cond
+ ((memq processing-type '(t mathjax))
+ (org-html-format-latex latex-frag 'mathjax info))
+ ((assq processing-type org-preview-latex-process-alist)
+ (let ((formula-link
+ (org-html-format-latex latex-frag processing-type info)))
+ (when (and formula-link (string-match "file:\\([^]]*\\)" formula-link))
+ ;; Do not provide a caption or a name to be consistent with
+ ;; `mathjax' handling.
+ (org-html--wrap-image
+ (org-html--format-image
+ (match-string 1 formula-link) attributes info) info))))
+ (t latex-frag))))
;;;; Latex Fragment
-(defun org-html-latex-fragment (latex-fragment contents info)
+(defun org-html-latex-fragment (latex-fragment _contents info)
"Transcode a LATEX-FRAGMENT object from Org to HTML.
CONTENTS is nil. INFO is a plist holding contextual information."
(let ((latex-frag (org-element-property :value latex-fragment))
(processing-type (plist-get info :with-latex)))
- (case processing-type
- ((t mathjax)
- (org-html-format-latex latex-frag 'mathjax info))
- ((dvipng imagemagick)
- (let ((formula-link
- (org-html-format-latex latex-frag processing-type info)))
- (when (and formula-link (string-match "file:\\([^]]*\\)" formula-link))
- (org-html--format-image (match-string 1 formula-link) nil info))))
- (t latex-frag))))
+ (cond
+ ((memq processing-type '(t mathjax))
+ (org-html-format-latex latex-frag 'mathjax info))
+ ((assq processing-type org-preview-latex-process-alist)
+ (let ((formula-link
+ (org-html-format-latex latex-frag processing-type info)))
+ (when (and formula-link (string-match "file:\\([^]]*\\)" formula-link))
+ (org-html--format-image (match-string 1 formula-link) nil info))))
+ (t latex-frag))))
;;;; Line Break
-(defun org-html-line-break (line-break contents info)
+(defun org-html-line-break (_line-break _contents info)
"Transcode a LINE-BREAK object from Org to HTML.
CONTENTS is nil. INFO is a plist holding contextual information."
(concat (org-html-close-tag "br" nil info) "\n"))
@@ -2754,13 +2850,13 @@ if its description is a single link targeting an image file."
(org-element-map (org-element-contents link)
(cons 'plain-text org-element-all-objects)
(lambda (obj)
- (case (org-element-type obj)
- (plain-text (org-string-nw-p obj))
- (link (if (= link-count 1) t
- (incf link-count)
- (not (org-export-inline-image-p
- obj (plist-get info :html-inline-image-rules)))))
- (otherwise t)))
+ (pcase (org-element-type obj)
+ (`plain-text (org-string-nw-p obj))
+ (`link (if (= link-count 1) t
+ (cl-incf link-count)
+ (not (org-export-inline-image-p
+ obj (plist-get info :html-inline-image-rules)))))
+ (_ t)))
info t)))))
(defvar org-html-standalone-image-predicate)
@@ -2782,9 +2878,9 @@ further. For example, to check for only captioned standalone
images, set it to:
(lambda (paragraph) (org-element-property :caption paragraph))"
- (let ((paragraph (case (org-element-type element)
- (paragraph element)
- (link (org-export-get-parent element)))))
+ (let ((paragraph (pcase (org-element-type element)
+ (`paragraph element)
+ (`link (org-export-get-parent element)))))
(and (eq (org-element-type paragraph) 'paragraph)
(or (not (fboundp 'org-html-standalone-image-predicate))
(funcall org-html-standalone-image-predicate paragraph))
@@ -2792,13 +2888,13 @@ images, set it to:
(let ((link-count 0))
(org-element-map (org-element-contents paragraph)
(cons 'plain-text org-element-all-objects)
- #'(lambda (obj)
- (when (case (org-element-type obj)
- (plain-text (org-string-nw-p obj))
- (link (or (> (incf link-count) 1)
- (not (org-html-inline-image-p obj info))))
- (otherwise t))
- (throw 'exit nil)))
+ (lambda (obj)
+ (when (pcase (org-element-type obj)
+ (`plain-text (org-string-nw-p obj))
+ (`link (or (> (cl-incf link-count) 1)
+ (not (org-html-inline-image-p obj info))))
+ (_ t))
+ (throw 'exit nil)))
info nil 'link)
(= link-count 1))))))
@@ -2827,9 +2923,8 @@ INFO is a plist holding contextual information. See
(desc (org-string-nw-p desc))
(path
(cond
- ((member type '("http" "https" "ftp" "mailto"))
- (org-link-escape-browser
- (org-link-unescape (concat type ":" raw-path))))
+ ((member type '("http" "https" "ftp" "mailto" "news"))
+ (url-encode-url (org-link-unescape (concat type ":" raw-path))))
((string= type "file")
;; Treat links to ".org" files as ".html", if needed.
(setq raw-path
@@ -2842,15 +2937,19 @@ INFO is a plist holding contextual information. See
((and home use-abs-url)
(setq raw-path (concat (file-name-as-directory home) raw-path))))
;; Add search option, if any. A search option can be
- ;; relative to a custom-id, a headline title a name,
- ;; a target or a radio-target.
+ ;; relative to a custom-id, a headline title, a name or
+ ;; a target.
(let ((option (org-element-property :search-option link)))
- (if (not option) raw-path
- (concat raw-path
- "#"
- (org-publish-resolve-external-link
- option
- (org-element-property :path link))))))
+ (cond ((not option) raw-path)
+ ;; Since HTML back-end use custom-id value as-is,
+ ;; resolving is them is trivial.
+ ((eq (string-to-char option) ?#) (concat raw-path option))
+ (t
+ (concat raw-path
+ "#"
+ (org-publish-resolve-external-link
+ option
+ (org-element-property :path link)))))))
(t raw-path)))
;; Extract attributes from parent's paragraph. HACK: Only do
;; this for the first link in parent (inner image link for
@@ -2891,9 +2990,9 @@ INFO is a plist holding contextual information. See
(let ((destination (if (string= type "fuzzy")
(org-export-resolve-fuzzy-link link info)
(org-export-resolve-id-link link info))))
- (case (org-element-type destination)
+ (pcase (org-element-type destination)
;; ID link points to an external file.
- (plain-text
+ (`plain-text
(let ((fragment (concat "ID-" path))
;; Treat links to ".org" files as ".html", if needed.
(path (funcall link-org-files-as-html-maybe
@@ -2901,13 +3000,13 @@ INFO is a plist holding contextual information. See
(format "<a href=\"%s#%s\"%s>%s</a>"
path fragment attributes (or desc destination))))
;; Fuzzy link points nowhere.
- ((nil)
+ (`nil
(format "<i>%s</i>"
(or desc
(org-export-data
(org-element-property :raw-link link) info))))
;; Link points to a headline.
- (headline
+ (`headline
(let ((href (or (org-element-property :CUSTOM_ID destination)
(org-export-get-reference destination info)))
;; What description to use?
@@ -2927,7 +3026,7 @@ INFO is a plist holding contextual information. See
(org-element-property :title destination) info)))))
(format "<a href=\"#%s\"%s>%s</a>" href attributes desc)))
;; Fuzzy link points to a target or an element.
- (t
+ (_
(let* ((ref (org-export-get-reference destination info))
(org-html-standalone-image-predicate
#'org-html--has-caption-p)
@@ -2964,13 +3063,16 @@ INFO is a plist holding contextual information. See
desc))
;; External link without a description part.
(path (let ((path (org-html-encode-plain-text path)))
- (format "<a href=\"%s\"%s>%s</a>" path attributes path)))
+ (format "<a href=\"%s\"%s>%s</a>"
+ path
+ attributes
+ (org-link-unescape path))))
;; No path, only description. Try to do something useful.
(t (format "<i>%s</i>" desc)))))
;;;; Node Property
-(defun org-html-node-property (node-property contents info)
+(defun org-html-node-property (node-property _contents _info)
"Transcode a NODE-PROPERTY element from Org to HTML.
CONTENTS is nil. INFO is a plist holding contextual
information."
@@ -3007,16 +3109,16 @@ the plist used as a communication channel."
(let ((raw (org-export-data
(org-export-get-caption paragraph) info))
(org-html-standalone-image-predicate
- 'org-html--has-caption-p))
+ #'org-html--has-caption-p))
(if (not (org-string-nw-p raw)) raw
- (concat
- "<span class=\"figure-number\">"
- (format (org-html--translate "Figure %d:" info)
- (org-export-get-ordinal
- (org-element-map paragraph 'link
- 'identity info t)
- info nil 'org-html-standalone-image-p))
- "</span> " raw))))
+ (concat "<span class=\"figure-number\">"
+ (format (org-html--translate "Figure %d:" info)
+ (org-export-get-ordinal
+ (org-element-map paragraph 'link
+ #'identity info t)
+ info nil #'org-html-standalone-image-p))
+ " </span>"
+ raw))))
(label (and (org-element-property :name paragraph)
(org-export-get-reference paragraph info))))
(org-html--wrap-image contents info caption label)))
@@ -3034,26 +3136,25 @@ the plist used as a communication channel."
"Insert the beginning of the HTML list depending on TYPE.
When ARG1 is a string, use it as the start parameter for ordered
lists."
- (case type
- (ordered
+ (pcase type
+ (`ordered
(format "<ol class=\"org-ol\"%s>"
(if arg1 (format " start=\"%d\"" arg1) "")))
- (unordered "<ul class=\"org-ul\">")
- (descriptive "<dl class=\"org-dl\">")))
+ (`unordered "<ul class=\"org-ul\">")
+ (`descriptive "<dl class=\"org-dl\">")))
(defun org-html-end-plain-list (type)
"Insert the end of the HTML list depending on TYPE."
- (case type
- (ordered "</ol>")
- (unordered "</ul>")
- (descriptive "</dl>")))
+ (pcase type
+ (`ordered "</ol>")
+ (`unordered "</ul>")
+ (`descriptive "</dl>")))
-(defun org-html-plain-list (plain-list contents info)
+(defun org-html-plain-list (plain-list contents _info)
"Transcode a PLAIN-LIST element from Org to HTML.
CONTENTS is the contents of the list. INFO is a plist holding
contextual information."
- (let* (arg1 ;; (assoc :counter (org-element-map plain-list 'item
- (type (org-element-property :type plain-list)))
+ (let ((type (org-element-property :type plain-list)))
(format "%s\n%s%s"
(org-html-begin-plain-list type)
contents (org-html-end-plain-list type))))
@@ -3062,13 +3163,10 @@ contextual information."
(defun org-html-convert-special-strings (string)
"Convert special characters in STRING to HTML."
- (let ((all org-html-special-string-regexps)
- e a re rpl start)
- (while (setq a (pop all))
- (setq re (car a) rpl (cdr a) start 0)
- (while (string-match re string start)
- (setq string (replace-match rpl t nil string))))
- string))
+ (dolist (a org-html-special-string-regexps string)
+ (let ((re (car a))
+ (rpl (cdr a)))
+ (setq string (replace-regexp-in-string re rpl string t)))))
(defun org-html-encode-plain-text (text)
"Convert plain text characters from TEXT to HTML equivalent.
@@ -3102,34 +3200,31 @@ contextual information."
;; Planning
-(defun org-html-planning (planning contents info)
+(defun org-html-planning (planning _contents info)
"Transcode a PLANNING element from Org to HTML.
CONTENTS is nil. INFO is a plist used as a communication
channel."
- (let ((span-fmt "<span class=\"timestamp-kwd\">%s</span> <span class=\"timestamp\">%s</span>"))
- (format
- "<p><span class=\"timestamp-wrapper\">%s</span></p>"
- (mapconcat
- 'identity
- (delq nil
- (list
- (let ((closed (org-element-property :closed planning)))
- (when closed
- (format span-fmt org-closed-string
- (org-timestamp-translate closed))))
- (let ((deadline (org-element-property :deadline planning)))
- (when deadline
- (format span-fmt org-deadline-string
- (org-timestamp-translate deadline))))
- (let ((scheduled (org-element-property :scheduled planning)))
- (when scheduled
- (format span-fmt org-scheduled-string
- (org-timestamp-translate scheduled))))))
- " "))))
+ (format
+ "<p><span class=\"timestamp-wrapper\">%s</span></p>"
+ (org-trim
+ (mapconcat
+ (lambda (pair)
+ (let ((timestamp (cdr pair)))
+ (when timestamp
+ (let ((string (car pair)))
+ (format "<span class=\"timestamp-kwd\">%s</span> \
+<span class=\"timestamp\">%s</span> "
+ string
+ (org-html-plain-text (org-timestamp-translate timestamp)
+ info))))))
+ `((,org-closed-string . ,(org-element-property :closed planning))
+ (,org-deadline-string . ,(org-element-property :deadline planning))
+ (,org-scheduled-string . ,(org-element-property :scheduled planning)))
+ ""))))
;;;; Property Drawer
-(defun org-html-property-drawer (property-drawer contents info)
+(defun org-html-property-drawer (_property-drawer contents _info)
"Transcode a PROPERTY-DRAWER element from Org to HTML.
CONTENTS holds the contents of the drawer. INFO is a plist
holding contextual information."
@@ -3138,11 +3233,19 @@ holding contextual information."
;;;; Quote Block
-(defun org-html-quote-block (quote-block contents info)
+(defun org-html-quote-block (quote-block contents _info)
"Transcode a QUOTE-BLOCK element from Org to HTML.
CONTENTS holds the contents of the block. INFO is a plist
holding contextual information."
- (format "<blockquote>\n%s</blockquote>" contents))
+ (format "<blockquote%s>\n%s</blockquote>"
+ (let* ((name (org-element-property :name quote-block))
+ (attributes (org-export-read-attribute :attr_html quote-block))
+ (a (org-html--make-attribute-string
+ (if (or (not name) (plist-member attributes :id))
+ attributes
+ (plist-put attributes :id name)))))
+ (if (org-string-nw-p a) (concat " " a) ""))
+ contents))
;;;; Section
@@ -3185,48 +3288,60 @@ contextual information."
CONTENTS holds the contents of the block. INFO is a plist
holding contextual information."
(let* ((block-type (org-element-property :type special-block))
- (contents (or contents ""))
- (html5-fancy (and (org-html--html5-fancy-p info)
- (member block-type org-html-html5-elements)))
- (attributes (org-export-read-attribute :attr_html special-block)))
+ (html5-fancy (and (org-html--html5-fancy-p info)
+ (member block-type org-html-html5-elements)))
+ (attributes (org-export-read-attribute :attr_html special-block)))
(unless html5-fancy
(let ((class (plist-get attributes :class)))
- (setq attributes (plist-put attributes :class
- (if class (concat class " " block-type)
- block-type)))))
- (setq attributes (org-html--make-attribute-string attributes))
- (when (not (equal attributes ""))
- (setq attributes (concat " " attributes)))
- (if html5-fancy
- (format "<%s%s>\n%s</%s>" block-type attributes
- contents block-type)
- (format "<div%s>\n%s\n</div>" attributes contents))))
+ (setq attributes (plist-put attributes :class
+ (if class (concat class " " block-type)
+ block-type)))))
+ (let* ((contents (or contents ""))
+ (name (org-element-property :name special-block))
+ (a (org-html--make-attribute-string
+ (if (or (not name) (plist-member attributes :id))
+ attributes
+ (plist-put attributes :id name))))
+ (str (if (org-string-nw-p a) (concat " " a) "")))
+ (if html5-fancy
+ (format "<%s%s>\n%s</%s>" block-type str contents block-type)
+ (format "<div%s>\n%s\n</div>" str contents)))))
;;;; Src Block
-(defun org-html-src-block (src-block contents info)
+(defun org-html-src-block (src-block _contents info)
"Transcode a SRC-BLOCK element from Org to HTML.
CONTENTS holds the contents of the item. INFO is a plist holding
contextual information."
(if (org-export-read-attribute :attr_html src-block :textarea)
(org-html--textarea-block src-block)
(let ((lang (org-element-property :language src-block))
- (caption (org-export-get-caption src-block))
(code (org-html-format-code src-block info))
(label (let ((lbl (and (org-element-property :name src-block)
(org-export-get-reference src-block info))))
(if lbl (format " id=\"%s\"" lbl) ""))))
(if (not lang) (format "<pre class=\"example\"%s>\n%s</pre>" label code)
- (format
- "<div class=\"org-src-container\">\n%s%s\n</div>"
- (if (not caption) ""
- (format "<label class=\"org-src-name\">%s</label>"
- (org-export-data caption info)))
- (format "\n<pre class=\"src src-%s\"%s>%s</pre>" lang label code))))))
+ (format "<div class=\"org-src-container\">\n%s%s\n</div>"
+ ;; Build caption.
+ (let ((caption (org-export-get-caption src-block)))
+ (if (not caption) ""
+ (let ((listing-number
+ (format
+ "<span class=\"listing-number\">%s </span>"
+ (format
+ (org-html--translate "Listing %d:" info)
+ (org-export-get-ordinal
+ src-block info nil #'org-html--has-caption-p)))))
+ (format "<label class=\"org-src-name\">%s%s</label>"
+ listing-number
+ (org-trim (org-export-data caption info))))))
+ ;; Contents.
+ (format "<pre class=\"src src-%s\"%s>%s</pre>"
+ lang label code))))))
;;;; Statistics Cookie
-(defun org-html-statistics-cookie (statistics-cookie contents info)
+(defun org-html-statistics-cookie (statistics-cookie _contents _info)
"Transcode a STATISTICS-COOKIE object from Org to HTML.
CONTENTS is nil. INFO is a plist holding contextual information."
(let ((cookie-value (org-element-property :value statistics-cookie)))
@@ -3234,7 +3349,7 @@ CONTENTS is nil. INFO is a plist holding contextual information."
;;;; Strike-Through
-(defun org-html-strike-through (strike-through contents info)
+(defun org-html-strike-through (_strike-through contents info)
"Transcode STRIKE-THROUGH from Org to HTML.
CONTENTS is the text with strike-through markup. INFO is a plist
holding contextual information."
@@ -3245,7 +3360,7 @@ holding contextual information."
;;;; Subscript
-(defun org-html-subscript (subscript contents info)
+(defun org-html-subscript (_subscript contents _info)
"Transcode a SUBSCRIPT object from Org to HTML.
CONTENTS is the contents of the object. INFO is a plist holding
contextual information."
@@ -3253,7 +3368,7 @@ contextual information."
;;;; Superscript
-(defun org-html-superscript (superscript contents info)
+(defun org-html-superscript (_superscript contents _info)
"Transcode a SUPERSCRIPT object from Org to HTML.
CONTENTS is the contents of the object. INFO is a plist holding
contextual information."
@@ -3302,40 +3417,45 @@ communication channel."
;; Rules are ignored since table separators are deduced from
;; borders of the current row.
(when (eq (org-element-property :type table-row) 'standard)
- (let* ((rowgroup-number (org-export-table-row-group table-row info))
- (row-number (org-export-table-row-number table-row info))
- (start-rowgroup-p
+ (let* ((group (org-export-table-row-group table-row info))
+ (number (org-export-table-row-number table-row info))
+ (start-group-p
(org-export-table-row-starts-rowgroup-p table-row info))
- (end-rowgroup-p
+ (end-group-p
(org-export-table-row-ends-rowgroup-p table-row info))
- ;; `top-row-p' and `end-rowgroup-p' are not used directly
- ;; but should be set so that `org-html-table-row-tags' can
- ;; use them (see the docstring of this variable.)
- (top-row-p (and (equal start-rowgroup-p '(top))
- (equal end-rowgroup-p '(below top))))
- (bottom-row-p (and (equal start-rowgroup-p '(above))
- (equal end-rowgroup-p '(bottom above))))
- (rowgroup-tags
+ (topp (and (equal start-group-p '(top))
+ (equal end-group-p '(below top))))
+ (bottomp (and (equal start-group-p '(above))
+ (equal end-group-p '(bottom above))))
+ (row-open-tag
+ (pcase (plist-get info :html-table-row-open-tag)
+ ((and accessor (pred functionp))
+ (funcall accessor
+ number group start-group-p end-group-p topp bottomp))
+ (accessor accessor)))
+ (row-close-tag
+ (pcase (plist-get info :html-table-row-close-tag)
+ ((and accessor (pred functionp))
+ (funcall accessor
+ number group start-group-p end-group-p topp bottomp))
+ (accessor accessor)))
+ (group-tags
(cond
- ;; Case 1: Row belongs to second or subsequent rowgroups.
- ((not (= 1 rowgroup-number))
- '("<tbody>" . "\n</tbody>"))
- ;; Case 2: Row is from first rowgroup. Table has >=1 rowgroups.
+ ;; Row belongs to second or subsequent groups.
+ ((not (= 1 group)) '("<tbody>" . "\n</tbody>"))
+ ;; Row is from first group. Table has >=1 groups.
((org-export-table-has-header-p
(org-export-get-parent-table table-row) info)
'("<thead>" . "\n</thead>"))
- ;; Case 2: Row is from first and only row group.
+ ;; Row is from first and only group.
(t '("<tbody>" . "\n</tbody>")))))
- (concat
- ;; Begin a rowgroup?
- (when start-rowgroup-p (car rowgroup-tags))
- ;; Actual table row
- (concat "\n" (eval (car (plist-get info :html-table-row-tags)))
- contents
- "\n"
- (eval (cdr (plist-get info :html-table-row-tags))))
- ;; End a rowgroup?
- (when end-rowgroup-p (cdr rowgroup-tags))))))
+ (concat (and start-group-p (car group-tags))
+ (concat "\n"
+ row-open-tag
+ contents
+ "\n"
+ row-close-tag)
+ (and end-group-p (cdr group-tags))))))
;;;; Table
@@ -3351,7 +3471,7 @@ INFO is a plist used as a communication channel."
(if (not special-column-p) (org-element-contents table-row)
(cdr (org-element-contents table-row)))))
-(defun org-html-table--table.el-table (table info)
+(defun org-html-table--table.el-table (table _info)
"Format table.el tables into HTML.
INFO is a plist used as a communication channel."
(when (eq (org-element-property :type table) 'table.el)
@@ -3372,63 +3492,61 @@ INFO is a plist used as a communication channel."
"Transcode a TABLE element from Org to HTML.
CONTENTS is the contents of the table. INFO is a plist holding
contextual information."
- (case (org-element-property :type table)
- ;; Case 1: table.el table. Convert it using appropriate tools.
- (table.el (org-html-table--table.el-table table info))
- ;; Case 2: Standard table.
- (t
- (let* ((caption (org-export-get-caption table))
- (number (org-export-get-ordinal
- table info nil #'org-html--has-caption-p))
- (attributes
- (org-html--make-attribute-string
- (org-combine-plists
- (and (org-element-property :name table)
- (list :id (org-export-get-reference table info)))
- (and (not (org-html-html5-p info))
- (plist-get info :html-table-attributes))
- (org-export-read-attribute :attr_html table))))
- (alignspec
- (if (and (boundp 'org-html-format-table-no-css)
- org-html-format-table-no-css)
- "align=\"%s\"" "class=\"org-%s\""))
- (table-column-specs
- (function
- (lambda (table info)
- (mapconcat
- (lambda (table-cell)
- (let ((alignment (org-export-table-cell-alignment
- table-cell info)))
- (concat
- ;; Begin a colgroup?
- (when (org-export-table-cell-starts-colgroup-p
- table-cell info)
- "\n<colgroup>")
- ;; Add a column. Also specify its alignment.
- (format "\n%s"
- (org-html-close-tag
- "col" (concat " " (format alignspec alignment)) info))
- ;; End a colgroup?
- (when (org-export-table-cell-ends-colgroup-p
- table-cell info)
- "\n</colgroup>"))))
- (org-html-table-first-row-data-cells table info) "\n")))))
- (format "<table%s>\n%s\n%s\n%s</table>"
- (if (equal attributes "") "" (concat " " attributes))
- (if (not caption) ""
- (format (if (plist-get info :html-table-caption-above)
- "<caption class=\"t-above\">%s</caption>"
- "<caption class=\"t-bottom\">%s</caption>")
- (concat
- "<span class=\"table-number\">"
- (format (org-html--translate "Table %d:" info) number)
- "</span> " (org-export-data caption info))))
- (funcall table-column-specs table info)
- contents)))))
+ (if (eq (org-element-property :type table) 'table.el)
+ ;; "table.el" table. Convert it using appropriate tools.
+ (org-html-table--table.el-table table info)
+ ;; Standard table.
+ (let* ((caption (org-export-get-caption table))
+ (number (org-export-get-ordinal
+ table info nil #'org-html--has-caption-p))
+ (attributes
+ (org-html--make-attribute-string
+ (org-combine-plists
+ (and (org-element-property :name table)
+ (list :id (org-export-get-reference table info)))
+ (and (not (org-html-html5-p info))
+ (plist-get info :html-table-attributes))
+ (org-export-read-attribute :attr_html table))))
+ (alignspec
+ (if (bound-and-true-p org-html-format-table-no-css)
+ "align=\"%s\""
+ "class=\"org-%s\""))
+ (table-column-specs
+ (lambda (table info)
+ (mapconcat
+ (lambda (table-cell)
+ (let ((alignment (org-export-table-cell-alignment
+ table-cell info)))
+ (concat
+ ;; Begin a colgroup?
+ (when (org-export-table-cell-starts-colgroup-p
+ table-cell info)
+ "\n<colgroup>")
+ ;; Add a column. Also specify its alignment.
+ (format "\n%s"
+ (org-html-close-tag
+ "col" (concat " " (format alignspec alignment)) info))
+ ;; End a colgroup?
+ (when (org-export-table-cell-ends-colgroup-p
+ table-cell info)
+ "\n</colgroup>"))))
+ (org-html-table-first-row-data-cells table info) "\n"))))
+ (format "<table%s>\n%s\n%s\n%s</table>"
+ (if (equal attributes "") "" (concat " " attributes))
+ (if (not caption) ""
+ (format (if (plist-get info :html-table-caption-above)
+ "<caption class=\"t-above\">%s</caption>"
+ "<caption class=\"t-bottom\">%s</caption>")
+ (concat
+ "<span class=\"table-number\">"
+ (format (org-html--translate "Table %d:" info) number)
+ "</span> " (org-export-data caption info))))
+ (funcall table-column-specs table info)
+ contents))))
;;;; Target
-(defun org-html-target (target contents info)
+(defun org-html-target (target _contents info)
"Transcode a TARGET object from Org to HTML.
CONTENTS is nil. INFO is a plist holding contextual
information."
@@ -3437,7 +3555,7 @@ information."
;;;; Timestamp
-(defun org-html-timestamp (timestamp contents info)
+(defun org-html-timestamp (timestamp _contents info)
"Transcode a TIMESTAMP object from Org to HTML.
CONTENTS is nil. INFO is a plist holding contextual
information."
@@ -3447,7 +3565,7 @@ information."
;;;; Underline
-(defun org-html-underline (underline contents info)
+(defun org-html-underline (_underline contents info)
"Transcode UNDERLINE from Org to HTML.
CONTENTS is the text with underline markup. INFO is a plist
holding contextual information."
@@ -3457,7 +3575,7 @@ holding contextual information."
;;;; Verbatim
-(defun org-html-verbatim (verbatim contents info)
+(defun org-html-verbatim (verbatim _contents info)
"Transcode VERBATIM from Org to HTML.
CONTENTS is nil. INFO is a plist holding contextual
information."
@@ -3466,7 +3584,7 @@ information."
;;;; Verse Block
-(defun org-html-verse-block (verse-block contents info)
+(defun org-html-verse-block (_verse-block contents info)
"Transcode a VERSE-BLOCK element from Org to HTML.
CONTENTS is verse block contents. INFO is a plist holding
contextual information."
@@ -3481,15 +3599,14 @@ contextual information."
;; non-breaking space.
(while (string-match "^[ \t]+" contents)
(let* ((num-ws (length (match-string 0 contents)))
- (ws (let (out) (dotimes (i num-ws out)
- (setq out (concat out "&#xa0;"))))))
+ (ws (org-html--make-string num-ws "&#xa0;")))
(setq contents (replace-match ws nil t contents))))
(format "<p class=\"verse\">\n%s</p>" contents))
;;; Filter Functions
-(defun org-html-final-function (contents backend info)
+(defun org-html-final-function (contents _backend info)
"Filter to indent the HTML and convert HTML entities."
(with-temp-buffer
(insert contents)
@@ -3539,10 +3656,10 @@ is non-nil."
;;;###autoload
(defun org-html-convert-region-to-html ()
- "Assume the current region has org-mode syntax, and convert it to HTML.
+ "Assume the current region has Org syntax, and convert it to HTML.
This can be used in any buffer. For example, you can write an
-itemized list in org-mode syntax in an HTML buffer and use this
-command to convert it."
+itemized list in Org syntax in an HTML buffer and use this command
+to convert it."
(interactive)
(org-export-replace-region-by 'html))