summaryrefslogtreecommitdiff
path: root/lisp/ox-html.el
diff options
context:
space:
mode:
authorSébastien Delafond <sdelafond@gmail.com>2014-07-13 13:35:31 +0200
committerSébastien Delafond <sdelafond@gmail.com>2014-07-13 13:35:31 +0200
commit52fbfeb04b10aa78f24f339a352fe1161c0b37e4 (patch)
treea3b147a3a2e4bb39c4ae36c0f442c6137ae506e2 /lisp/ox-html.el
parent40ce6b75e6245659a3a14622356e32e7dd1125dd (diff)
Imported Upstream version 8.2.4
Diffstat (limited to 'lisp/ox-html.el')
-rw-r--r--lisp/ox-html.el136
1 files changed, 86 insertions, 50 deletions
diff --git a/lisp/ox-html.el b/lisp/ox-html.el
index 14b31b2..44962a5 100644
--- a/lisp/ox-html.el
+++ b/lisp/ox-html.el
@@ -1,11 +1,13 @@
;;; ox-html.el --- HTML Back-End for Org Export Engine
-;; Copyright (C) 2011-2013 Free Software Foundation, Inc.
+;; Copyright (C) 2011-2013 Free Software Foundation, Inc.
;; Author: Carsten Dominik <carsten at orgmode dot org>
;; Jambunathan K <kjambunathan at gmail dot com>
;; Keywords: outlines, hypermedia, calendar, wp
+;; This file is part of GNU Emacs.
+
;; GNU Emacs is free software: you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
@@ -22,13 +24,7 @@
;;; Commentary:
;; This library implements a HTML back-end for Org generic exporter.
-
-;; To test it, run:
-;;
-;; M-x org-html-export-as-html
-;;
-;; in an Org mode buffer. See ox.el for more details on how this
-;; exporter works.
+;; See Org manual for more information.
;;; Code:
@@ -134,7 +130,9 @@
(:infojs-opt "INFOJS_OPT" nil nil)
;; Redefine regular options.
(:creator "CREATOR" nil org-html-creator-string)
- (:with-latex nil "tex" org-html-with-latex)))
+ (:with-latex nil "tex" org-html-with-latex)
+ ;; Retrieve LaTeX header for fragments.
+ (:latex-header "LATEX_HEADER" nil nil newline)))
;;; Internal Variables
@@ -157,7 +155,7 @@
\"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">")
("xhtml-transitional" . "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\"
\"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">")
- ("xhtml-framset" . "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Frameset//EN\"
+ ("xhtml-frameset" . "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Frameset//EN\"
\"http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd\">")
("xhtml-11" . "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.1//EN\"
\"http://www.w3.org/TR/xhtml1/DTD/xhtml11.dtd\">")
@@ -190,7 +188,7 @@ the headline itself.")
@licstart The following is the entire license notice for the
JavaScript code in this tag.
-Copyright (C) 2012 Free Software Foundation, Inc.
+Copyright (C) 2012-2013 Free Software Foundation, Inc.
The JavaScript code in this tag is free software: you can
redistribute it and/or modify it under the terms of the GNU
@@ -387,7 +385,7 @@ means to use the maximum value consistent with other options."
* @licstart The following is the entire license notice for the
* JavaScript code in %SCRIPT_PATH.
*
- * Copyright (C) 2012-2013 Sebastian Rose
+ * Copyright (C) 2012-2013 Free Software Foundation, Inc.
*
*
* The JavaScript code in this tag is free software: you can
@@ -548,6 +546,8 @@ a formatting string to wrap fontified text with.
If no association can be found for a given markup, text will be
returned as-is."
:group 'org-export-html
+ :version "24.4"
+ :package-version '(Org . "8.0")
:type '(alist :key-type (symbol :tag "Markup type")
:value-type (string :tag "Format string"))
:options '(bold code italic strike-through underline verbatim))
@@ -569,7 +569,8 @@ Warning: non-nil may break indentation of source code blocks."
;;;; Drawers
-(defcustom org-html-format-drawer-function nil
+(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:
@@ -581,10 +582,10 @@ The function should return the string to be exported.
For example, the variable could be set to the following function
in order to mimic default behaviour:
-\(defun org-html-format-drawer-default \(name contents\)
- \"Format a drawer element for HTML export.\"
- contents\)"
+The default value simply returns the value of CONTENTS."
:group 'org-export-html
+ :version "24.4"
+ :package-version '(Org . "8.0")
:type 'function)
;;;; Footnotes
@@ -626,7 +627,7 @@ document title."
:group 'org-export-html
:type 'integer)
-(defcustom org-html-format-headline-function nil
+(defcustom org-html-format-headline-function 'ignore
"Function to format headline text.
This function will be called with 5 arguments:
@@ -638,6 +639,8 @@ TAGS the tags (string or nil).
The function result will be used in the section format string."
:group 'org-export-html
+ :version "24.4"
+ :package-version '(Org . "8.0")
:type 'function)
;;;; HTML-specific
@@ -653,7 +656,7 @@ attributes, when appropriate."
;;;; Inlinetasks
-(defcustom org-html-format-inlinetask-function nil
+(defcustom org-html-format-inlinetask-function 'ignore
"Function called to format an inlinetask in HTML code.
The function must accept six parameters:
@@ -666,6 +669,8 @@ The function must accept six parameters:
The function should return the string to be exported."
:group 'org-export-html
+ :version "24.4"
+ :package-version '(Org . "8.0")
:type 'function)
;;;; LaTeX
@@ -1123,6 +1128,8 @@ like that: \"%%\"."
"Information about the creator of the HTML document.
This option can also be set on with the CREATOR keyword."
:group 'org-export-html
+ :version "24.4"
+ :package-version '(Org . "8.0")
:type '(string :tag "Creator string"))
;;;; Template :: Preamble
@@ -1976,33 +1983,44 @@ and value is its relative level, as an integer."
"Return an appropriate table of contents entry for HEADLINE.
INFO is a plist used as a communication channel."
(let* ((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)
- (concat (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-with-backend
+ (org-export-get-alt-title headline info)
+ ;; Create an anonymous back-end that will ignore any
+ ;; footnote-reference, link, radio-target and target
+ ;; in table of contents.
+ (org-export-create-backend
+ :parent 'html
+ :transcoders '((footnote-reference . ignore)
+ (link . (lambda (object c i) c))
+ (radio-target . (lambda (object c i) c))
+ (target . ignore)))
+ info))
(tags (and (eq (plist-get info :with-tags) t)
(org-export-get-tags headline info))))
(format "<a href=\"#%s\">%s</a>"
;; Label.
(org-export-solidify-link-text
(or (org-element-property :CUSTOM_ID headline)
- (concat "sec-" (mapconcat 'number-to-string
- headline-number "-"))))
+ (concat "sec-"
+ (mapconcat #'number-to-string headline-number "-"))))
;; Body.
- (concat section-number
- (org-export-data-with-backend
- (org-export-get-alt-title headline info)
- ;; Create an anonymous back-end that will ignore
- ;; any footnote-reference, link, radio-target and
- ;; target in table of contents.
- (org-export-create-backend
- :parent 'html
- :transcoders '((footnote-reference . ignore)
- (link . (lambda (object c i) c))
- (radio-target . (lambda (object c i) c))
- (target . ignore)))
- info)
- (and tags "&#xa0;&#xa0;&#xa0;") (org-html--tags tags)))))
+ (concat
+ (and (not (org-export-low-level-p headline info))
+ (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)
+ todo todo-type priority text tags :section-number nil)))))
(defun org-html-list-of-listings (info)
"Build a list of listings.
@@ -2242,7 +2260,7 @@ holding contextual information."
headline-number "-"))))
(format-function
(cond ((functionp format-function) format-function)
- ((functionp org-html-format-headline-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)))
@@ -2369,9 +2387,9 @@ contextual information."
CONTENTS holds the contents of the block. INFO is a plist
holding contextual information."
(cond
- ;; If `org-html-format-inlinetask-function' is provided, call it
+ ;; If `org-html-format-inlinetask-function' is not 'ignore, call it
;; with appropriate arguments.
- ((functionp org-html-format-inlinetask-function)
+ ((not (eq org-html-format-inlinetask-function 'ignore))
(let ((format-function
(function*
(lambda (todo todo-type priority text tags
@@ -2472,18 +2490,34 @@ CONTENTS is nil. INFO is a plist holding contextual information."
;;;; Latex Environment
-(defun org-html-format-latex (latex-frag processing-type)
- "Format a LaTeX fragment LATEX-FRAG into HTML."
+(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."
(let ((cache-relpath "") (cache-dir ""))
(unless (eq processing-type 'mathjax)
(let ((bfn (or (buffer-file-name)
(make-temp-name
- (expand-file-name "latex" temporary-file-directory)))))
+ (expand-file-name "latex" temporary-file-directory))))
+ (latex-header
+ (let ((header (plist-get info :latex-header)))
+ (and header
+ (concat (mapconcat
+ (lambda (line) (concat "#+LATEX_HEADER: " line))
+ (org-split-string header "\n")
+ "\n")
+ "\n")))))
(setq cache-relpath
(concat "ltxpng/"
(file-name-sans-extension
(file-name-nondirectory bfn)))
- cache-dir (file-name-directory bfn))))
+ cache-dir (file-name-directory bfn))
+ ;; Re-create LaTeX environment from original buffer in
+ ;; temporary buffer so that dvipng/imagemagick can properly
+ ;; turn the fragment into an image.
+ (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..."
@@ -2499,9 +2533,10 @@ CONTENTS is nil. INFO is a plist holding contextual information."
(attributes (org-export-read-attribute :attr_html latex-environment)))
(case processing-type
((t mathjax)
- (org-html-format-latex latex-frag 'mathjax))
+ (org-html-format-latex latex-frag 'mathjax info))
((dvipng imagemagick)
- (let ((formula-link (org-html-format-latex latex-frag processing-type)))
+ (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.
@@ -2519,9 +2554,10 @@ CONTENTS is nil. INFO is a plist holding contextual information."
(processing-type (plist-get info :with-latex)))
(case processing-type
((t mathjax)
- (org-html-format-latex latex-frag 'mathjax))
+ (org-html-format-latex latex-frag 'mathjax info))
((dvipng imagemagick)
- (let ((formula-link (org-html-format-latex latex-frag processing-type)))
+ (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))))
@@ -3067,7 +3103,7 @@ CONTENTS is the contents of the object. INFO is a plist holding
contextual information."
(format "<sup>%s</sup>" contents))
-;;;; Tabel Cell
+;;;; Table Cell
(defun org-html-table-cell (table-cell contents info)
"Transcode a TABLE-CELL element from Org to HTML.