Rick Frankel <r...@rickster.com> writes: > On Tue, Apr 30, 2013 at 08:26:52PM -0700, Eric Abrahamsen wrote: >> Rick Frankel <r...@rickster.com> writes: >> >> > Whoops. Wrong key. Patch actually attached to this email... >> > rick >> >> Great, I'll consolidate all these -- would it be better to mush them >> into one big patch, or to keep them separate (I suppose for ease of >> rollback, if something goes wrong)? > > Probably squashing them into one patch would be the best. But Carsten > or Bastien might disagree :). > > rick
Okay, there it is: one big patch (including your xml declaration fix). I didn't add any more refined handling of the html5-fancy option. As a second-order option it didn't seem worthy of an #+OPTIONS entry, and I didn't bother checking for an empty string, either. It can always be #+BINDed if necessary, and if it ever annoys anyone I can fix it further. E
>From 9224f289801c7f1193718fe7f2ca351e26d7534b Mon Sep 17 00:00:00 2001 From: Eric Abrahamsen <e...@ericabrahamsen.net> Date: Thu, 2 May 2013 13:40:58 -0700 Subject: [PATCH] ox-html.el Export to different (X)HTML flavors, including HTML5 * lisp/ox-html.el (org-html-doctype-alist): New variable holding an alist of (X)HTML doctypes (org-html-xhtml-p): New function (org-html-html5-p): New function (org-html-close-tag): New function (org-html-html5-fancy): New export option, determining whether or not to use HTML5-specific elements. (org-html-html5-elements): New variable, new HTML5 elements. (org-html-special-block): Export special blocks to new HTML5 elements. (org-html-format-inline-image): Use <figure> and <figcaption> for standalone images. Significant changes to `org-html-format-inline-image', `org-html--build-meta-info', `org-html--build-head', `org-html--build-pre/postable', `org-html-template', `org-html-horizontal-rule', `org-html-format-list-item', `org-html-line-break', `org-html-table', and `org-html-verse-block'. doc/org.texi: Document the above --- doc/org.texi | 97 +++++++++++++++++++++- lisp/ox-html.el | 251 ++++++++++++++++++++++++++++++++++++++++---------------- 2 files changed, 277 insertions(+), 71 deletions(-) diff --git a/doc/org.texi b/doc/org.texi index 7437451..c294ea6 100644 --- a/doc/org.texi +++ b/doc/org.texi @@ -596,6 +596,7 @@ Exporting HTML export * HTML Export commands:: How to invoke HTML export +* HTML doctypes:: Org can export to various (X)HTML flavors * HTML preamble and postamble:: How to insert a preamble and a postamble * Quoting HTML tags:: Using direct HTML in Org mode * Links in HTML export:: How links will be interpreted and formatted @@ -10969,6 +10970,7 @@ language, but with additional support for tables. @menu * HTML Export commands:: How to invoke HTML export +* HTML doctypes:: Org can export to various (X)HTML flavors * HTML preamble and postamble:: How to insert a preamble and a postamble * Quoting HTML tags:: Using direct HTML in Org mode * Links in HTML export:: How links will be interpreted and formatted @@ -10980,7 +10982,7 @@ language, but with additional support for tables. * JavaScript support:: Info and Folding in a web browser @end menu -@node HTML Export commands, HTML preamble and postamble, HTML export, HTML export +@node HTML Export commands, HTML doctypes, HTML export, HTML export @subsection HTML export commands @table @kbd @@ -11008,7 +11010,98 @@ Export to a temporary buffer. Do not create a file. @c @noindent @c creates two levels of headings and does the rest as items. -@node HTML preamble and postamble, Quoting HTML tags, HTML Export commands, HTML export +@node HTML doctypes, HTML preamble and postamble, HTML Export commands, HTML export +@subsection HTML doctypes +@vindex org-html-doctype +@vindex org-html-doctype-alist + +Org can export to various (X)HTML flavors. + +Setting the variable @code{org-html-doctype} allows you to export to different +(X)HTML variants. The exported HTML will be adjusted according to the sytax +requirements of that variant. You can either set this variable to a doctype +string directly, in which case the exporter will try to adjust the syntax +automatically, or you can use a ready-made doctype. The ready-made options +are: + +@itemize +@item +``html4-strict'' +@item +``html4-transitional'' +@item +``html4-frameset'' +@item +``xhtml-strict'' +@item +``xhtml-transitional'' +@item +``xhtml-frameset'' +@item +``xhtml-11'' +@item +``html5'' +@item +``xhtml5'' +@end itemize + +See the variable @code{org-html-doctype-alist} for details. The default is +``xhtml-strict''. + +@subsubheading Fancy HTML5 export +@vindex org-html-html5-fancy +@vindex org-html-html5-elements + +HTML5 introduces several new element types. By default, Org will not make +use of these element types, but you can set @code{org-html-html5-fancy} to +@code{t} (or use the corresponding @code{HTML_HTML5_FANCY} export option), to +enable a few new block-level elements. These are created using arbitrary +#+BEGIN and #+END blocks. For instance: + +@example +#+BEGIN_ASIDE +Lorem ipsum +#+END_ASIDE +@end example + +Will export to: + +@example +<aside> + <p>Lorem ipsum</p> +</aside> +@end example + +While this: + +@example +#+ATTR_HTML: :controls controls :width 350 +#+BEGIN_VIDEO +#+HTML: <source src="movie.mp4" type="video/mp4"> +#+HTML: <source src="movie.ogg" type="video/ogg"> +Your browser does not support the video tag. +#+END_VIDEO +@end example + +Becomes: + +@example +<video controls="controls" width="350"> + <source src="movie.mp4" type="video/mp4"> + <source src="movie.ogg" type="video/ogg"> + <p>Your browser does not support the video tag.</p> +</video> +@end example + +Special blocks that do not correspond to HTML5 elements (see +@code{org-html-html5-elements}) will revert to the usual behavior, +i.e. #+BEGIN_LEDERHOSEN will still export to <div class=''lederhosen''>. + +Headlines cannot appear within special blocks. To wrap a headline and its +contents in e.g. <section> or <article> tags, set the @code{HTML_CONTAINER} +property on the headline itself. + +@node HTML preamble and postamble, Quoting HTML tags, HTML doctypes, HTML export @subsection HTML preamble and postamble @vindex org-html-preamble @vindex org-html-postamble diff --git a/lisp/ox-html.el b/lisp/ox-html.el index ef7d15a..05b99bf 100644 --- a/lisp/ox-html.el +++ b/lisp/ox-html.el @@ -116,6 +116,7 @@ (:html-link-org-as-html nil nil org-html-link-org-files-as-html) (:html-doctype "HTML_DOCTYPE" nil org-html-doctype) (:html-container "HTML_CONTAINER" nil org-html-container-element) + (:html-html5-fancy "HTML_HTML5_FANCY" nil org-html-html5-fancy) (: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) @@ -143,6 +144,38 @@ (defvar org-html--pre/postamble-class "status" "CSS class used for pre/postamble") +(defconst org-html-doctype-alist + '(("html4-strict" . "<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01//EN\" +\"http://www.w3.org/TR/html4/strict.dtd\">") + ("html4-transitional" . "<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" +\"http://www.w3.org/TR/html4/loose.dtd\">") + ("html4-frameset" . "<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01 Frameset//EN\" +\"http://www.w3.org/TR/html4/frameset.dtd\">") + + ("xhtml-strict" . "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\" +\"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\" +\"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\">") + + ("html5" . "<!DOCTYPE html>") + ("xhtml5" . "<!DOCTYPE html>")) + "An alist mapping (x)html flavors to specific doctypes.") + +(defconst org-html-html5-elements + '("article" "aside" "audio" "canvas" "details" "figcaption" + "figure" "footer" "header" "menu" "meter" "nav" "output" + "progress" "section" "video") + "New elements in html5. + +<hgroup> is not included because it's currently impossible to +wrap special blocks around multiple headlines. For other blocks +that should contain headlines, use the HTML_CONTAINER property on +the headline itself.") + (defconst org-html-special-string-regexps '(("\\\\-" . "­") ; shy ("---\\([^-]\\)" . "—\\1") ; mdash @@ -748,7 +781,9 @@ in all modes you want. Then, use the command '(:border "2" :cellspacing "0" :cellpadding "6" :rules "groups" :frame "hsides") "Default attributes and values which will be used in table tags. This is a plist where attributes are symbols, starting with -colons, and values are strings." +colons, and values are strings. + +When exporting to HTML5, these values will be disregarded." :group 'org-export-html :version "24.4" :package-version '(Org . "8.0") @@ -856,7 +891,9 @@ CSS classes, then this prefix can be very useful." "The extension for exported HTML files. %s will be replaced with the charset of the exported file. This may be a string, or an alist with export extensions -and corresponding declarations." +and corresponding declarations. + +This declaration only applies when exporting to XHTML." :group 'org-export-html :type '(choice (string :tag "Single declaration") @@ -872,8 +909,7 @@ Use utf-8 as the default value." :package-version '(Org . "8.0") :type 'coding-system) -(defcustom org-html-doctype - "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">" +(defcustom org-html-doctype "xhtml-strict" "Document type definition to use for exported HTML files. Can be set with the in-buffer HTML_DOCTYPE property or for publishing, with :html-doctype." @@ -882,6 +918,21 @@ publishing, with :html-doctype." :package-version '(Org . "8.0") :type 'string) +(defcustom org-html-html5-fancy nil + "When exporting to HTML5, set this to t to use new HTML5 + elements. This variable is ignored for anything other than + HTML5. + +For compatibility with Internet Explorer, it's probably a good +idea to download some form of the html5shiv (for instance +https://code.google.com/p/html5shiv/) and add it to your +HTML_HEAD_EXTRA, so that your pages don't break for users of IE +versions 8 and below." + :group 'org-export-html + :version "24.4" + :package-version '(Org . "8.0") + :type 'boolean) + (defcustom org-html-container-element "div" "HTML element to use for wrapping top level sections. Can be set with the in-buffer HTML_CONTAINER property or for @@ -962,7 +1013,8 @@ You can also customize this for each buffer, using something like (const :format " " mathml) (boolean)))) (defcustom org-html-mathjax-template - "<script type=\"text/javascript\" src=\"%PATH\"> + "<script type=\"text/javascript\" src=\"%PATH\"></script> +<script type=\"text/javascript\"> <!--/*--><![CDATA[/*><!--*/ MathJax.Hub.Config({ // Only one of the two following lines, depending on user settings @@ -1035,7 +1087,7 @@ precedence over this variable." '(("en" "<p class=\"author\">Author: %a (%e)</p> <p class=\"date\">Date: %d</p> <p class=\"creator\">%c</p> -<p class=\"xhtml-validation\">%v</p>")) +<p class=\"validation\">%v</p>")) "Alist of languages and format strings for the HTML postamble. The first element of each list is the language code, as used for @@ -1060,7 +1112,7 @@ like that: \"%%\"." :value-type (string :tag "Format string"))) (defcustom org-html-validation-link - "<a href=\"http://validator.w3.org/check?uri=referer\">Validate XHTML 1.0</a>" + "<a href=\"http://validator.w3.org/check?uri=referer\">Validate</a>" "Link to HTML validation service." :group 'org-export-html :type 'string) @@ -1240,6 +1292,18 @@ CSS classes, then this prefix can be very useful." ;;; Internal Functions +(defun org-html-xhtml-p (info) + (let ((dt (downcase (plist-get info :html-doctype)))) + (string-match-p "xhtml" dt))) + +(defun org-html-html5-p (info) + (let ((dt (downcase (plist-get info :html-doctype)))) + (member dt '("html5" "xhtml5" "<!doctype html>")))) + +(defun org-html-close-tag (tag attr info) + (concat "<" tag (or attr "") + (if (org-html-xhtml-p info) " />" ">"))) + (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 @@ -1253,7 +1317,7 @@ attributes with a nil value will be omitted from the result." "\"" """ (org-html-encode-plain-text item)))) (setcar output (format "%s=\"%s\"" key value)))))))) -(defun org-html-format-inline-image (src &optional +(defun org-html-format-inline-image (src info &optional caption label attr standalone-p) "Format an inline image from SRC. CAPTION, LABEL and ATTR are optional arguments providing the @@ -1262,6 +1326,7 @@ When STANDALONE-P is t, wrap the <img.../> into a <div>...</div>." (let* ((id (if (not label) "" (format " id=\"%s\"" (org-export-solidify-link-text label)))) (attr (concat attr + (format " src=\"%s\"" src) (cond ((string-match "\\<alt=" (or attr "")) "") ((string-match "^ltxpng/" src) @@ -1270,15 +1335,21 @@ When STANDALONE-P is t, wrap the <img.../> into a <div>...</div>." (org-find-text-property-in-string 'org-latex-src src)))) (t (format " alt=\"%s\"" - (file-name-nondirectory src))))))) + (file-name-nondirectory src)))))) + (html5-fancy (and (org-html-html5-p info) + (plist-get info :html-html5-fancy)))) (cond (standalone-p - (let ((img (format "<img src=\"%s\" %s/>" src attr))) - (format "\n<div%s class=\"figure\">%s%s\n</div>" + (let ((img (org-html-close-tag "img" attr info))) + (format (if html5-fancy + "\n<figure%s>%s%s\n</figure>" + "\n<div%s class=\"figure\">%s%s\n</div>") id (format "\n<p>%s</p>" img) (if (and caption (not (string= caption ""))) - (format "\n<p>%s</p>" caption) "")))) - (t (format "<img src=\"%s\" %s/>" src (concat attr id)))))) + (format (if html5-fancy + "\n<figcaption>%s</figcaption>" + "\n<p>%s</p>") caption) "")))) + (t (org-html-close-tag "img" (concat attr id) info))))) (defun org-html--textarea-block (element) "Transcode ELEMENT into a textarea block. @@ -1437,7 +1508,11 @@ INFO is a plist used as a communication channel." (cons 'plain-text org-element-all-objects) 'identity info)))))) (description (plist-get info :description)) - (keywords (plist-get info :keywords))) + (keywords (plist-get info :keywords)) + (charset (or (and org-html-coding-system + (fboundp 'coding-system-get) + (coding-system-get org-html-coding-system 'mime-charset)) + "iso-8859-1"))) (concat (format "<title>%s</title>\n" title) (format @@ -1445,21 +1520,24 @@ INFO is a plist used as a communication channel." (format-time-string (concat "<!-- " org-html-metadata-timestamp-format " -->\n")))) (format - "<meta http-equiv=\"Content-Type\" content=\"text/html;charset=%s\"/>\n" - (or (and org-html-coding-system - (fboundp 'coding-system-get) - (coding-system-get org-html-coding-system 'mime-charset)) - "iso-8859-1")) - (format "<meta name=\"generator\" content=\"Org-mode\"/>\n") + (if (org-html-html5-p info) + (org-html-close-tag "meta" " charset=\"%s\"" info) + (org-html-close-tag + "meta" " http-equiv=\"Content-Type\" content=\"text/html;charset=%s\"" info)) + charset) "\n" + (org-html-close-tag "meta" " name=\"generator\" content=\"Org-mode\"" info) "\n" (and (org-string-nw-p author) - (format "<meta name=\"author\" content=\"%s\"/>\n" - (funcall protect-string author))) + (org-html-close-tag "meta" (format " name=\"author\" content=\"%s\"" + (funcall protect-string author)) info) + "\n") (and (org-string-nw-p description) - (format "<meta name=\"description\" content=\"%s\"/>\n" - (funcall protect-string description))) + (org-html-close-tag "meta" (format " name=\"description\" content=\"%s\"%s\n" + (funcall protect-string description)) info) + "\n") (and (org-string-nw-p keywords) - (format "<meta name=\"keywords\" content=\"%s\"/>\n" - (funcall protect-string keywords)))))) + (org-html-close-tag "meta" (format " name=\"keywords\" content=\"%s\"" + (funcall protect-string keywords)) info) + "\n")))) (defun org-html--build-head (info) "Return information for the <head>..</head> of the HTML output. @@ -1472,8 +1550,10 @@ INFO is a plist used as a communication channel." (org-element-normalize-string (plist-get info :html-head-extra)) (when (and (plist-get info :html-htmlized-css-url) (eq org-html-htmlize-output-type 'css)) - (format "<link rel=\"stylesheet\" href=\"%s\" type=\"text/css\" />\n" - (plist-get info :html-htmlized-css-url))) + (org-html-close-tag "link" + (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)))) (defun org-html--build-mathjax-config (info) @@ -1570,7 +1650,7 @@ communication channel." (format-time-string org-html-metadata-timestamp-format))) (when (plist-get info :with-creator) (format "<p class=\"creator\">%s</p>\n" creator)) - (format "<p class=\"xhtml-validation\">%s</p>\n" + (format "<p class=\"validation\">%s</p>\n" validation-link)))) (t (format-spec (or (cadr (assoc @@ -1612,23 +1692,33 @@ holding export options." CONTENTS is the transcoded contents string. INFO is a plist holding export options." (concat - (format - (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)) - - "") - (or (and org-html-coding-system - (fboundp 'coding-system-get) - (coding-system-get org-html-coding-system 'mime-charset)) - "iso-8859-1")) - "\n" - (plist-get info :html-doctype) + (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))) + (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")))))) + (let* ((dt (plist-get info :html-doctype)) + (dt-cons (assoc dt org-html-doctype-alist))) + (if dt-cons + (cdr dt-cons) + dt)) "\n" - (format "<html xmlns=\"http://www.w3.org/1999/xhtml\" lang=\"%s\" xml:lang=\"%s\">\n" - (plist-get info :language) (plist-get info :language)) + (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))) + ">\n") "<head>\n" (org-html--build-meta-info info) (org-html--build-head info) @@ -2179,7 +2269,7 @@ holding contextual information." ;; Build the real contents of the sub-tree. (let* ((type (if numberedp 'ordered 'unordered)) (itemized-body (org-html-format-list-item - contents type nil nil full-text))) + contents type nil info nil full-text))) (concat (and (org-export-first-sibling-p headline info) (org-html-begin-plain-list type)) @@ -2239,7 +2329,7 @@ holding contextual information." (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." - "<hr/>") + (org-html-close-tag "hr" nil info)) ;;;; Inline Src Block @@ -2275,8 +2365,9 @@ holding contextual information." (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><br/>\n%s</div>" + (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)))) ;;;; Italic @@ -2296,11 +2387,12 @@ contextual information." (trans "<code>[-]</code>") (t ""))) -(defun org-html-format-list-item (contents type checkbox +(defun org-html-format-list-item (contents type checkbox info &optional term-counter-id headline) "Format a list item into HTML." - (let ((checkbox (concat (org-html-checkbox checkbox) (and checkbox " ")))) + (let ((checkbox (concat (org-html-checkbox checkbox) (and checkbox " "))) + (br (org-html-close-tag "br" nil info))) (concat (case type (ordered @@ -2308,13 +2400,13 @@ contextual information." (extra (if counter (format " value=\"%s\"" counter) ""))) (concat (format "<li%s>" extra) - (when headline (concat headline "<br/>"))))) + (when headline (concat headline br))))) (unordered (let* ((id term-counter-id) (extra (if id (format " id=\"%s\"" id) ""))) (concat (format "<li%s>" extra) - (when headline (concat headline "<br/>"))))) + (when headline (concat headline br))))) (descriptive (let* ((term term-counter-id)) (setq term (or term "(no term)")) @@ -2340,7 +2432,7 @@ contextual information." (tag (let ((tag (org-element-property :tag item))) (and tag (org-export-data tag info))))) (org-html-format-list-item - contents type checkbox (or tag counter)))) + contents type checkbox info (or tag counter)))) ;;;; Keyword @@ -2399,7 +2491,7 @@ CONTENTS is nil. INFO is a plist holding contextual information." (when (and formula-link (string-match "file:\\([^]]*\\)" formula-link)) (org-html-format-inline-image - (match-string 1 formula-link) caption label attr t)))) + (match-string 1 formula-link) info caption label attr t)))) (t latex-frag)))) ;;;; Latex Fragment @@ -2418,7 +2510,7 @@ CONTENTS is nil. INFO is a plist holding contextual information." (when (and formula-link (string-match "file:\\([^]]*\\)" formula-link)) (org-html-format-inline-image - (match-string 1 formula-link))))) + (match-string 1 formula-link) info)))) (t latex-frag)))) ;;;; Line Break @@ -2426,7 +2518,7 @@ CONTENTS is nil. INFO is a plist holding contextual information." (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." - "<br/>\n") + (concat (org-html-close-tag "br" nil info) "\n")) ;;;; Link @@ -2451,7 +2543,7 @@ Inline images can have these attributes: (label (org-element-property :name parent))) ;; Return proper string, depending on DISPOSITION. (org-html-format-inline-image - path caption label + path info caption label (org-html--make-attribute-string (org-export-read-attribute :attr_html parent)) (org-html-standalone-image-p link info)))) @@ -2769,7 +2861,8 @@ contextual information." (when (plist-get info :preserve-breaks) (setq output (replace-regexp-in-string - "\\(\\\\\\\\\\)?[ \t]*\n" "<br/>\n" output))) + "\\(\\\\\\\\\\)?[ \t]*\n" + (concat (org-html-close-tag "br" nil info) "\n") output))) ;; Return value. output)) @@ -2869,9 +2962,25 @@ contextual information." "Transcode a SPECIAL-BLOCK element from Org to HTML. CONTENTS holds the contents of the block. INFO is a plist holding contextual information." - (format "<div class=\"%s\">\n%s\n</div>" - (downcase (org-element-property :type special-block)) - contents)) + (let* ((block-type (downcase + (org-element-property :type special-block))) + (contents (or contents "")) + (html5-fancy (and (org-html-html5-p info) + (plist-get info :html-html5-fancy) + (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)))) ;;;; Src Block @@ -3044,11 +3153,12 @@ contextual information." (let* ((label (org-element-property :name table)) (caption (org-export-get-caption table)) (attributes - (org-html--make-attribute-string - (org-combine-plists - (and label (list :id (org-export-solidify-link-text label))) - (plist-get info :html-table-attributes) - (org-export-read-attribute :attr_html table)))) + (if (org-html-html5-p info) "" + (org-html--make-attribute-string + (org-combine-plists + (and label (list :id (org-export-solidify-link-text label))) + (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) @@ -3066,7 +3176,9 @@ contextual information." table-cell info) "\n<colgroup>") ;; Add a column. Also specify it's alignment. - (format "\n<col %s/>" (format alignspec 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) @@ -3128,9 +3240,10 @@ contextual information." ;; Replace each newline character with line break. Also replace ;; each blank line with a line break. (setq contents (replace-regexp-in-string - "^ *\\\\\\\\$" "<br/>\n" + "^ *\\\\\\\\$" (format "%s\n" (org-html-close-tag "br" nil info)) (replace-regexp-in-string - "\\(\\\\\\\\\\)?[ \t]*\n" " <br/>\n" contents))) + "\\(\\\\\\\\\\)?[ \t]*\n" + (format "%s\n" (org-html-close-tag "br" nil info)) contents))) ;; Replace each white space at beginning of a line with a ;; non-breaking space. (while (string-match "^[ \t]+" contents) -- 1.8.2.2