;;;; html-from-latex.el -- Assistance for creating HTML from LaTeX documents
;;; Time-stamp: <2005-02-24 11:03:40 jcgs>
;; This program 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 2 of the License, or (at your
;; option) any later version.
;; This program is distributed in the hope that it will be useful, but
;; WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
;; General Public License for more details.
;; You should have received a copy of the GNU General Public License along
;; with this program; if not, write to the Free Software Foundation, Inc.,
;; 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
(provide 'html-from-latex)
(require 'replace-regexp-list)
(defvar latex-2-html-patterns nil
"Edits to make for a first bash at htmlizing latex")
(setq latex-2-html-patterns
'(("Time stamp<\\([^>]+\\)>" . "Time stamp: \\1")
("\\\\\\([a-z]+ ?\\)$" . "\\\\\\1 ")
("\\\\par" . "
")
("\\\\-" . "")
("\\\\begin{itemize}" . "
")
("\\\\end{itemize}" . "
")
("\\\\begin{codexample}" . "")
("\\\\end{codexample}" . "
")
("\\\\begin{verbatim}" . "")
("\\\\end{verbatim}" . "")
("\\\\begin{chendquote}" . "
\n")
("\\\\end{chendquote}" . "
")
("\\\\item" . "")
("%\\(.+\\)$" . "")
("{\\\\em \\([^}]+\\)}" . "\\1")
("{\\\\it \\([^}]+\\)}" . "\\1")
("{\\\\tt \\([^}]+\\)}" . "\\1")
("\\\\chapter ?{\\([^}]+\\)}" . "\\1
")
("\\\\section ?{\\([^}]+\\)}" . "\\1
")
("\\\\subsection ?{\\([^}]+\\)}" . "\\1
")
("\\\\label{\\([^}]+\\)}" . "")
("\\\\ref{\\([^}]+\\)}" . "\\1")
("\\\\input{\\([^}]+\\)}" . "\\1")
("\\\\cite{\\([^}]+\\)}" .
"\\1")
("\\\\attribute{\\([^}]+\\)}" . "
\\1
")
("\\\\bibitem\\[\\([^]]+\\)\\]{\\([^}]+\\)}" .
" \\1\n ")
("Biblio.Html" . "biblio.html")
("\\\\ldots" . "...")
("\\\\^a" . "â")
("\\\\^o" . "ô")
("\\\\\"o" . "ö")
("\\\\subsection{\\([^}]+\\)}" . "\\1
")
("\\\\subsubsection{\\([^}]+\\)}" . "\\1
")
("\\\\begin{equation}" . "")
("\\\\end{equation}" . "") ))
(defun latex-2-html-in-place ()
(interactive)
"Hack latex to html in place."
(apply-replace-regexp-alist latex-2-html-patterns))
(defun latex-2-html-region (a b buffer)
"Roughly htmlize LaTeX text between A and B, and put into BUFFER.
Insertion is at point in that buffer."
(interactive "r
bInsert html into buffer: ")
(let ((latex-text (buffer-substring a b)))
(save-window-excursion
(set-buffer (get-buffer-create " *LaTeX to HTML conversion*"))
(erase-buffer)
(insert latex-text)
(latex-2-html-in-place)
(append-to-buffer buffer (point-min) (point-max)))))
;;; end of html-from-latex.el