ox-html: Use options instead of hard-coded variables

* contrib/lisp/ox-s5.el (org-s5--format-toc-headline): Apply signature
  change.

* lisp/ox-md.el (org-md-headline): Apply signature change.

* lisp/ox-html.el (org-html-format-drawer-function,
  org-html-publish-to-html): Small reformatting.

(org-html-infojs-install-script, org-html--build-meta-info,
org-html--build-mathjax-config, org-html-format-spec,
org-html--build-pre/postamble, org-html-template, org-html-toc,
org-html--format-toc-headline, org-html-list-of-listings,
org-html-list-of-tables, org-html-bold, org-html-drawer,
org-html-headline, org-html-inlinetask, org-html-italic,
org-html-checkbox, org-html-inline-image-p, org-html-link,
org-html-section, org-html-strike-through, org-html-table-cell,
org-html-table-row, org-html-underline, org-html-verbatim,
org-html-final-function, org-html-export-to-html): Do not use
hard-coded variable names.

(org-html-format-headline-function,
org-html-format-inlinetask-function): Change default value.  Require
an additional argument.

(org-html-format-footnote-reference,
org-html-format-footnotes-section,
org-html-format-footnote-definition, org-html-format-headline,
org-html-format-headline--wrap, org-html-format-section): Remove
functions.

(org-html-footnote-section, org-html-footnote-reference): Apply
function removal.  Do not use hard-coded variable names.

(org-html--anchor, org-html--todo, org-html--tags): Change signature.
Do not use hard-coded variable names.

(org-html-radio-target, org-html-target): Apply signature change.

(org-html-format-headline-default-function,
org-html-format-inlinetask-default-function): New functions.
This commit is contained in:
Nicolas Goaziou 2014-07-29 14:42:15 +02:00
parent 3c22bb19e0
commit c9ca0b6df8
3 changed files with 234 additions and 274 deletions

View File

@ -201,7 +201,7 @@ INFO is a plist used as a communication channel."
(concat section-number
(org-export-data
(org-export-get-alt-title headline info) info)
(and tags "   ") (org-html--tags tags))))
(and tags "   ") (org-html--tags tags info))))
(defun org-s5-toc (depth info)
(let* ((headlines (org-export-collect-headlines info depth))

View File

@ -491,18 +491,19 @@ Option settings will replace the %MANAGER-OPTIONS cookie."
EXP-PLIST is a plist containing export options. BACKEND is the
export back-end currently used."
(unless (or (memq 'body-only (plist-get exp-plist :export-options))
(not org-html-use-infojs)
(and (eq org-html-use-infojs 'when-configured)
(or (not (plist-get exp-plist :infojs-opt))
(string= "" (plist-get exp-plist :infojs-opt))
(string-match "\\<view:nil\\>"
(plist-get exp-plist :infojs-opt)))))
(let* ((template org-html-infojs-template)
(not (plist-get exp-plist :html-use-infojs))
(and (eq (plist-get exp-plist :html-use-infojs) 'when-configured)
(let ((opt (plist-get exp-plist :infojs-opt)))
(or (not opt)
(string= "" opt)
(string-match "\\<view:nil\\>" opt)))))
(let* ((template (plist-get exp-plist :html-infojs-template))
(ptoc (plist-get exp-plist :with-toc))
(hlevels (plist-get exp-plist :headline-levels))
(sdepth hlevels)
(tdepth (if (integerp ptoc) (min ptoc hlevels) hlevels))
(options (plist-get exp-plist :infojs-opt))
(infojs-opt (plist-get exp-plist :html-infojs-options))
(table org-html-infojs-opts-table)
style)
(dolist (entry table)
@ -511,7 +512,7 @@ export back-end currently used."
;; Compute default values for script option OPT from
;; `org-html-infojs-options' variable.
(default
(let ((default (cdr (assq opt org-html-infojs-options))))
(let ((default (cdr (assq opt infojs-opt))))
(if (and (symbolp default) (not (memq default '(t nil))))
(plist-get exp-plist default)
default)))
@ -548,9 +549,9 @@ export back-end currently used."
(push (cons "TOC_DEPTH" tdepth) style)
;; Build style string.
(setq style (mapconcat
(lambda (x) (format "org_html_manager.set(\"%s\", \"%s\");"
(car x)
(cdr x)))
(lambda (x)
(format "org_html_manager.set(\"%s\", \"%s\");"
(car x) (cdr x)))
style "\n"))
(when (and style (> (length style) 0))
(and (string-match "%MANAGER_OPTIONS" template)
@ -609,8 +610,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:
@ -667,20 +667,22 @@ document title."
:group 'org-export-html
:type 'integer)
(defcustom org-html-format-headline-function 'ignore
(defcustom org-html-format-headline-function
'org-html-format-headline-default-function
"Function to format headline text.
This function will be called with 5 arguments:
This function will be called with six arguments:
TODO the todo keyword (string or nil).
TODO-TYPE the type of todo (symbol: `todo', `done', nil)
PRIORITY the priority of the headline (integer or nil)
TEXT the main headline text (string).
TAGS the tags (string or nil).
INFO the export options (plist).
The function result will be used in the section format string."
:group 'org-export-html
:version "24.4"
:package-version '(Org . "8.0")
:version "24.5"
:package-version '(Org . "8.3")
:type 'function)
;;;; HTML-specific
@ -696,21 +698,23 @@ but without \"name\" attribute."
;;;; Inlinetasks
(defcustom org-html-format-inlinetask-function 'ignore
(defcustom org-html-format-inlinetask-function
'org-html-format-inlinetask-default-function
"Function called to format an inlinetask in HTML code.
The function must accept six parameters:
The function must accept seven parameters:
TODO the todo keyword, as a string
TODO-TYPE the todo type, a symbol among `todo', `done' and nil.
PRIORITY the inlinetask priority, as a string
NAME the inlinetask name, as a string.
TAGS the inlinetask tags, as a list of strings.
CONTENTS the contents of the inlinetask, as a string.
INFO the export options, as a plist
The function should return the string to be exported."
:group 'org-export-html
:version "24.4"
:package-version '(Org . "8.0")
:version "24.5"
:package-version '(Org . "8.3")
:type 'function)
;;;; LaTeX
@ -1551,32 +1555,6 @@ Replaces invalid characters with \"_\"."
(setq kwd (replace-match "_" t t kwd))))
kwd)
(defun org-html-format-footnote-reference (n def refcnt)
"Format footnote reference N with definition DEF into HTML."
(let ((extra (if (= refcnt 1) "" (format ".%d" refcnt))))
(format org-html-footnote-format
(let* ((id (format "fnr.%s%s" n extra))
(href (format " href=\"#fn.%s\"" n))
(attributes (concat " class=\"footref\"" href)))
(org-html--anchor id n attributes)))))
(defun org-html-format-footnotes-section (section-name definitions)
"Format footnotes section SECTION-NAME."
(if (not definitions) ""
(format org-html-footnotes-section section-name definitions)))
(defun org-html-format-footnote-definition (fn)
"Format the footnote definition FN."
(let ((n (car fn)) (def (cdr fn)))
(format
"<div class=\"footdef\">%s %s</div>\n"
(format org-html-footnote-format
(let* ((id (format "fn.%s" n))
(href (format " href=\"#fnr.%s\"" n))
(attributes (concat " class=\"footnum\"" href)))
(org-html--anchor id n attributes)))
def)))
(defun org-html-footnote-section (info)
"Format the footnote section.
INFO is a plist used as a communication channel."
@ -1589,11 +1567,26 @@ INFO is a plist used as a communication channel."
(format "<p>%s</p>"
(org-trim (org-export-data raw info))))))))
(when fn-alist
(org-html-format-footnotes-section
(format
(plist-get info :html-footnotes-section)
(org-html--translate "Footnotes" info)
(format
"\n%s\n"
(mapconcat 'org-html-format-footnote-definition fn-alist "\n"))))))
(mapconcat
(lambda (fn)
(let ((n (car fn)) (def (cdr fn)))
(format
"<div class=\"footdef\">%s %s</div>\n"
(format
(plist-get info :html-footnote-format)
(org-html--anchor
(format "fn.%d" n)
n
(format " class=\"footnum\" href=\"#fnr.%d\"" n)
info))
def)))
fn-alist
"\n"))))))
;;; Template
@ -1626,7 +1619,9 @@ INFO is a plist used as a communication channel."
(format "<title>%s</title>\n" title)
(when (plist-get info :time-stamp-file)
(format-time-string
(concat "<!-- " org-html-metadata-timestamp-format " -->\n")))
(concat "<!-- "
(plist-get info :html-metadata-timestamp-format)
" -->\n")))
(format
(if (org-html-html5-p info)
(org-html-close-tag "meta" " charset=\"%s\"" info)
@ -1681,8 +1676,8 @@ INFO is a plist used as a communication channel."
(when (and (memq (plist-get info :with-latex) '(mathjax t))
(org-element-map (plist-get info :parse-tree)
'(latex-fragment latex-environment) 'identity info t))
(let ((template org-html-mathjax-template)
(options org-html-mathjax-options)
(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 (yes " ") (no "// ") x)
(mapc
@ -1714,7 +1709,8 @@ INFO is a plist used as a communication channel."
used in the preamble or postamble."
`((?t . ,(org-export-data (plist-get info :title) info))
(?d . ,(org-export-data (org-export-get-date info) info))
(?T . ,(format-time-string org-html-metadata-timestamp-format))
(?T . ,(format-time-string
(plist-get info :html-metadata-timestamp-format)))
(?a . ,(org-export-data (plist-get info :author) info))
(?e . ,(mapconcat
(lambda (e)
@ -1723,10 +1719,10 @@ used in the preamble or postamble."
", "))
(?c . ,(plist-get info :creator))
(?C . ,(let ((file (plist-get info :input-file)))
(format-time-string org-html-metadata-timestamp-format
(if file (nth 5 (file-attributes file))
(current-time)))))
(?v . ,(or org-html-validation-link ""))))
(format-time-string
(plist-get info :html-metadata-timestamp-format)
(if file (nth 5 (file-attributes file)) (current-time)))))
(?v . ,(or (plist-get info :html-validation-link) ""))))
(defun org-html--build-pre/postamble (type info)
"Return document preamble or postamble as a string, or nil.
@ -1766,7 +1762,8 @@ communication channel."
(format
"<p class=\"date\">%s: %s</p>\n"
(org-html--translate "Created" info)
(format-time-string org-html-metadata-timestamp-format)))
(format-time-string
(plist-get info :html-metadata-timestamp-format))))
(when (plist-get info :with-creator)
(format "<p class=\"creator\">%s</p>\n" creator))
(format "<p class=\"validation\">%s</p>\n"
@ -1782,14 +1779,15 @@ communication channel."
(eval
(intern (format "org-html-%s-format" type))))))
spec))))))
(when (org-string-nw-p section-contents)
(concat
(format "<%s id=\"%s\" class=\"%s\">\n"
(nth 1 (assq type org-html-divs))
(nth 2 (assq type org-html-divs))
org-html--pre/postamble-class)
(org-element-normalize-string section-contents)
(format "</%s>\n" (nth 1 (assq type org-html-divs)))))))))
(let ((div (assq type (plist-get info :html-divs))))
(when (org-string-nw-p section-contents)
(concat
(format "<%s id=\"%s\" class=\"%s\">\n"
(nth 1 div)
(nth 2 div)
org-html--pre/postamble-class)
(org-element-normalize-string section-contents)
(format "</%s>\n" (nth 1 div)))))))))
(defun org-html-inner-template (contents info)
"Return body of document string after HTML conversion.
@ -1810,20 +1808,19 @@ CONTENTS is the transcoded contents string. INFO is a plist
holding export options."
(concat
(when (and (not (org-html-html5-p info)) (org-html-xhtml-p info))
(let ((decl (or (and (stringp org-html-xml-declaration)
org-html-xml-declaration)
(cdr (assoc (plist-get info :html-extension)
org-html-xml-declaration))
(cdr (assoc "html" org-html-xml-declaration))
"")))
(when (not (or (eq nil decl) (string= "" decl)))
(let* ((xml-declaration (plist-get info :html-xml-declaration))
(decl (or (and (stringp xml-declaration) xml-declaration)
(cdr (assoc (plist-get info :html-extension)
xml-declaration))
(cdr (assoc "html" xml-declaration))
"")))
(when (not (or (not decl) (string= "" decl)))
(format "%s\n"
(format decl
(or (and org-html-coding-system
(fboundp 'coding-system-get)
(coding-system-get org-html-coding-system 'mime-charset))
"iso-8859-1"))))))
(or (and org-html-coding-system
(fboundp 'coding-system-get)
(coding-system-get org-html-coding-system 'mime-charset))
"iso-8859-1"))))))
(org-html-doctype info)
"\n"
(concat "<html"
@ -1841,21 +1838,20 @@ holding export options."
(let ((link-up (org-trim (plist-get info :html-link-up)))
(link-home (org-trim (plist-get info :html-link-home))))
(unless (and (string= link-up "") (string= link-home ""))
(format org-html-home/up-format
(format (plist-get info :html-home/up-format)
(or link-up link-home)
(or link-home link-up))))
;; Preamble.
(org-html--build-pre/postamble 'preamble info)
;; Document contents.
(format "<%s id=\"%s\">\n"
(nth 1 (assq 'content org-html-divs))
(nth 2 (assq 'content org-html-divs)))
(let ((div (assq 'content (plist-get info :html-divs))))
(format "<%s id=\"%s\">\n" (nth 1 div) (nth 2 div)))
;; Document title.
(let ((title (plist-get info :title)))
(format "<h1 class=\"title\">%s</h1>\n" (org-export-data (or title "") info)))
(format "<h1 class=\"title\">%s</h1>\n"
(org-export-data (or title "") info)))
contents
(format "</%s>\n"
(nth 1 (assq 'content org-html-divs)))
(format "</%s>\n" (nth 1 (assq 'content (plist-get info :html-divs))))
;; Postamble.
(org-html--build-pre/postamble 'postamble info)
;; Closing document.
@ -1868,9 +1864,9 @@ INFO is a plist used as a communication channel."
;;;; Anchor
(defun org-html--anchor (&optional id desc attributes)
(defun org-html--anchor (id desc attributes info)
"Format a HTML anchor."
(let* ((name (and org-html-allow-name-attribute-in-anchors id))
(let* ((name (and (plist-get info :html-allow-name-attribute-in-anchors) id))
(attributes (concat (and id (format " id=\"%s\"" id))
(and name (format " name=\"%s\"" name))
attributes)))
@ -1878,43 +1874,30 @@ INFO is a plist used as a communication channel."
;;;; Todo
(defun org-html--todo (todo)
(defun org-html--todo (todo info)
"Format TODO keywords into HTML."
(when todo
(format "<span class=\"%s %s%s\">%s</span>"
(if (member todo org-done-keywords) "done" "todo")
org-html-todo-kwd-class-prefix (org-html-fix-class-name todo)
(plist-get info :html-todo-kwd-class-prefix)
(org-html-fix-class-name todo)
todo)))
;;;; Tags
(defun org-html--tags (tags)
"Format TAGS into HTML."
(defun org-html--tags (tags info)
"Format TAGS into HTML.
INFO is a plist containing export options."
(when tags
(format "<span class=\"tag\">%s</span>"
(mapconcat
(lambda (tag)
(format "<span class=\"%s\">%s</span>"
(concat org-html-tag-class-prefix
(concat (plist-get info :html-tag-class-prefix)
(org-html-fix-class-name tag))
tag))
tags "&#xa0;"))))
;;;; Headline
(defun* org-html-format-headline
(todo todo-type priority text tags
&key level section-number headline-label &allow-other-keys)
"Format a headline in HTML."
(let ((section-number
(when section-number
(format "<span class=\"section-number-%d\">%s</span> "
level section-number)))
(todo (org-html--todo todo))
(tags (org-html--tags tags)))
(concat section-number todo (and todo " ") text
(and tags "&#xa0;&#xa0;&#xa0;") tags)))
;;;; Src Code
(defun org-html-fontify-code (code lang)
@ -2048,10 +2031,11 @@ contents as a string, or nil if it is empty."
"div")))
(when toc-entries
(concat (format "<%s id=\"table-of-contents\">\n" outer-tag)
(format "<h%d>%s</h%d>\n"
org-html-toplevel-hlevel
(org-html--translate "Table of Contents" info)
org-html-toplevel-hlevel)
(let ((top-level (plist-get info :html-toplevel-hlevel)))
(format "<h%d>%s</h%d>\n"
top-level
(org-html--translate "Table of Contents" info)
top-level))
"<div id=\"text-table-of-contents\">"
(org-html--toc-text toc-entries)
"</div>\n"
@ -2118,11 +2102,7 @@ INFO is a plist used as a communication channel."
(org-export-numbered-headline-p headline info)
(concat (mapconcat #'number-to-string headline-number ".")
". "))
(apply (if (not (eq org-html-format-headline-function 'ignore))
(lambda (todo todo-type priority text tags &rest ignore)
(funcall org-html-format-headline-function
todo todo-type priority text tags))
#'org-html-format-headline)
(apply (plist-get info :html-format-headline-function)
todo todo-type priority text tags :section-number nil)))))
(defun org-html-list-of-listings (info)
@ -2132,10 +2112,11 @@ of listings as a string, or nil if it is empty."
(let ((lol-entries (org-export-collect-listings info)))
(when lol-entries
(concat "<div id=\"list-of-listings\">\n"
(format "<h%d>%s</h%d>\n"
org-html-toplevel-hlevel
(org-html--translate "List of Listings" info)
org-html-toplevel-hlevel)
(let ((top-level (plist-get info :html-toplevel-hlevel)))
(format "<h%d>%s</h%d>\n"
top-level
(org-html--translate "List of Listings" info)
top-level))
"<div id=\"text-list-of-listings\">\n<ul>\n"
(let ((count 0)
(initial-fmt (format "<span class=\"listing-number\">%s</span>"
@ -2167,10 +2148,11 @@ of tables as a string, or nil if it is empty."
(let ((lol-entries (org-export-collect-tables info)))
(when lol-entries
(concat "<div id=\"list-of-tables\">\n"
(format "<h%d>%s</h%d>\n"
org-html-toplevel-hlevel
(org-html--translate "List of Tables" info)
org-html-toplevel-hlevel)
(let ((top-level (plist-get info :html-toplevel-hlevel)))
(format "<h%d>%s</h%d>\n"
top-level
(org-html--translate "List of Tables" info)
top-level))
"<div id=\"text-list-of-tables\">\n<ul>\n"
(let ((count 0)
(initial-fmt (format "<span class=\"table-number\">%s</span>"
@ -2204,7 +2186,7 @@ of tables as a string, or nil if it is empty."
"Transcode BOLD from Org to HTML.
CONTENTS is the text with bold markup. INFO is a plist holding
contextual information."
(format (or (cdr (assq 'bold org-html-text-markup-alist)) "%s")
(format (or (cdr (assq 'bold (plist-get info :html-text-markup-alist))) "%s")
contents))
;;;; Center Block
@ -2239,7 +2221,7 @@ channel."
"Transcode CODE from Org to HTML.
CONTENTS is nil. INFO is a plist holding contextual
information."
(format (or (cdr (assq 'code org-html-text-markup-alist)) "%s")
(format (or (cdr (assq 'code (plist-get info :html-text-markup-alist))) "%s")
(org-html-encode-plain-text (org-element-property :value code))))
;;;; Drawer
@ -2248,13 +2230,9 @@ information."
"Transcode a DRAWER element from Org to HTML.
CONTENTS holds the contents of the block. INFO is a plist
holding contextual information."
(if (functionp org-html-format-drawer-function)
(funcall org-html-format-drawer-function
(org-element-property :drawer-name drawer)
contents)
;; If there's no user defined function: simply
;; display contents of the drawer.
contents))
(funcall (plist-get info :html-format-drawer-function)
(org-element-property :drawer-name drawer)
contents))
;;;; Dynamic Block
@ -2311,87 +2289,44 @@ CONTENTS is nil. INFO is a plist holding contextual information."
;; Insert separator between two footnotes in a row.
(let ((prev (org-export-get-previous-element footnote-reference info)))
(when (eq (org-element-type prev) 'footnote-reference)
org-html-footnote-separator))
(cond
((not (org-export-footnote-first-reference-p footnote-reference info))
(org-html-format-footnote-reference
(org-export-get-footnote-number footnote-reference info)
"IGNORED" 100))
;; Inline definitions are secondary strings.
((eq (org-element-property :type footnote-reference) 'inline)
(org-html-format-footnote-reference
(org-export-get-footnote-number footnote-reference info)
"IGNORED" 1))
;; Non-inline footnotes definitions are full Org data.
(t (org-html-format-footnote-reference
(org-export-get-footnote-number footnote-reference info)
"IGNORED" 1)))))
(plist-get info :html-footnote-separator)))
(let* ((n (org-export-get-footnote-number footnote-reference info))
(id (format "fnr.%d%s"
n
(if (org-export-footnote-first-reference-p
footnote-reference info)
""
".100"))))
(format
(plist-get info :html-footnote-format)
(org-html--anchor
id n (format " class=\"footref\" href=\"#fn.%d\"" n) info)))))
;;;; Headline
(defun org-html-format-headline--wrap
(headline info &optional format-function &rest extra-keys)
"Transcode a HEADLINE element from Org to HTML.
CONTENTS holds the contents of the headline. INFO is a plist
holding contextual information."
(let* ((level (+ (org-export-get-relative-level headline info)
(1- org-html-toplevel-hlevel)))
(headline-number (org-export-get-headline-number headline info))
(section-number (and (not (org-export-low-level-p headline info))
(org-export-numbered-headline-p headline info)
(mapconcat 'number-to-string
headline-number ".")))
(todo (and (plist-get info :with-todo-keywords)
(let ((todo (org-element-property :todo-keyword headline)))
(and todo (org-export-data todo info)))))
(todo-type (and todo (org-element-property :todo-type headline)))
(priority (and (plist-get info :with-priority)
(org-element-property :priority headline)))
(text (org-export-data (org-element-property :title headline) info))
(tags (and (plist-get info :with-tags)
(org-export-get-tags headline info)))
(headline-label (or (org-element-property :CUSTOM_ID headline)
(concat "sec-" (mapconcat 'number-to-string
headline-number "-"))))
(format-function
(cond ((functionp format-function) format-function)
((not (eq org-html-format-headline-function 'ignore))
(lambda (todo todo-type priority text tags &rest ignore)
(funcall org-html-format-headline-function
todo todo-type priority text tags)))
(t 'org-html-format-headline))))
(apply format-function
todo todo-type priority text tags
:headline-label headline-label :level level
:section-number section-number extra-keys)))
(defun org-html-headline (headline contents info)
"Transcode a HEADLINE element from Org to HTML.
CONTENTS holds the contents of the headline. INFO is a plist
holding contextual information."
;; Empty contents?
(setq contents (or contents ""))
(let* ((numberedp (org-export-numbered-headline-p headline info))
(level (org-export-get-relative-level headline info))
(text (org-export-data (org-element-property :title headline) info))
(level (+ (org-export-get-relative-level headline info)
(1- (plist-get info :html-toplevel-hlevel))))
(todo (and (plist-get info :with-todo-keywords)
(let ((todo (org-element-property :todo-keyword headline)))
(and todo (org-export-data todo info)))))
(todo-type (and todo (org-element-property :todo-type headline)))
(tags (and (plist-get info :with-tags)
(org-export-get-tags headline info)))
(priority (and (plist-get info :with-priority)
(org-element-property :priority headline)))
(section-number (and (org-export-numbered-headline-p headline info)
(mapconcat 'number-to-string
(org-export-get-headline-number
headline info) ".")))
;; Create the headline text.
(full-text (org-html-format-headline--wrap headline info)))
(text (org-export-data (org-element-property :title headline) info))
(tags (and (plist-get info :with-tags)
(org-export-get-tags headline info)))
(full-text (funcall (plist-get info :html-format-headline-function)
todo todo-type priority text tags info))
(contents (or contents "")))
(cond
;; Case 1: This is a footnote section: ignore it.
((org-element-property :footnote-section-p headline) nil)
;; Case 2. This is a deep sub-tree: export it as a list item.
;; Case 2: This is a deep sub-tree: export it as a list item.
;; Also export as items headlines for which no section
;; format has been found.
((org-export-low-level-p headline info)
@ -2399,54 +2334,62 @@ holding contextual information."
(let* ((type (if numberedp 'ordered 'unordered))
(itemized-body (org-html-format-list-item
contents type nil info nil full-text)))
(concat
(and (org-export-first-sibling-p headline info)
(org-html-begin-plain-list type))
itemized-body
(and (org-export-last-sibling-p headline info)
(org-html-end-plain-list type)))))
;; Case 3. Standard headline. Export it as a section.
(concat (and (org-export-first-sibling-p headline info)
(org-html-begin-plain-list type))
itemized-body
(and (org-export-last-sibling-p headline info)
(org-html-end-plain-list type)))))
;; Case 3: Standard headline. Export it as a section.
(t
(let* ((section-number (mapconcat 'number-to-string
(org-export-get-headline-number
headline info) "-"))
(ids (remove 'nil
(list (org-element-property :CUSTOM_ID headline)
(concat "sec-" section-number)
(org-element-property :ID headline))))
(let* ((headline-number
(and numberedp (org-export-get-headline-number headline info)))
(section-number (mapconcat #'number-to-string headline-number "-"))
(ids (remq nil
(list (org-element-property :CUSTOM_ID headline)
(concat "sec-" section-number)
(org-element-property :ID headline))))
(preferred-id (car ids))
(extra-ids (cdr ids))
(extra-class (org-element-property :HTML_CONTAINER_CLASS headline))
(level1 (+ level (1- org-html-toplevel-hlevel)))
(first-content (car (org-element-contents headline))))
(format "<%s id=\"%s\" class=\"%s\">%s%s</%s>\n"
(org-html--container headline info)
(format "outline-container-%s"
(or (org-element-property :CUSTOM_ID headline)
(concat "sec-" section-number)))
(concat (format "outline-%d" level1) (and extra-class " ")
(concat (format "outline-%d" level)
(and extra-class " ")
extra-class)
(format "\n<h%d id=\"%s\">%s%s</h%d>\n"
level1
level
preferred-id
(mapconcat
(lambda (x)
(let ((id (org-export-solidify-link-text
(if (org-uuidgen-p x) (concat "ID-" x)
x))))
(org-html--anchor id)))
(org-html--anchor id nil nil info)))
extra-ids "")
full-text
level1)
(concat
(mapconcat #'number-to-string headline-number ".")
(and headline-number " ")
full-text)
level)
;; When there is no section, pretend there is an empty
;; one to get the correct <div class="outline- ...>
;; which is needed by `org-info.js'.
(if (not (eq (org-element-type first-content) 'section))
(concat (org-html-section first-content "" info)
contents)
contents)
(if (eq (org-element-type first-content) 'section) contents
(concat (org-html-section first-content "" info) contents))
(org-html--container headline info)))))))
(defun org-html-format-headline-default-function
(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))
(tags (org-html--tags tags info)))
(concat todo (and todo " ") text (and tags "&#xa0;&#xa0;&#xa0;") tags)))
(defun org-html--container (headline info)
(or (org-element-property :HTML_CONTAINER headline)
(if (= 1 (org-export-get-relative-level headline info))
@ -2472,32 +2415,31 @@ contextual information."
;;;; Inlinetask
(defun org-html-format-section (text class &optional id)
"Format a section with TEXT into a HTML div with CLASS and ID."
(let ((extra (concat (when id (format " id=\"%s\"" id)))))
(concat (format "<div class=\"%s\"%s>\n" class extra) text "</div>\n")))
(defun org-html-inlinetask (inlinetask contents info)
"Transcode an INLINETASK element from Org to HTML.
CONTENTS holds the contents of the block. INFO is a plist
holding contextual information."
(cond
;; If `org-html-format-inlinetask-function' is not 'ignore, call it
;; with appropriate arguments.
((not (eq org-html-format-inlinetask-function 'ignore))
(let ((format-function
(function*
(lambda (todo todo-type priority text tags
&key contents &allow-other-keys)
(funcall org-html-format-inlinetask-function
todo todo-type priority text tags contents)))))
(org-html-format-headline--wrap
inlinetask info format-function :contents contents)))
;; Otherwise, use a default template.
(t (format "<div class=\"inlinetask\">\n<b>%s</b>%s\n%s</div>"
(org-html-format-headline--wrap inlinetask info)
(org-html-close-tag "br" nil info)
contents))))
(let* ((todo (and (plist-get info :with-todo-keywords)
(let ((todo (org-element-property :todo-keyword inlinetask)))
(and todo (org-export-data todo info)))))
(todo-type (and todo (org-element-property :todo-type inlinetask)))
(priority (and (plist-get info :with-priority)
(org-element-property :priority inlinetask)))
(text (org-export-data (org-element-property :title inlinetask) info))
(tags (and (plist-get info :with-tags)
(org-export-get-tags inlinetask info))))
(funcall (plist-get info :html-format-inlinetask-function)
todo todo-type priority text tags contents)))
(defun org-html-format-inlinetask-default-function
(todo todo-type priority text tags contents info)
"Default format function for a inlinetasks.
See `org-html-format-inlinetask-function' for details."
(format "<div class=\"inlinetask\">\n<b>%s</b>%s\n%s</div>"
(org-html-format-headline-default-function
todo todo-type priority text tags info)
(org-html-close-tag "br" nil info)
contents))
;;;; Italic
@ -2505,7 +2447,9 @@ holding contextual information."
"Transcode ITALIC from Org to HTML.
CONTENTS is the text with italic markup. INFO is a plist holding
contextual information."
(format (or (cdr (assq 'italic org-html-text-markup-alist)) "%s") contents))
(format
(or (cdr (assq 'italic (plist-get info :html-text-markup-alist))) "%s")
contents))
;;;; Item
@ -2514,7 +2458,8 @@ contextual information."
INFO is a plist holding contextual information. See
`org-html-checkbox-type' for customization options."
(cdr (assq checkbox
(cdr (assq org-html-checkbox-type org-html-checkbox-types)))))
(cdr (assq (plist-get info :html-checkbox-type)
org-html-checkbox-types)))))
(defun org-html-format-list-item (contents type checkbox info
&optional term-counter-id
@ -2677,7 +2622,8 @@ inline image when it has no description and targets an image
file (see `org-html-inline-image-rules' for more information), or
if its description is a single link targeting an image file."
(if (not (org-element-contents link))
(org-export-inline-image-p link org-html-inline-image-rules)
(org-export-inline-image-p
link (plist-get info :html-inline-image-rules))
(not
(let ((link-count 0))
(org-element-map (org-element-contents link)
@ -2688,7 +2634,7 @@ if its description is a single link targeting an image file."
(link (if (= link-count 1) t
(incf link-count)
(not (org-export-inline-image-p
obj org-html-inline-image-rules))))
obj (plist-get info :html-inline-image-rules)))))
(otherwise t)))
info t)))))
@ -2746,7 +2692,7 @@ INFO is a plist holding contextual information. See
"Treat links to `file.org' as links to `file.html', if needed.
See `org-html-link-org-files-as-html'."
(cond
((and org-html-link-org-files-as-html
((and (plist-get info :html-link-org-files-as-html)
(string= ".org"
(downcase (file-name-extension raw-path "."))))
(concat (file-name-sans-extension raw-path) "."
@ -2808,8 +2754,9 @@ INFO is a plist holding contextual information. See
protocol)
(cond
;; Image file.
((and org-html-inline-images
(org-export-inline-image-p link org-html-inline-image-rules))
((and (plist-get info :html-inline-images)
(org-export-inline-image-p
link (plist-get info :html-inline-image-rules)))
(org-html--format-image path attributes-plist info))
;; Radio target: Transcode target's contents and use them as
;; link's description.
@ -3113,7 +3060,7 @@ holding contextual information."
(if (not parent) contents
;; Get div's class and id references.
(let* ((class-num (+ (org-export-get-relative-level parent info)
(1- org-html-toplevel-hlevel)))
(1- (plist-get info :html-toplevel-hlevel))))
(section-number
(mapconcat
'number-to-string
@ -3132,7 +3079,7 @@ TEXT is the text of the target. INFO is a plist holding
contextual information."
(let ((id (org-export-solidify-link-text
(org-element-property :value radio-target))))
(org-html--anchor id text)))
(org-html--anchor id text nil info)))
;;;; Special Block
@ -3197,8 +3144,10 @@ CONTENTS is nil. INFO is a plist holding contextual information."
"Transcode STRIKE-THROUGH from Org to HTML.
CONTENTS is the text with strike-through markup. INFO is a plist
holding contextual information."
(format (or (cdr (assq 'strike-through org-html-text-markup-alist)) "%s")
contents))
(format
(or (cdr (assq 'strike-through (plist-get info :html-text-markup-alist)))
"%s")
contents))
;;;; Subscript
@ -3225,7 +3174,7 @@ channel."
(let* ((table-row (org-export-get-parent table-cell))
(table (org-export-get-parent-table table-cell))
(cell-attrs
(if (not org-html-table-align-individual-fields) ""
(if (not (plist-get info :html-table-align-individual-fields)) ""
(format (if (and (boundp 'org-html-format-table-no-css)
org-html-format-table-no-css)
" align=\"%s\"" " class=\"%s\"")
@ -3235,14 +3184,20 @@ channel."
(cond
((and (org-export-table-has-header-p table info)
(= 1 (org-export-table-row-group table-row info)))
(concat "\n" (format (car org-html-table-header-tags) "col" cell-attrs)
contents (cdr org-html-table-header-tags)))
((and org-html-table-use-header-tags-for-first-column
(let ((header-tags (plist-get info :html-table-header-tags)))
(concat "\n" (format (car header-tags) "col" cell-attrs)
contents
(cdr header-tags))))
((and (plist-get info :html-table-use-header-tags-for-first-column)
(zerop (cdr (org-export-table-cell-address table-cell info))))
(concat "\n" (format (car org-html-table-header-tags) "row" cell-attrs)
contents (cdr org-html-table-header-tags)))
(t (concat "\n" (format (car org-html-table-data-tags) cell-attrs)
contents (cdr org-html-table-data-tags))))))
(let ((header-tags (plist-get info :html-table-header-tags)))
(concat "\n" (format (car header-tags) "row" cell-attrs)
contents
(cdr header-tags))))
(t (let ((data-tags (plist-get info :html-table-data-tags)))
(concat "\n" (format (car data-tags) cell-attrs)
contents
(cdr data-tags)))))))
;;;; Table Row
@ -3281,10 +3236,10 @@ communication channel."
;; Begin a rowgroup?
(when start-rowgroup-p (car rowgroup-tags))
;; Actual table row
(concat "\n" (eval (car org-html-table-row-tags))
(concat "\n" (eval (car (plist-get info :html-table-row-tags)))
contents
"\n"
(eval (cdr org-html-table-row-tags)))
(eval (cdr (plist-get info :html-table-row-tags))))
;; End a rowgroup?
(when end-rowgroup-p (cdr rowgroup-tags))))))
@ -3367,7 +3322,7 @@ contextual information."
(format "<table%s>\n%s\n%s\n%s</table>"
(if (equal attributes "") "" (concat " " attributes))
(if (not caption) ""
(format (if org-html-table-caption-above
(format (if (plist-get info :html-table-caption-above)
"<caption class=\"t-above\">%s</caption>"
"<caption class=\"t-bottom\">%s</caption>")
(concat
@ -3385,7 +3340,7 @@ CONTENTS is nil. INFO is a plist holding contextual
information."
(let ((id (org-export-solidify-link-text
(org-element-property :value target))))
(org-html--anchor id)))
(org-html--anchor id nil nil info)))
;;;; Timestamp
@ -3404,7 +3359,8 @@ information."
"Transcode UNDERLINE from Org to HTML.
CONTENTS is the text with underline markup. INFO is a plist
holding contextual information."
(format (or (cdr (assq 'underline org-html-text-markup-alist)) "%s")
(format (or (cdr (assq 'underline (plist-get info :html-text-markup-alist)))
"%s")
contents))
;;;; Verbatim
@ -3413,7 +3369,7 @@ holding contextual information."
"Transcode VERBATIM from Org to HTML.
CONTENTS is nil. INFO is a plist holding contextual
information."
(format (or (cdr (assq 'verbatim org-html-text-markup-alist)) "%s")
(format (or (cdr (assq 'verbatim (plist-get info :html-text-markup-alist))) "%s")
(org-html-encode-plain-text (org-element-property :value verbatim))))
;;;; Verse Block
@ -3446,9 +3402,9 @@ contextual information."
(with-temp-buffer
(insert contents)
(set-auto-mode t)
(if org-html-indent
(if (plist-get info :html-indent)
(indent-region (point-min) (point-max)))
(when org-html-use-unicode-chars
(when (plist-get info :html-use-unicode-chars)
(require 'mm-url)
(mm-url-decode-entities))
(buffer-substring-no-properties (point-min) (point-max))))
@ -3531,7 +3487,9 @@ file-local settings.
Return output file's name."
(interactive)
(let* ((extension (concat "." org-html-extension))
(let* ((extension (concat "." (or (plist-get ext-plist :html-extension)
org-html-extension
"html")))
(file (org-export-output-file-name extension subtreep))
(org-export-coding-system org-html-coding-system))
(org-export-to-file 'html file
@ -3548,7 +3506,8 @@ publishing directory.
Return output file name."
(org-publish-org-to 'html filename
(concat "." (or (plist-get plist :html-extension)
org-html-extension "html"))
org-html-extension
"html"))
plist pub-dir))

View File

@ -191,7 +191,8 @@ a communication channel."
(concat "sec-"
(mapconcat 'number-to-string
(org-export-get-headline-number
headline info) "-"))))))
headline info) "-")))
nil nil info)))
;; Headline text without tags.
(heading (concat todo priority title))
(style (plist-get info :md-headline-style)))