%s
"
(format
(or (and (stringp org-export-html-xml-declaration)
org-export-html-xml-declaration)
(cdr (assoc html-extension org-export-html-xml-declaration))
(cdr (assoc "html" org-export-html-xml-declaration))
"")
(or charset "iso-8859-1"))
language language
title
(or charset "iso-8859-1")
date author description keywords
style
mathjax
(if (or link-up link-home)
(concat
(format org-export-html-home/up-format
(or link-up link-home)
(or link-home link-up))
"\n")
"")))
(org-export-html-insert-plist-item opt-plist :preamble opt-plist)
(when (plist-get opt-plist :auto-preamble)
(if title (insert (format org-export-html-title-format
(org-html-expand title))))))
(if (and org-export-with-toc (not body-only))
(progn
(push (format "
%s\n"
org-export-html-toplevel-hlevel
(nth 3 lang-words)
org-export-html-toplevel-hlevel)
thetoc)
(push "
\n" thetoc)
(push "
\n- " thetoc)
(setq lines
(mapcar '(lambda (line)
(if (and (string-match org-todo-line-regexp line)
(not (get-text-property 0 'org-protected line)))
;; This is a headline
(progn
(setq have-headings t)
(setq level (- (match-end 1) (match-beginning 1)
level-offset)
level (org-tr-level level)
txt (save-match-data
(org-html-expand
(org-export-cleanup-toc-line
(match-string 3 line))))
todo
(or (and org-export-mark-todo-in-toc
(match-beginning 2)
(not (member (match-string 2 line)
org-done-keywords)))
; TODO, not DONE
(and org-export-mark-todo-in-toc
(= level umax-toc)
(org-search-todo-below
line lines level))))
(if (string-match
(org-re "[ \t]+:\\([[:alnum:]_@:]+\\):[ \t]*$") txt)
(setq txt (replace-match " \\1" t nil txt)))
(if (string-match quote-re0 txt)
(setq txt (replace-match "" t t txt)))
(setq snumber (org-section-number level))
(if org-export-with-section-numbers
(setq txt (concat snumber " " txt)))
(if (<= level (max umax umax-toc))
(setq head-count (+ head-count 1)))
(if (<= level umax-toc)
(progn
(if (> level org-last-level)
(progn
(setq cnt (- level org-last-level))
(while (>= (setq cnt (1- cnt)) 0)
(push "\n
\n- " thetoc))
(push "\n" thetoc)))
(if (< level org-last-level)
(progn
(setq cnt (- org-last-level level))
(while (>= (setq cnt (1- cnt)) 0)
(push "
\n
" thetoc))
(push "\n" thetoc)))
;; Check for targets
(while (string-match org-any-target-regexp line)
(setq line (replace-match
(concat "@" (match-string 1 line) "@ ")
t t line)))
(while (string-match "<\\(<\\)+\\|>\\(>\\)+" txt)
(setq txt (replace-match "" t t txt)))
(setq href
(replace-regexp-in-string
"\\." "_" (format "sec-%s" snumber)))
(setq href (or (cdr (assoc href org-export-preferred-target-alist)) href))
(push
(format
(if todo
" \n- %s"
"
\n- %s")
href txt) thetoc)
(setq org-last-level level))
)))
line)
lines))
(while (> org-last-level (1- org-min-level))
(setq org-last-level (1- org-last-level))
(push "
\n
\n" thetoc))
(push "
\n" thetoc)
(setq thetoc (if have-headings (nreverse thetoc) nil))))
(setq head-count 0)
(org-init-section-numbers)
(org-open-par)
(while (setq line (pop lines) origline line)
(catch 'nextline
;; end of quote section?
(when (and inquote (string-match "^\\*+ " line))
(insert "\n")
(org-open-par)
(setq inquote nil))
;; inside a quote section?
(when inquote
(insert (org-html-protect line) "\n")
(throw 'nextline nil))
;; Fixed-width, verbatim lines (examples)
(when (and org-export-with-fixed-width
(string-match "^[ \t]*:\\(\\([ \t]\\|$\\)\\(.*\\)\\)" line))
(when (not infixed)
(setq infixed t)
(org-close-par-maybe)
(insert "
\n"))
(insert (org-html-protect (match-string 3 line)) "\n")
(when (or (not lines)
(not (string-match "^[ \t]*:\\(\\([ \t]\\|$\\)\\(.*\\)\\)"
(car lines))))
(setq infixed nil)
(insert "
\n")
(org-open-par))
(throw 'nextline nil))
;; Explicit list closure
(when (equal "ORG-LIST-END" line)
(while local-list-indent
(org-close-li (car local-list-type))
(insert (format "%sl>\n" (car local-list-type)))
(pop local-list-type)
(pop local-list-indent))
(setq in-local-list nil)
(org-open-par)
(throw 'nextline nil))
;; Protected HTML
(when (get-text-property 0 'org-protected line)
(let (par (ind (get-text-property 0 'original-indentation line)))
(when (re-search-backward
"\\(
\\)\\([ \t\r\n]*\\)\\=" (- (point) 100) t)
(setq par (match-string 1))
(replace-match "\\2\n"))
(insert line "\n")
(while (and lines
(or (= (length (car lines)) 0)
(not ind)
(equal ind (get-text-property 0 'original-indentation (car lines))))
(or (= (length (car lines)) 0)
(get-text-property 0 'org-protected (car lines))))
(insert (pop lines) "\n"))
(and par (insert "
\n")))
(throw 'nextline nil))
;; Blockquotes, verse, and center
(when (equal "ORG-BLOCKQUOTE-START" line)
(org-close-par-maybe)
(insert "
\n")
(org-open-par)
(throw 'nextline nil))
(when (equal "ORG-BLOCKQUOTE-END" line)
(org-close-par-maybe)
(insert "\n
\n")
(org-open-par)
(throw 'nextline nil))
(when (equal "ORG-VERSE-START" line)
(org-close-par-maybe)
(insert "\n
\n")
(setq org-par-open t)
(setq inverse t)
(throw 'nextline nil))
(when (equal "ORG-VERSE-END" line)
(insert "
\n")
(setq org-par-open nil)
(org-open-par)
(setq inverse nil)
(throw 'nextline nil))
(when (equal "ORG-CENTER-START" line)
(org-close-par-maybe)
(insert "\n
")
(org-open-par)
(throw 'nextline nil))
(when (equal "ORG-CENTER-END" line)
(org-close-par-maybe)
(insert "\n
")
(org-open-par)
(throw 'nextline nil))
(run-hooks 'org-export-html-after-blockquotes-hook)
(when inverse
(let ((i (org-get-string-indentation line)))
(if (> i 0)
(setq line (concat (mapconcat 'identity
(make-list (* 2 i) "\\nbsp") "")
" " (org-trim line))))
(unless (string-match "\\\\\\\\[ \t]*$" line)
(setq line (concat line "\\\\")))))
;; make targets to anchors
(setq start 0)
(while (string-match
"<<\\([^<>]*\\)>>>?\\((INVISIBLE)\\)?[ \t]*\n?" line start)
(cond
((get-text-property (match-beginning 1) 'org-protected line)
(setq start (match-end 1)))
((match-end 2)
(setq line (replace-match
(format
"@
@"
(org-solidify-link-text (match-string 1 line))
(org-solidify-link-text (match-string 1 line)))
t t line)))
((and org-export-with-toc (equal (string-to-char line) ?*))
;; FIXME: NOT DEPENDENT on TOC?????????????????????
(setq line (replace-match
(concat "@
"
(match-string 1 line) "@ ")
;; (concat "@
" (match-string 1 line) "@ ")
t t line)))
(t
(setq line (replace-match
(concat "@
" (match-string 1 line)
"@ ")
t t line)))))
(setq line (org-html-handle-time-stamps line))
;; replace "&" by "&", "<" and ">" by "<" and ">"
;; handle @<..> HTML tags (replace "@>..<" by "<..>")
;; Also handle sub_superscripts and checkboxes
(or (string-match org-table-hline-regexp line)
(setq line (org-html-expand line)))
;; Format the links
(setq start 0)
(while (string-match org-bracket-link-analytic-regexp++ line start)
(setq start (match-beginning 0))
(setq path (save-match-data (org-link-unescape
(match-string 3 line))))
(setq type (cond
((match-end 2) (match-string 2 line))
((save-match-data
(or (file-name-absolute-p path)
(string-match "^\\.\\.?/" path)))
"file")
(t "internal")))
(setq path (org-extract-attributes (org-link-unescape path)))
(setq attr (get-text-property 0 'org-attributes path))
(setq desc1 (if (match-end 5) (match-string 5 line))
desc2 (if (match-end 2) (concat type ":" path) path)
descp (and desc1 (not (equal desc1 desc2)))
desc (or desc1 desc2))
;; Make an image out of the description if that is so wanted
(when (and descp (org-file-image-p
desc org-export-html-inline-image-extensions))
(save-match-data
(if (string-match "^file:" desc)
(setq desc (substring desc (match-end 0)))))
(setq desc (org-add-props
(concat "
")
'(org-protected t))))
(cond
((equal type "internal")
(let
((frag-0
(if (= (string-to-char path) ?#)
(substring path 1)
path)))
(setq rpl
(org-html-make-link
opt-plist
""
""
(org-solidify-link-text
(save-match-data (org-link-unescape frag-0))
nil)
desc attr nil))))
((and (equal type "id")
(setq id-file (org-id-find-id-file path)))
;; This is an id: link to another file (if it was the same file,
;; it would have become an internal link...)
(save-match-data
(setq id-file (file-relative-name
id-file
(file-name-directory org-current-export-file)))
(setq rpl
(org-html-make-link opt-plist
"file" id-file
(concat (if (org-uuidgen-p path) "ID-") path)
desc
attr
nil))))
((member type '("http" "https"))
;; standard URL, can inline as image
(setq rpl
(org-html-make-link opt-plist
type path nil
desc
attr
(org-html-should-inline-p path descp))))
((member type '("ftp" "mailto" "news"))
;; standard URL, can't inline as image
(setq rpl
(org-html-make-link opt-plist
type path nil
desc
attr
nil)))
((string= type "coderef")
(let*
((coderef-str (format "coderef-%s" path))
(attr-1
(format "class=\"coderef\" onmouseover=\"CodeHighlightOn(this, '%s');\" onmouseout=\"CodeHighlightOff(this, '%s');\""
coderef-str coderef-str)))
(setq rpl
(org-html-make-link opt-plist
type "" coderef-str
(format
(org-export-get-coderef-format
path
(and descp desc))
(cdr (assoc path org-export-code-refs)))
attr-1
nil))))
((functionp (setq fnc (nth 2 (assoc type org-link-protocols))))
;; The link protocol has a function for format the link
(setq rpl
(save-match-data
(funcall fnc (org-link-unescape path) desc1 'html))))
((string= type "file")
;; FILE link
(save-match-data
(let*
((components
(if
(string-match "::\\(.*\\)" path)
(list
(replace-match "" t nil path)
(match-string 1 path))
(list path nil)))
;;The proper path, without a fragment
(path-1
(first components))
;;The raw fragment
(fragment-0
(second components))
;;Check the fragment. If it can't be used as
;;target fragment we'll pass nil instead.
(fragment-1
(if
(and fragment-0
(not (string-match "^[0-9]*$" fragment-0))
(not (string-match "^\\*" fragment-0))
(not (string-match "^/.*/$" fragment-0)))
(org-solidify-link-text
(org-link-unescape fragment-0))
nil))
(desc-2
;;Description minus "file:" and ".org"
(if (string-match "^file:" desc)
(let
((desc-1 (replace-match "" t t desc)))
(if (string-match "\\.org$" desc-1)
(replace-match "" t t desc-1)
desc-1))
desc)))
(setq rpl
(if
(and
(functionp link-validate)
(not (funcall link-validate path-1 current-dir)))
desc
(org-html-make-link opt-plist
"file" path-1 fragment-1 desc-2 attr
(org-html-should-inline-p path-1 descp)))))))
(t
;; just publish the path, as default
(setq rpl (concat "
<" type ":"
(save-match-data (org-link-unescape path))
">"))))
(setq line (replace-match rpl t t line)
start (+ start (length rpl))))
;; TODO items
(if (and (string-match org-todo-line-regexp line)
(match-beginning 2))
(setq line
(concat (substring line 0 (match-beginning 2))
"
" (org-export-html-get-todo-kwd-class-name
(match-string 2 line))
"" (substring line (match-end 2)))))
;; Does this contain a reference to a footnote?
(when org-export-with-footnotes
(setq start 0)
(while (string-match "\\([^* \t].*?\\)\\[\\([0-9]+\\)\\]" line start)
(if (get-text-property (match-beginning 2) 'org-protected line)
(setq start (match-end 2))
(let ((n (match-string 2 line)) extra a)
(if (setq a (assoc n footref-seen))
(progn
(setcdr a (1+ (cdr a)))
(setq extra (format ".%d" (cdr a))))
(setq extra "")
(push (cons n 1) footref-seen))
(setq line
(replace-match
(format
(concat "%s"
(format org-export-html-footnote-format
""))
(or (match-string 1 line) "") n extra n n)
t t line))))))
(cond
((string-match "^\\(\\*+\\)[ \t]+\\(.*\\)" line)
;; This is a headline
(setq level (org-tr-level (- (match-end 1) (match-beginning 1)
level-offset))
txt (match-string 2 line))
(if (string-match quote-re0 txt)
(setq txt (replace-match "" t t txt)))
(if (<= level (max umax umax-toc))
(setq head-count (+ head-count 1)))
(setq first-heading-pos (or first-heading-pos (point)))
(org-html-level-start level txt umax
(and org-export-with-toc (<= level umax))
head-count)
;; QUOTES
(when (string-match quote-re line)
(org-close-par-maybe)
(insert "
")
(setq inquote t)))
((and org-export-with-tables
(string-match "^\\([ \t]*\\)\\(|\\|\\+-+\\+\\)" line))
(when (not table-open)
;; New table starts
(setq table-open t table-buffer nil table-orig-buffer nil))
;; Accumulate lines
(setq table-buffer (cons line table-buffer)
table-orig-buffer (cons origline table-orig-buffer))
(when (or (not lines)
(not (string-match "^\\([ \t]*\\)\\(|\\|\\+-+\\+\\)"
(car lines))))
(setq table-open nil
table-buffer (nreverse table-buffer)
table-orig-buffer (nreverse table-orig-buffer))
(org-close-par-maybe)
(insert (org-format-table-html table-buffer table-orig-buffer))))
(t
;; Normal lines
(when (string-match
(cond
((eq llt t) "^\\([ \t]*\\)\\(\\([-+*] \\)\\|\\([0-9]+[.)]\\) \\)?\\( *[^ \t\n\r]\\|[ \t]*$\\)")
((= llt ?.) "^\\([ \t]*\\)\\(\\([-+*] \\)\\|\\([0-9]+\\.\\) \\)?\\( *[^ \t\n\r]\\|[ \t]*$\\)")
((= llt ?\)) "^\\([ \t]*\\)\\(\\([-+*] \\)\\|\\([0-9]+)\\) \\)?\\( *[^ \t\n\r]\\|[ \t]*$\\)")
(t (error "Invalid value of `org-plain-list-ordered-item-terminator'")))
line)
(setq ind (or (get-text-property 0 'original-indentation line)
(org-get-string-indentation line))
item-type (if (match-beginning 4) "o" "u")
starter (if (match-beginning 2)
(substring (match-string 2 line) 0 -1))
line (substring line (match-beginning 5))
item-number nil
item-tag nil)
(if (string-match "\\[@\\(?:start:\\)?\\([0-9]+\\)\\][ \t]?" line)
(setq item-number (match-string 1 line)
line (replace-match "" t t line)))
(if (and starter (string-match "\\(.*?\\) ::[ \t]*" line))
(setq item-type "d"
item-tag (match-string 1 line)
line (substring line (match-end 0))))
(cond
((and starter
(or (not in-local-list)
(> ind (car local-list-indent))))
;; Start new (level of) list
(org-close-par-maybe)
(insert (cond
((equal item-type "u") "
\n- \n")
((and (equal item-type "o") item-number)
(format "
\n- \n" item-number))
((equal item-type "o") "
\n- \n")
((equal item-type "d")
(format "
\n- %s
- \n" item-tag))))
(push item-type local-list-type)
(push ind local-list-indent)
(setq in-local-list t))
;; Continue list
(starter
;; terminate any previous sublist but first ensure
;; list is not ill-formed.
(let ((min-ind (apply 'min local-list-indent)))
(when (< ind min-ind) (setq ind min-ind)))
(while (< ind (car local-list-indent))
(org-close-li (car local-list-type))
(insert (format "%sl>\n" (car local-list-type)))
(pop local-list-type) (pop local-list-indent)
(setq in-local-list local-list-indent))
;; insert new item
(org-close-li (car local-list-type))
(insert (cond
((equal (car local-list-type) "d")
(format "
- %s
- \n" (or item-tag "???")))
((and (equal item-type "o") item-number)
(format "
- \n" item-number))
(t "
- \n")))))
(if (string-match "^[ \t]*\\[\\([X ]\\)\\]" line)
(setq line
(replace-match
(if (equal (match-string 1 line) "X")
"[X]"
"[X]")
t t line))))
;; Horizontal line
(when (string-match "^[ \t]*-\\{5,\\}[ \t]*$" line)
(if org-par-open
(insert "\n\n
\n\n")
(insert "\n
\n"))
(throw 'nextline nil))
;; Empty lines start a new paragraph. If hand-formatted lists
;; are not fully interpreted, lines starting with "-", "+", "*"
;; also start a new paragraph.
(if (string-match "^ [-+*]-\\|^[ \t]*$" line) (org-open-par))
;; Is this the start of a footnote?
(when org-export-with-footnotes
(when (and (boundp 'footnote-section-tag-regexp)
(string-match (concat "^" footnote-section-tag-regexp)
line))
;; ignore this line
(throw 'nextline nil))
(when (string-match "^[ \t]*\\[\\([0-9]+\\)\\]" line)
(org-close-par-maybe)
(let ((n (match-string 1 line)))
(setq org-par-open t
line (replace-match
(format
(concat " so that the footnote matcher
;; does not see this.
(if (not (get-text-property (match-beginning 0)
'org-protected line))
(setq line (replace-match "" t t line)))
(setq start (match-end 0))))
(insert line "\n")))))
;; Properly close all local lists and other lists
(when inquote
(insert "\n")
(org-open-par))
(org-html-level-start 1 nil umax
(and org-export-with-toc (<= level umax))
head-count)
;; the
to close the last text-... div.
(when (and (> umax 0) first-heading-pos) (insert "\n"))
(save-excursion
(goto-char (point-min))
(while (re-search-forward "\\|\\'\\)" nil t)
(push (match-string 0) footnotes)
(replace-match "" t t)))
(when footnotes
(insert (format org-export-html-footnotes-section
(nth 4 lang-words)
(mapconcat 'identity (nreverse footnotes) "\n"))
"\n"))
(let ((bib (org-export-html-get-bibliography)))
(when bib
(insert "\n" bib "\n")))
(unless body-only
(when (plist-get opt-plist :auto-postamble)
(insert "\n")
(when (and org-export-author-info author)
(insert "
"
(nth 1 lang-words) ": " author "\n")
(when (and org-export-email-info email (string-match "\\S-" email))
(if (listp (split-string email ",+ *"))
(mapc (lambda(e)
(insert "<"
e ">\n"))
(split-string email ",+ *"))
(insert "<"
email ">\n")))
(insert "
\n"))
(when (and date org-export-time-stamp-file)
(insert "
"
(nth 2 lang-words) ": "
date "
\n"))
(when org-export-creator-info
(insert (format "
HTML generated by org-mode %s in emacs %s
\n"
org-version emacs-major-version)))
(when org-export-html-validation-link
(insert org-export-html-validation-link "\n"))
(insert "
"))
(if org-export-html-with-timestamp
(insert org-export-html-html-helper-timestamp))
(org-export-html-insert-plist-item opt-plist :postamble opt-plist)
(insert "\n\n\n\n"))
(unless (plist-get opt-plist :buffer-will-be-killed)
(normal-mode)
(if (eq major-mode (default-value 'major-mode))
(html-mode)))
;; insert the table of contents
(goto-char (point-min))
(when thetoc
(if (or (re-search-forward
"" ""))))))))
(defun org-export-html-get-bibliography ()
"Find bibliography, cut it out and return it."
(catch 'exit
(let (beg end (cnt 1) bib)
(save-excursion
(goto-char (point-min))
(when (re-search-forward "^[ \t]*
" nil t)
(setq cnt (+ cnt (if (string= (match-string 0) "
") (forward-char 1))
(setq bib (buffer-substring beg (point)))
(delete-region beg (point))
(throw 'exit bib))))
nil))))
(defvar org-table-number-regexp) ; defined in org-table.el
(defun org-format-table-html (lines olines &optional no-css)
"Find out which HTML converter to use and return the HTML code.
NO-CSS is passed to the exporter."
(if (stringp lines)
(setq lines (org-split-string lines "\n")))
(if (string-match "^[ \t]*|" (car lines))
;; A normal org table
(org-format-org-table-html lines nil no-css)
;; Table made by table.el - test for spanning
(let* ((hlines (delq nil (mapcar
(lambda (x)
(if (string-match "^[ \t]*\\+-" x) x
nil))
lines)))
(first (car hlines))
(ll (and (string-match "\\S-+" first)
(match-string 0 first)))
(re (concat "^[ \t]*" (regexp-quote ll)))
(spanning (delq nil (mapcar (lambda (x) (not (string-match re x)))
hlines))))
(if (and (not spanning)
(not org-export-prefer-native-exporter-for-tables))
;; We can use my own converter with HTML conversions
(org-format-table-table-html lines)
;; Need to use the code generator in table.el, with the original text.
(org-format-table-table-html-using-table-generate-source olines)))))
(defvar org-table-number-fraction) ; defined in org-table.el
(defun org-format-org-table-html (lines &optional splice no-css)
"Format a table into HTML.
LINES is a list of lines. Optional argument SPLICE means, do not
insert header and surrounding
tags, just format the lines.
Optional argument NO-CSS means use XHTML attributes instead of CSS
for formatting. This is required for the DocBook exporter."
(require 'org-table)
;; Get rid of hlines at beginning and end
(if (string-match "^[ \t]*|-" (car lines)) (setq lines (cdr lines)))
(setq lines (nreverse lines))
(if (string-match "^[ \t]*|-" (car lines)) (setq lines (cdr lines)))
(setq lines (nreverse lines))
(when org-export-table-remove-special-lines
;; Check if the table has a marking column. If yes remove the
;; column and the special lines
(setq lines (org-table-clean-before-export lines)))
(let* ((caption (org-find-text-property-in-string 'org-caption (car lines)))
(label (org-find-text-property-in-string 'org-label (car lines)))
(forced-aligns (org-find-text-property-in-string 'org-forced-aligns
(car lines)))
(attributes (org-find-text-property-in-string 'org-attributes
(car lines)))
(html-table-tag (org-export-splice-attributes
html-table-tag attributes))
(head (and org-export-highlight-first-table-line
(delq nil (mapcar
(lambda (x) (string-match "^[ \t]*|-" x))
(cdr lines)))))
(nline 0) fnum nfields i (cnt 0)
tbopen line fields html gr colgropen rowstart rowend
ali align aligns n)
(setq caption (and caption (org-html-do-expand caption)))
(when (and forced-aligns org-table-clean-did-remove-column)
(setq forced-aligns
(mapcar (lambda (x) (cons (1- (car x)) (cdr x))) forced-aligns)))
(if splice (setq head nil))
(unless splice (push (if head "" "") html))
(setq tbopen t)
(while (setq line (pop lines))
(catch 'next-line
(if (string-match "^[ \t]*|-" line)
(progn
(unless splice
(push (if head "" "") html)
(if lines (push "" html) (setq tbopen nil)))
(setq head nil) ;; head ends here, first time around
;; ignore this line
(throw 'next-line t)))
;; Break the line into fields
(setq fields (org-split-string line "[ \t]*|[ \t]*"))
(unless fnum (setq fnum (make-vector (length fields) 0)
nfields (length fnum)))
(setq nline (1+ nline) i -1
rowstart (eval (car org-export-table-row-tags))
rowend (eval (cdr org-export-table-row-tags)))
(push (concat rowstart
(mapconcat
(lambda (x)
(setq i (1+ i) ali (format "@@class%03d@@" i))
(if (and (< i nfields) ; make sure no rogue line causes an error here
(string-match org-table-number-regexp x))
(incf (aref fnum i)))
(cond
(head
(concat
(format (car org-export-table-header-tags)
"col" ali)
x
(cdr org-export-table-header-tags)))
((and (= i 0) org-export-html-table-use-header-tags-for-first-column)
(concat
(format (car org-export-table-header-tags)
"row" ali)
x
(cdr org-export-table-header-tags)))
(t
(concat (format (car org-export-table-data-tags) ali)
x
(cdr org-export-table-data-tags)))))
fields "")
rowend)
html)))
(unless splice (if tbopen (push "" html)))
(unless splice (push "
\n" html))
(setq html (nreverse html))
(unless splice
;; Put in col tags with the alignment (unfortunately often ignored...)
(unless (car org-table-colgroup-info)
(setq org-table-colgroup-info
(cons :start (cdr org-table-colgroup-info))))
(setq i 0)
(push (mapconcat
(lambda (x)
(setq gr (pop org-table-colgroup-info)
i (1+ i)
align (if (assoc i forced-aligns)
(cdr (assoc (cdr (assoc i forced-aligns))
'(("l" . "left") ("r" . "right")
("c" . "center"))))
(if (> (/ (float x) nline)
org-table-number-fraction)
"right" "left")))
(push align aligns)
(format (if no-css
"%s
%s"
"%s
%s")
(if (memq gr '(:start :startend))
(prog1
(if colgropen
"\n
"
"")
(setq colgropen t))
"")
align
(if (memq gr '(:end :startend))
(progn (setq colgropen nil) "")
"")))
fnum "")
html)
(setq aligns (nreverse aligns))
(if colgropen (setq html (cons (car html)
(cons "" (cdr html)))))
;; Since the output of HTML table formatter can also be used in
;; DocBook document, we want to always include the caption to make
;; DocBook XML file valid.
(push (format "
%s" (or caption "")) html)
(when label (push (format "
" label label)
html))
(push html-table-tag html))
(setq html (mapcar
(lambda (x)
(replace-regexp-in-string
"@@class\\([0-9]+\\)@@"
(lambda (txt)
(if (not org-export-html-table-align-individual-fields)
""
(setq n (string-to-number (match-string 1 txt)))
(format (if no-css " align=\"%s\"" " class=\"%s\"")
(or (nth n aligns) "left"))))
x))
html))
(concat (mapconcat 'identity html "\n") "\n")))
(defun org-export-splice-attributes (tag attributes)
"Read attributes in string ATTRIBUTES, add and replace in HTML tag TAG."
(if (not attributes)
tag
(let (oldatt newatt)
(setq oldatt (org-extract-attributes-from-string tag)
tag (pop oldatt)
newatt (cdr (org-extract-attributes-from-string attributes)))
(while newatt
(setq oldatt (plist-put oldatt (pop newatt) (pop newatt))))
(if (string-match ">" tag)
(setq tag
(replace-match (concat (org-attributes-to-string oldatt) ">")
t t tag)))
tag)))
(defun org-format-table-table-html (lines)
"Format a table generated by table.el into HTML.
This conversion does *not* use `table-generate-source' from table.el.
This has the advantage that Org-mode's HTML conversions can be used.
But it has the disadvantage, that no cell- or row-spanning is allowed."
(let (line field-buffer
(head org-export-highlight-first-table-line)
fields html empty i)
(setq html (concat html-table-tag "\n"))
(while (setq line (pop lines))
(setq empty " ")
(catch 'next-line
(if (string-match "^[ \t]*\\+-" line)
(progn
(if field-buffer
(progn
(setq
html
(concat
html
"
"
(mapconcat
(lambda (x)
(if (equal x "") (setq x empty))
(if head
(concat
(format (car org-export-table-header-tags) "col" "")
x
(cdr org-export-table-header-tags))
(concat (format (car org-export-table-data-tags) "") x
(cdr org-export-table-data-tags))))
field-buffer "\n")
"
\n"))
(setq head nil)
(setq field-buffer nil)))
;; Ignore this line
(throw 'next-line t)))
;; Break the line into fields and store the fields
(setq fields (org-split-string line "[ \t]*|[ \t]*"))
(if field-buffer
(setq field-buffer (mapcar
(lambda (x)
(concat x "
" (pop fields)))
field-buffer))
(setq field-buffer fields))))
(setq html (concat html "