%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)))
	    (when in-local-list
	      ;; Close any local lists before inserting a new header line
	      (while local-list-type
		(org-close-li (car local-list-type))
		(insert (format "%sl>\n" (car local-list-type)))
		(pop local-list-type))
	      (setq local-list-indent nil
		    in-local-list nil))
	    (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))
		    initial-number nil
		    item-tag nil)
	      (if (string-match "\\`\\[@start:\\([0-9]+\\)\\][ \t]?" line)
		  (setq initial-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))))
	      (when (and (not (equal item-type "d"))
			 (not (string-match "[^ \t]" line)))
		;; empty line.  Pretend indentation is large.
		(setq ind (1+ (or (car local-list-indent) 1))))
	      (while (and in-local-list
			  (or (and (= ind (car local-list-indent))
				   (not starter))
			      (< 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))
	      (cond
	       ((and starter
		     (or (not in-local-list)
			 (> ind (car local-list-indent))))
		;; check for a specified start number
		;; Start new (level of) list
		(org-close-par-maybe)
		(insert (cond
			 ((equal item-type "u") "
\n- \n")
			 ((equal item-type "o")
			  (if initial-number
			      (format "\n- \n" initial-number)
			    "\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))
	       (starter
		;; continue current list
		(org-close-li (car local-list-type))
		(insert (cond
			 ((equal (car local-list-type) "d")
			  (format "
- %s
- \n" (or item-tag "???")))
			 (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  
 
 
 
\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 "
" ""))))))))
(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]*