Browse Source

Refactor fetching html doctype from alist into function so it can be reused in inherited exporters.

* lisp/ox-html.el (org-html-doctype): Add new function `org-html-doctype'.
(org-html-template): Use `org-html-doctype' function instead of inline
code.

* contrib/lisp/ox-deck.el (org-deck-template): Use `org-html-doctype'
  function instead of inline code.

* contrib/lisp/ox-s5.el (org-s5-template): Use `org-html-doctype'
  function instead of inline code.
Rick Frankel 11 years ago
parent
commit
9d22167c68
3 changed files with 11 additions and 11 deletions
  1. 1 5
      contrib/lisp/ox-deck.el
  2. 1 1
      contrib/lisp/ox-s5.el
  3. 9 5
      lisp/ox-html.el

+ 1 - 5
contrib/lisp/ox-deck.el

@@ -392,11 +392,7 @@ holding export options."
     (mapconcat
      'identity
      (list
-      (let* ((dt (plist-get info :html-doctype))
-	     (dt-cons (assoc dt org-html-doctype-alist)))
-	(if dt-cons
-	    (cdr dt-cons)
-	  dt))
+      (org-html-doctype info)
       (let ((lang (plist-get info :language)))
         (mapconcat
          (lambda (x)

+ 1 - 1
contrib/lisp/ox-s5.el

@@ -306,7 +306,7 @@ holding export options."
     (mapconcat
      'identity
      (list
-      (plist-get info :html-doctype)
+      (org-html-doctype info)
       (format "<html xmlns=\"http://www.w3.org/1999/xhtml\" lang=\"%s\" xml:lang=\"%s\">"
 	      (plist-get info :language) (plist-get info :language))
       "<head>"

+ 9 - 5
lisp/ox-html.el

@@ -1306,6 +1306,14 @@ CSS classes, then this prefix can be very useful."
   (concat "<" tag " " attr
 	  (if (org-html-xhtml-p info) " />" ">")))
 
+(defun org-html-doctype (info)
+  "Return correct html doctype tag from `org-html-doctype-alist',
+or the literal value of :html-doctype from INFO if :html-doctype
+is not found in the alist.
+INFO is a plist used as a communication channel."
+  (let ((dt (plist-get info :html-doctype)))
+    (or (cdr (assoc dt org-html-doctype-alist)) dt)))
+
 (defun org-html--make-attribute-string (attributes)
   "Return a list of attributes, as a string.
 ATTRIBUTES is a plist where values are either strings or nil. An
@@ -1696,11 +1704,7 @@ holding export options."
 			   (fboundp 'coding-system-get)
 			   (coding-system-get org-html-coding-system 'mime-charset))
 		      "iso-8859-1"))))))
-   (let* ((dt (plist-get info :html-doctype))
-	  (dt-cons (assoc dt org-html-doctype-alist)))
-     (if dt-cons
-	 (cdr dt-cons)
-       dt))
+   (org-html-doctype info)
    "\n"
    (concat "<html"
 	   (when (org-html-xhtml-p info)