;;; py2texi.el -- Conversion of Python LaTeX documentation to Texinfo ;; Copyright (C) 2006 Jeroen Dekkers <jeroen@dekkers.cx>;; Copyright (C) 1998, 1999, 2001, 2002 Milan Zamazal ;; Author: Milan Zamazal <pdm@zamazal.org>;; Version: $Id: py2texi.el 52974 2006-12-09 12:13:02Z matthias.klose $;; Keywords: python ;; COPYRIGHT NOTICE;;;; 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, 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 can find the GNU General Public License at;; http://www.gnu.org/copyleft/gpl.html;; or you can write to the Free Software Foundation, Inc., 59 Temple Place,;; Suite 330, Boston, MA 02111-1307, USA. ;;; Commentary: ;; This is a Q&D hack for conversion of Python manuals to on-line help format.;; I desperately needed usable online documenta for Python, so I wrote this.;; The result code is ugly and need not contain complete information from;; Python manuals. I apologize for my ignorance, especially ignorance to;; python.sty. Improvements of this convertor are welcomed. ;; How to use it:;; Load this file and apply `M-x py2texi'. You will be asked for name of a;; file to be converted. ;; Where to find it:;; New versions of this code might be found at;; http://www.zamazal.org/software/python/py2texi/ . ;;; Code: (require 'texinfo)(eval-when-compile (require 'cl)) (defvar py2texi-python-version "2.2" "What to substitute for the \\version macro.") (defvar py2texi-python-short-version (progn (string-match "[0-9]+\\.[0-9]+" py2texi-python-version) (match-string 0 py2texi-python-version)) "Short version number, usually set by the LaTeX commands.") (defvar py2texi-texi-file-name nil "If non-nil, that string is used as the name of the Texinfo file.Otherwise a generated Texinfo file name is used.") (defvar py2texi-info-file-name nil "If non-nil, that string is used as the name of the Info file.Otherwise a generated Info file name is used.") (defvar py2texi-stop-on-problems nil "*If non-nil, stop when you encouter soft problem.") (defconst py2texi-environments '(("abstract" 0 "@quotation" "@end quotation\n") ("center" 0 "" "") ("cfuncdesc" 3 (progn (setq findex t) "\n@table @code\n@item \\1 \\2(\\3)\n@findex \\2\n") "@end table\n") ("cmemberdesc" 3 "\n@table @code\n@item \\2 \\3\n" "@end table\n") ("classdesc" 2 (progn (setq obindex t) "\n@table @code\n@item \\1(\\2)\n@obindex \\1\n") "@end table\n") ("classdesc*" 1 (progn (setq obindex t) "\n@table @code\n@item \\1\n@obindex \\1\n") "@end table\n") ("comment" 0 "\n@ignore\n" "\n@end ignore\n") ("csimplemacrodesc" 1 (progn (setq cindex t) "\n@table @code\n@item \\1\n@cindex \\1\n") "@end table\n") ("ctypedesc" 1 (progn (setq cindex t) "\n@table @code\n@item \\1\n@cindex \\1\n") "@end table\n") ("cvardesc" 2 (progn (setq findex t) "\n@table @code\n@item \\1 \\2\n@findex \\2\n") "@end table\n") ("datadesc" 1 (progn (setq findex t) "\n@table @code\n@item \\1\n@findex \\1\n") "@end table\n") ("datadescni" 1 "\n@table @code\n@item \\1\n" "@end table\n") ("definitions" 0 "@table @dfn" "@end table\n") ("description" 0 "@table @samp" "@end table\n") ("displaymath" 0 "" "") ("document" 0 (concat "@defcodeindex mo\n" "@defcodeindex ob\n" "@titlepage\n" (format "@title " title "\n") (format "@author " author "\n") "@page\n" author-address "@end titlepage\n" "@node Top, , , (dir)\n") (concat "@indices\n" "@contents\n" "@bye\n")) ("enumerate" 0 "@enumerate" "@end enumerate") ("envdesc" 2 (concat "\n@table @code" "\n@item @backslash{}begin@{\\1@}\\2") "@end table\n") ("excdesc" 1 (progn (setq obindex t) "\n@table @code\n@item \\1\n@obindex \\1\n") "@end table\n") ("excclassdesc" 2 (progn (setq obindex t) "\n@table @code\n@item \\1(\\2)\n@obindex \\1\n") "@end table\n") ("flushleft" 0 "" "") ("fulllineitems" 0 "\n@table @code\n" "@end table\n") ("funcdesc" 2 (progn (setq findex t) "\n@table @code\n@item \\1(\\2)\n@findex \\1\n") "@end table\n") ("funcdescni" 2 "\n@table @code\n@item \\1(\\2)\n" "@end table\n") ("itemize" 0 "@itemize @bullet" "@end itemize\n") ("list" 2 "\n@table @code\n" "@end table\n") ("longtableii" 4 (concat "@multitable @columnfractions .5 .5\n" "@item \\3 @tab \\4\n" "@item ------- @tab ------ \n") "@end multitable\n") ("longtableiii" 5 (concat "@multitable @columnfractions .33 .33 .33\n" "@item \\3 @tab \\4 @tab \\5\n" "@item ------- @tab ------ @tab ------\n") "@end multitable\n") ("macrodesc" 2 (concat "\n@table @code" "\n@item \\1@{\\2@}") "@end table\n") ("memberdesc" 1 (progn (setq findex t) "\n@table @code\n@item \\1\n@findex \\1\n") "@end table\n") ("memberdescni" 1 "\n@table @code\n@item \\1\n" "@end table\n") ("methoddesc" 2 (progn (setq findex t) "\n@table @code\n@item \\1(\\2)\n@findex \\1\n") "@end table\n") ("methoddescni" 2 "\n@table @code\n@item \\1(\\2)\n" "@end table\n") ("notice" 0 "@emph{Notice:} " "") ("opcodedesc" 2 (progn (setq findex t) "\n@table @code\n@item \\1 \\2\n@findex \\1\n") "@end table\n") ("productionlist" 0 "\n@table @code\n" "@end table\n") ("quotation" 0 "@quotation" "@end quotation") ("quote" 0 "@quotation" "@end quotation") ("seealso" 0 "See also:\n@table @emph\n" "@end table\n") ("seealso*" 0 "@table @emph\n" "@end table\n") ("sloppypar" 0 "" "") ("small" 0 "" "") ("tableii" 4 (concat "@multitable @columnfractions .5 .5\n" "@item \\3 @tab \\4\n" "@item ------- @tab ------ \n") "@end multitable\n") ("tableiii" 5 (concat "@multitable @columnfractions .33 .33 .33\n" "@item \\3 @tab \\4 @tab \\5\n" "@item ------- @tab ------ @tab ------\n") "@end multitable\n") ("tableiv" 6 (concat "@multitable @columnfractions .25 .25 .25 .25\n" "@item \\3 @tab \\4 @tab \\5 @tab \\6\n" "@item ------- @tab ------- @tab ------- @tab -------\n") "@end multitable\n") ("tablev" 7 (concat "@multitable @columnfractions .20 .20 .20 .20 .20\n" "@item \\3 @tab \\4 @tab \\5 @tab \\6 @tab \\7\n" "@item ------- @tab ------- @tab ------- @tab ------- @tab -------\n") "@end multitable\n") ("alltt" 0 "@example" "@end example") ) "Associative list defining substitutions for environments.Each list item is of the form (ENVIRONMENT ARGNUM BEGIN END) where:- ENVIRONMENT is LaTeX environment name- ARGNUM is number of (required) macro arguments- BEGIN is substitution for \begin{ENVIRONMENT}- END is substitution for \end{ENVIRONMENT}Both BEGIN and END are evaled. Moreover, you can reference arguments through\N regular expression notation in strings of BEGIN.") (defconst py2texi-commands '(("AA" 0 "@AA{}") ("aa" 0 "@aa{}") ("ABC" 0 "ABC") ("appendix" 0 (progn (setq appendix t) "")) ("ASCII" 0 "ASCII") ("author" 1 (progn (setq author (match-string 1 string)) "")) ("authoraddress" 1 (progn (setq author-address (match-string 1 string)) "")) ("b" 1 "@w{\\1}") ("backslash" 0 "@backslash{}") ("bf" 0 "@destroy") ("bifuncindex" 1 (progn (setq findex t) "@findex{\\1}")) ("C" 0 "C") ("c" 0 "@,") ("catcode" 0 "") ("cdata" 1 "@code{\\1}") ("centerline" 1 "@center \\1") ("cfuncline" 3 "@itemx \\1 \\2(\\3)\n@findex \\2") ("cfunction" 1 "@code{\\1}") ("chapter" 1 (format "@node \\1\n@%s \\1\n" (if appendix "appendix" "chapter"))) ("chapter*" 1 "@node \\1\n@unnumbered \\1\n") ("character" 1 "@samp{\\1}") ("citetitle" 1 "@ref{Top,,,\\1}") ("class" 1 "@code{\\1}") ("cmemberline" 3 "@itemx \\2 \\3\n") ("code" 1 "@code{\\1}") ("command" 1 "@command{\\1}") ("constant" 1 "@code{\\1}") ("copyright" 1 "@copyright{}") ("Cpp" 0 "C++") ("csimplemacro" 1 "@code{\\1}") ("ctype" 1 "@code{\\1}") ("dataline" 1 (progn (setq findex t) "@item \\1\n@findex \\1\n")) ("date" 1 "\\1") ("declaremodule" 2 (progn (setq cindex t) "@label{\\2}@cindex{\\2}")) ("deprecated" 2 "@emph{This is deprecated in Python \\1. \\2}\n\n") ("dfn" 1 "@dfn{\\1}") ("documentclass" 1 py2texi-magic) ("e" 0 "@backslash{}") ("else" 0 (concat "@end ifinfo\n@" (setq last-if "iftex"))) ("env" 1 "@code{\\1}") ("EOF" 0 "@code{EOF}") ("email" 1 "@email{\\1}") ("em" 1 "@emph{\\1}") ("emph" 1 "@emph{\\1}") ("envvar" 1 "@env{\\1}") ("exception" 1 "@code{\\1}") ("exindex" 1 (progn (setq obindex t) "@obindex{\\1}")) ("fi" 0 (if (equal last-if "ifx") "" (concat "@end " last-if))) ("file" 1 "@file{\\1}") ("filenq" 1 "@file{\\1}") ("filevar" 1 "@file{@var{\\1}}") ("footnote" 1 "@footnote{\\1}") ("frac" 0 "") ("funcline" 2 (progn (setq findex t) "@item \\1 \\2\n@findex \\1")) ("funclineni" 2 "@item \\1 \\2") ("function" 1 "@code{\\1}") ("grammartoken" 1 "@code{\\1}") ("guilabel" 1 "@strong{\\1}") ("hline" 0 "") ("ifx" 0 (progn (setq last-if "ifx") "")) ("ifhtml" 0 (concat "@" (setq last-if "ifinfo"))) ("iftexi" 0 (concat "@" (setq last-if "ifinfo"))) ("index" 1 (progn (setq cindex t) "@cindex{\\1}")) ("indexii" 2 (progn (setq cindex t) "@cindex{\\1 \\2}")) ("indexiii" 3 (progn (setq cindex t) "@cindex{\\1 \\2 \\3}")) ("indexiv" 3 (progn (setq cindex t) "@cindex{\\1 \\2 \\3 \\4}")) ("infinity" 0 "@emph{infinity}") ("it" 0 "@destroy") ("kbd" 1 "@key{\\1}") ("keyword" 1 "@code{\\1}") ("kwindex" 1 (progn (setq cindex t) "@cindex{\\1}")) ("label" 1 "@label{\\1}") ("Large" 0 "") ("LaTeX" 0 "La@TeX{}") ("large" 0 "") ("ldots" 0 "@dots{}") ("leftline" 1 "\\1") ("leq" 0 "<=") ("lineii" 2 "@item \\1 @tab \\2") ("lineiii" 3 "@item \\1 @tab \\2 @tab \\3") ("lineiv" 4 "@item \\1 @tab \\2 @tab \\3 @tab \\4") ("linev" 5 "@item \\1 @tab \\2 @tab \\3 @tab \\4 @tab \\5") ("locallinewidth" 0 "") ("localmoduletable" 0 "") ("longprogramopt" 1 "@option{--\\1}") ("macro" 1 "@code{@backslash{}\\1}") ("mailheader" 1 "@code{\\1}") ("makeindex" 0 "") ("makemodindex" 0 "") ("maketitle" 0 (concat "@top " title "\n")) ("makevar" 1 "@code{\\1}") ("manpage" 2 "@samp{\\1(\\2)}") ("mbox" 1 "@w{\\1}") ("member" 1 "@code{\\1}") ("memberline" 1 "@item \\1\n@findex \\1\n") ("menuselection" 1 "@samp{\\1}") ("method" 1 "@code{\\1}") ("methodline" 2 (progn (setq moindex t) "@item \\1(\\2)\n@moindex \\1\n")) ("methodlineni" 2 "@item \\1(\\2)\n") ("mimetype" 1 "@samp{\\1}") ("module" 1 "@samp{\\1}") ("moduleauthor" 2 "") ("modulesynopsis" 1 "\\1") ("moreargs" 0 "@dots{}") ("n" 0 "@backslash{}n") ("newcommand" 2 "") ("newlength" 1 "") ("newsgroup" 1 "@samp{\\1}") ("nodename" 1 (save-excursion (save-match-data (re-search-backward "^@node ")) (delete-region (point) (save-excursion (end-of-line) (point))) (insert "@node " (match-string 1 string)) "")) ("noindent" 0 "@noindent ") ("note" 1 "@emph{Note:} \\1") ("NULL" 0 "@code{NULL}") ("obindex" 1 (progn (setq obindex t) "@obindex{\\1}")) ("opindex" 1 (progn (setq cindex t) "@cindex{\\1}")) ("option" 1 "@option{\\1}") ("optional" 1 "[\\1]") ("paragraph" 1 "@subsubheading \\1") ("pep" 1 (progn (setq cindex t) "PEP@ \\1@cindex PEP \\1\n")) ("pi" 0 "pi") ("platform" 1 "") ("plusminus" 0 "+-") ("POSIX" 0 "POSIX") ("production" 2 "@item \\1 \\2") ("productioncont" 1 "@item @w{} \\1") ("program" 1 "@command{\\1}") ("programopt" 1 "@option{\\1}") ("protect" 0 "") ("pytype" 1 "@code{\\1}") ("ref" 1 "@ref{\\1}") ("refbimodindex" 1 (progn (setq moindex t) "@moindex{\\1}")) ("refmodindex" 1 (progn (setq moindex t) "@moindex{\\1}")) ("refmodule" 1 "@samp{\\1}") ("refstmodindex" 1 (progn (setq moindex t) "@moindex{\\1}")) ("regexp" 1 "\"\\1\"") ("release" 1 (progn (setq py2texi-python-version (match-string 1 string)) "")) ("renewcommand" 2 "") ("rfc" 1 (progn (setq cindex t) "RFC@ \\1@cindex RFC \\1\n")) ("rm" 0 "@destroy") ("samp" 1 "@samp{\\1}") ("section" 1 (let ((str (match-string 1 string))) (save-match-data (if (string-match "\\(.*\\)[ \t\n]*---[ \t\n]*\\(.*\\)" str) (format "@node %s\n@section %s\n" (py2texi-backslash-quote (match-string 1 str)) (py2texi-backslash-quote (match-string 2 str))) "@node \\1\n@section \\1\n")))) ("sectionauthor" 2 "") ("seelink" 3 "\n@table @url\n@item @strong{\\1}\n(\\2)\n\\3\n@end table\n") ("seemodule" 2 "@ref{\\1} \\2") ("seepep" 3 "\n@table @strong\n@item PEP\\1 \\2\n\\3\n@end table\n") ("seerfc" 3 "\n@table @strong\n@item RFC\\1 \\2\n\\3\n@end table\n") ("seetext" 1 "\\1") ("seetitle" 1 "@cite{\\1}") ("seeurl" 2 "\n@table @url\n@item \\1\n\\2\n@end table\n") ("setindexsubitem" 1 (progn (setq cindex t) "@cindex \\1")) ("setlength" 2 "") ("setreleaseinfo" 1 (progn (setq py2texi-releaseinfo ""))) ("setshortversion" 1 (progn (setq py2texi-python-short-version (match-string 1 string)) "")) ("shortversion" 0 py2texi-python-short-version) ("sqrt" 0 "") ("stindex" 1 (progn (setq cindex t) "@cindex{\\1}")) ("stmodindex" 1 (progn (setq moindex t) "@moindex{\\1}")) ("strong" 1 "@strong{\\1}") ("sub" 0 "/") ("subsection" 1 "@node \\1\n@subsection \\1\n") ("subsubsection" 1 "@node \\1\n@subsubsection \\1\n") ("sum" 0 "") ("tableofcontents" 0 "") ("term" 1 "@item \\1") ("TeX" 0 "@TeX{}") ("textasciitilde" 0 "~") ("textasciicircum" 0 "^") ("textbackslash" 0 "@backslash{}") ("textbar" 0 "|") ("textbf" 1 "@strong{\\1}") ("texteuro" 0 "@euro{}") ; Unfortunately, this alternate spelling doesn't actually apply to ; the usage found in Python Tutorial, which actually requires a ; Euro symbol to make sense, so this is commented out as well. ; ("texteuro" 0 "Euro ") ("textgreater" 0 ">") ("textit" 1 "@i{\\1}") ("textless" 0 "<") ("textrm" 1 "\\1") ("texttt" 1 "@code{\\1}") ("textunderscore" 0 "_") ("tilde" 0 "~") ("title" 1 (progn (setq title (match-string 1 string)) "@settitle \\1")) ("today" 0 "@today{}") ("token" 1 "@code{\\1}") ("tt" 0 "@destroy") ("ttindex" 1 (progn (setq cindex t) "@cindex{\\1}")) ("u" 0 "@backslash{}u") ("ulink" 2 "\\1") ("UNIX" 0 "UNIX") ("undefined" 0 "") ("unspecified" 0 "@dots{}") ("url" 1 "@url{\\1}") ("usepackage" 1 "") ("var" 1 "@var{\\1}") ("verbatiminput" 1 "@code{\\1}") ("version" 0 py2texi-python-version) ("versionadded" 1 "@emph{Added in Python version \\1}") ("versionchanged" 1 "@emph{Changed in Python version \\1}") ("vskip" 1 "") ("vspace" 1 "") ("warning" 1 "@emph{\\1}") ("withsubitem" 2 "\\2") ("XXX" 1 "@strong{\\1}")) "Associative list of command substitutions.Each list item is of the form (COMMAND ARGNUM SUBSTITUTION) where:- COMMAND is LaTeX command name- ARGNUM is number of (required) command arguments- SUBSTITUTION substitution for the command. It is evaled and you can reference command arguments through the \\N regexp notation in strings.") (defvar py2texi-magic "@documentclass\n" "\"Magic\" string for auxiliary insertion at the beginning of document.") (defvar py2texi-dirs '("./" "../texinputs/") "Where to search LaTeX input files.") (defvar py2texi-buffer "*py2texi*" "The name of a buffer where Texinfo is generated.") (defconst py2texi-xemacs (string-match "^XEmacs" (emacs-version)) "Running under XEmacs?") (defmacro py2texi-search (regexp &rest body) `(progn (goto-char (point-min)) (while (re-search-forward ,regexp nil t) ,@body))) (defmacro py2texi-search-safe (regexp &rest body) `(py2texi-search ,regexp (unless (py2texi-protected) ,@body))) (defun py2texi-message (message) "Report message and stop if `py2texi-stop-on-problems' is non-nil." (if py2texi-stop-on-problems (error message) (message message))) (defun py2texi-backslash-quote (string) "Double backslahes in STRING." (let ((i 0)) (save-match-data (while (setq i (string-match "\\\\" string i)) (setq string (replace-match "\\\\\\\\" t nil string)) (setq i (+ i 2)))) string)) (defun py2texi (file) "Convert Python LaTeX documentation FILE to Texinfo." (interactive "fFile to convert: ") (switch-to-buffer (get-buffer-create py2texi-buffer)) (erase-buffer) (insert-file file) (let ((case-fold-search nil) (title "") (author "") (author-address "") (appendix nil) (findex nil) (obindex nil) (cindex nil) (moindex nil) last-if) (py2texi-process-verbatims) (py2texi-process-comments) (py2texi-process-includes) (py2texi-process-funnyas) (py2texi-process-environments) (py2texi-process-commands) (py2texi-fix-indentation) (py2texi-fix-nodes)Lines 1–500 of 970. Load more
;;; py2texi.el -- Conversion of Python LaTeX documentation to Texinfo ;; Copyright (C) 2006 Jeroen Dekkers <jeroen@dekkers.cx> ;; Copyright (C) 1998, 1999, 2001, 2002 Milan Zamazal ;; Author: Milan Zamazal <pdm@zamazal.org> ;; Version: $Id: py2texi.el 52974 2006-12-09 12:13:02Z matthias.klose $ ;; Keywords: python ;; COPYRIGHT NOTICE ;; ;; 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, 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 can find the GNU General Public License at ;; http://www.gnu.org/copyleft/gpl.html ;; or you can write to the Free Software Foundation, Inc., 59 Temple Place, ;; Suite 330, Boston, MA 02111-1307, USA. ;;; Commentary: ;; This is a Q&D hack for conversion of Python manuals to on-line help format. ;; I desperately needed usable online documenta for Python, so I wrote this. ;; The result code is ugly and need not contain complete information from ;; Python manuals. I apologize for my ignorance, especially ignorance to ;; python.sty. Improvements of this convertor are welcomed. ;; How to use it: ;; Load this file and apply `M-x py2texi'. You will be asked for name of a ;; file to be converted. ;; Where to find it: ;; New versions of this code might be found at ;; http://www.zamazal.org/software/python/py2texi/ . ;;; Code: (require 'texinfo) (eval-when-compile (require 'cl)) (defvar py2texi-python-version "2.2" "What to substitute for the \\version macro.") (defvar py2texi-python-short-version (progn (string-match "[0-9]+\\.[0-9]+" py2texi-python-version) (match-string 0 py2texi-python-version)) "Short version number, usually set by the LaTeX commands.") (defvar py2texi-texi-file-name nil "If non-nil, that string is used as the name of the Texinfo file. Otherwise a generated Texinfo file name is used.") (defvar py2texi-info-file-name nil "If non-nil, that string is used as the name of the Info file. Otherwise a generated Info file name is used.") (defvar py2texi-stop-on-problems nil "*If non-nil, stop when you encouter soft problem.") (defconst py2texi-environments '(("abstract" 0 "@quotation" "@end quotation\n") ("center" 0 "" "") ("cfuncdesc" 3 (progn (setq findex t) "\n@table @code\n@item \\1 \\2(\\3)\n@findex \\2\n") "@end table\n") ("cmemberdesc" 3 "\n@table @code\n@item \\2 \\3\n" "@end table\n") ("classdesc" 2 (progn (setq obindex t) "\n@table @code\n@item \\1(\\2)\n@obindex \\1\n") "@end table\n") ("classdesc*" 1 (progn (setq obindex t) "\n@table @code\n@item \\1\n@obindex \\1\n") "@end table\n") ("comment" 0 "\n@ignore\n" "\n@end ignore\n") ("csimplemacrodesc" 1 (progn (setq cindex t) "\n@table @code\n@item \\1\n@cindex \\1\n") "@end table\n") ("ctypedesc" 1 (progn (setq cindex t) "\n@table @code\n@item \\1\n@cindex \\1\n") "@end table\n") ("cvardesc" 2 (progn (setq findex t) "\n@table @code\n@item \\1 \\2\n@findex \\2\n") "@end table\n") ("datadesc" 1 (progn (setq findex t) "\n@table @code\n@item \\1\n@findex \\1\n") "@end table\n") ("datadescni" 1 "\n@table @code\n@item \\1\n" "@end table\n") ("definitions" 0 "@table @dfn" "@end table\n") ("description" 0 "@table @samp" "@end table\n") ("displaymath" 0 "" "") ("document" 0 (concat "@defcodeindex mo\n" "@defcodeindex ob\n" "@titlepage\n" (format "@title " title "\n") (format "@author " author "\n") "@page\n" author-address "@end titlepage\n" "@node Top, , , (dir)\n") (concat "@indices\n" "@contents\n" "@bye\n")) ("enumerate" 0 "@enumerate" "@end enumerate") ("envdesc" 2 (concat "\n@table @code" "\n@item @backslash{}begin@{\\1@}\\2") "@end table\n") ("excdesc" 1 (progn (setq obindex t) "\n@table @code\n@item \\1\n@obindex \\1\n") "@end table\n") ("excclassdesc" 2 (progn (setq obindex t) "\n@table @code\n@item \\1(\\2)\n@obindex \\1\n") "@end table\n") ("flushleft" 0 "" "") ("fulllineitems" 0 "\n@table @code\n" "@end table\n") ("funcdesc" 2 (progn (setq findex t) "\n@table @code\n@item \\1(\\2)\n@findex \\1\n") "@end table\n") ("funcdescni" 2 "\n@table @code\n@item \\1(\\2)\n" "@end table\n") ("itemize" 0 "@itemize @bullet" "@end itemize\n") ("list" 2 "\n@table @code\n" "@end table\n") ("longtableii" 4 (concat "@multitable @columnfractions .5 .5\n" "@item \\3 @tab \\4\n" "@item ------- @tab ------ \n") "@end multitable\n") ("longtableiii" 5 (concat "@multitable @columnfractions .33 .33 .33\n" "@item \\3 @tab \\4 @tab \\5\n" "@item ------- @tab ------ @tab ------\n") "@end multitable\n") ("macrodesc" 2 (concat "\n@table @code" "\n@item \\1@{\\2@}") "@end table\n") ("memberdesc" 1 (progn (setq findex t) "\n@table @code\n@item \\1\n@findex \\1\n") "@end table\n") ("memberdescni" 1 "\n@table @code\n@item \\1\n" "@end table\n") ("methoddesc" 2 (progn (setq findex t) "\n@table @code\n@item \\1(\\2)\n@findex \\1\n") "@end table\n") ("methoddescni" 2 "\n@table @code\n@item \\1(\\2)\n" "@end table\n") ("notice" 0 "@emph{Notice:} " "") ("opcodedesc" 2 (progn (setq findex t) "\n@table @code\n@item \\1 \\2\n@findex \\1\n") "@end table\n") ("productionlist" 0 "\n@table @code\n" "@end table\n") ("quotation" 0 "@quotation" "@end quotation") ("quote" 0 "@quotation" "@end quotation") ("seealso" 0 "See also:\n@table @emph\n" "@end table\n") ("seealso*" 0 "@table @emph\n" "@end table\n") ("sloppypar" 0 "" "") ("small" 0 "" "") ("tableii" 4 (concat "@multitable @columnfractions .5 .5\n" "@item \\3 @tab \\4\n" "@item ------- @tab ------ \n") "@end multitable\n") ("tableiii" 5 (concat "@multitable @columnfractions .33 .33 .33\n" "@item \\3 @tab \\4 @tab \\5\n" "@item ------- @tab ------ @tab ------\n") "@end multitable\n") ("tableiv" 6 (concat "@multitable @columnfractions .25 .25 .25 .25\n" "@item \\3 @tab \\4 @tab \\5 @tab \\6\n" "@item ------- @tab ------- @tab ------- @tab -------\n") "@end multitable\n") ("tablev" 7 (concat "@multitable @columnfractions .20 .20 .20 .20 .20\n" "@item \\3 @tab \\4 @tab \\5 @tab \\6 @tab \\7\n" "@item ------- @tab ------- @tab ------- @tab ------- @tab -------\n") "@end multitable\n") ("alltt" 0 "@example" "@end example") ) "Associative list defining substitutions for environments. Each list item is of the form (ENVIRONMENT ARGNUM BEGIN END) where: - ENVIRONMENT is LaTeX environment name - ARGNUM is number of (required) macro arguments - BEGIN is substitution for \begin{ENVIRONMENT} - END is substitution for \end{ENVIRONMENT} Both BEGIN and END are evaled. Moreover, you can reference arguments through \N regular expression notation in strings of BEGIN.") (defconst py2texi-commands '(("AA" 0 "@AA{}") ("aa" 0 "@aa{}") ("ABC" 0 "ABC") ("appendix" 0 (progn (setq appendix t) "")) ("ASCII" 0 "ASCII") ("author" 1 (progn (setq author (match-string 1 string)) "")) ("authoraddress" 1 (progn (setq author-address (match-string 1 string)) "")) ("b" 1 "@w{\\1}") ("backslash" 0 "@backslash{}") ("bf" 0 "@destroy") ("bifuncindex" 1 (progn (setq findex t) "@findex{\\1}")) ("C" 0 "C") ("c" 0 "@,") ("catcode" 0 "") ("cdata" 1 "@code{\\1}") ("centerline" 1 "@center \\1") ("cfuncline" 3 "@itemx \\1 \\2(\\3)\n@findex \\2") ("cfunction" 1 "@code{\\1}") ("chapter" 1 (format "@node \\1\n@%s \\1\n" (if appendix "appendix" "chapter"))) ("chapter*" 1 "@node \\1\n@unnumbered \\1\n") ("character" 1 "@samp{\\1}") ("citetitle" 1 "@ref{Top,,,\\1}") ("class" 1 "@code{\\1}") ("cmemberline" 3 "@itemx \\2 \\3\n") ("code" 1 "@code{\\1}") ("command" 1 "@command{\\1}") ("constant" 1 "@code{\\1}") ("copyright" 1 "@copyright{}") ("Cpp" 0 "C++") ("csimplemacro" 1 "@code{\\1}") ("ctype" 1 "@code{\\1}") ("dataline" 1 (progn (setq findex t) "@item \\1\n@findex \\1\n")) ("date" 1 "\\1") ("declaremodule" 2 (progn (setq cindex t) "@label{\\2}@cindex{\\2}")) ("deprecated" 2 "@emph{This is deprecated in Python \\1. \\2}\n\n") ("dfn" 1 "@dfn{\\1}") ("documentclass" 1 py2texi-magic) ("e" 0 "@backslash{}") ("else" 0 (concat "@end ifinfo\n@" (setq last-if "iftex"))) ("env" 1 "@code{\\1}") ("EOF" 0 "@code{EOF}") ("email" 1 "@email{\\1}") ("em" 1 "@emph{\\1}") ("emph" 1 "@emph{\\1}") ("envvar" 1 "@env{\\1}") ("exception" 1 "@code{\\1}") ("exindex" 1 (progn (setq obindex t) "@obindex{\\1}")) ("fi" 0 (if (equal last-if "ifx") "" (concat "@end " last-if))) ("file" 1 "@file{\\1}") ("filenq" 1 "@file{\\1}") ("filevar" 1 "@file{@var{\\1}}") ("footnote" 1 "@footnote{\\1}") ("frac" 0 "") ("funcline" 2 (progn (setq findex t) "@item \\1 \\2\n@findex \\1")) ("funclineni" 2 "@item \\1 \\2") ("function" 1 "@code{\\1}") ("grammartoken" 1 "@code{\\1}") ("guilabel" 1 "@strong{\\1}") ("hline" 0 "") ("ifx" 0 (progn (setq last-if "ifx") "")) ("ifhtml" 0 (concat "@" (setq last-if "ifinfo"))) ("iftexi" 0 (concat "@" (setq last-if "ifinfo"))) ("index" 1 (progn (setq cindex t) "@cindex{\\1}")) ("indexii" 2 (progn (setq cindex t) "@cindex{\\1 \\2}")) ("indexiii" 3 (progn (setq cindex t) "@cindex{\\1 \\2 \\3}")) ("indexiv" 3 (progn (setq cindex t) "@cindex{\\1 \\2 \\3 \\4}")) ("infinity" 0 "@emph{infinity}") ("it" 0 "@destroy") ("kbd" 1 "@key{\\1}") ("keyword" 1 "@code{\\1}") ("kwindex" 1 (progn (setq cindex t) "@cindex{\\1}")) ("label" 1 "@label{\\1}") ("Large" 0 "") ("LaTeX" 0 "La@TeX{}") ("large" 0 "") ("ldots" 0 "@dots{}") ("leftline" 1 "\\1") ("leq" 0 "<=") ("lineii" 2 "@item \\1 @tab \\2") ("lineiii" 3 "@item \\1 @tab \\2 @tab \\3") ("lineiv" 4 "@item \\1 @tab \\2 @tab \\3 @tab \\4") ("linev" 5 "@item \\1 @tab \\2 @tab \\3 @tab \\4 @tab \\5") ("locallinewidth" 0 "") ("localmoduletable" 0 "") ("longprogramopt" 1 "@option{--\\1}") ("macro" 1 "@code{@backslash{}\\1}") ("mailheader" 1 "@code{\\1}") ("makeindex" 0 "") ("makemodindex" 0 "") ("maketitle" 0 (concat "@top " title "\n")) ("makevar" 1 "@code{\\1}") ("manpage" 2 "@samp{\\1(\\2)}") ("mbox" 1 "@w{\\1}") ("member" 1 "@code{\\1}") ("memberline" 1 "@item \\1\n@findex \\1\n") ("menuselection" 1 "@samp{\\1}") ("method" 1 "@code{\\1}") ("methodline" 2 (progn (setq moindex t) "@item \\1(\\2)\n@moindex \\1\n")) ("methodlineni" 2 "@item \\1(\\2)\n") ("mimetype" 1 "@samp{\\1}") ("module" 1 "@samp{\\1}") ("moduleauthor" 2 "") ("modulesynopsis" 1 "\\1") ("moreargs" 0 "@dots{}") ("n" 0 "@backslash{}n") ("newcommand" 2 "") ("newlength" 1 "") ("newsgroup" 1 "@samp{\\1}") ("nodename" 1 (save-excursion (save-match-data (re-search-backward "^@node ")) (delete-region (point) (save-excursion (end-of-line) (point))) (insert "@node " (match-string 1 string)) "")) ("noindent" 0 "@noindent ") ("note" 1 "@emph{Note:} \\1") ("NULL" 0 "@code{NULL}") ("obindex" 1 (progn (setq obindex t) "@obindex{\\1}")) ("opindex" 1 (progn (setq cindex t) "@cindex{\\1}")) ("option" 1 "@option{\\1}") ("optional" 1 "[\\1]") ("paragraph" 1 "@subsubheading \\1") ("pep" 1 (progn (setq cindex t) "PEP@ \\1@cindex PEP \\1\n")) ("pi" 0 "pi") ("platform" 1 "") ("plusminus" 0 "+-") ("POSIX" 0 "POSIX") ("production" 2 "@item \\1 \\2") ("productioncont" 1 "@item @w{} \\1") ("program" 1 "@command{\\1}") ("programopt" 1 "@option{\\1}") ("protect" 0 "") ("pytype" 1 "@code{\\1}") ("ref" 1 "@ref{\\1}") ("refbimodindex" 1 (progn (setq moindex t) "@moindex{\\1}")) ("refmodindex" 1 (progn (setq moindex t) "@moindex{\\1}")) ("refmodule" 1 "@samp{\\1}") ("refstmodindex" 1 (progn (setq moindex t) "@moindex{\\1}")) ("regexp" 1 "\"\\1\"") ("release" 1 (progn (setq py2texi-python-version (match-string 1 string)) "")) ("renewcommand" 2 "") ("rfc" 1 (progn (setq cindex t) "RFC@ \\1@cindex RFC \\1\n")) ("rm" 0 "@destroy") ("samp" 1 "@samp{\\1}") ("section" 1 (let ((str (match-string 1 string))) (save-match-data (if (string-match "\\(.*\\)[ \t\n]*---[ \t\n]*\\(.*\\)" str) (format "@node %s\n@section %s\n" (py2texi-backslash-quote (match-string 1 str)) (py2texi-backslash-quote (match-string 2 str))) "@node \\1\n@section \\1\n")))) ("sectionauthor" 2 "") ("seelink" 3 "\n@table @url\n@item @strong{\\1}\n(\\2)\n\\3\n@end table\n") ("seemodule" 2 "@ref{\\1} \\2") ("seepep" 3 "\n@table @strong\n@item PEP\\1 \\2\n\\3\n@end table\n") ("seerfc" 3 "\n@table @strong\n@item RFC\\1 \\2\n\\3\n@end table\n") ("seetext" 1 "\\1") ("seetitle" 1 "@cite{\\1}") ("seeurl" 2 "\n@table @url\n@item \\1\n\\2\n@end table\n") ("setindexsubitem" 1 (progn (setq cindex t) "@cindex \\1")) ("setlength" 2 "") ("setreleaseinfo" 1 (progn (setq py2texi-releaseinfo ""))) ("setshortversion" 1 (progn (setq py2texi-python-short-version (match-string 1 string)) "")) ("shortversion" 0 py2texi-python-short-version) ("sqrt" 0 "") ("stindex" 1 (progn (setq cindex t) "@cindex{\\1}")) ("stmodindex" 1 (progn (setq moindex t) "@moindex{\\1}")) ("strong" 1 "@strong{\\1}") ("sub" 0 "/") ("subsection" 1 "@node \\1\n@subsection \\1\n") ("subsubsection" 1 "@node \\1\n@subsubsection \\1\n") ("sum" 0 "") ("tableofcontents" 0 "") ("term" 1 "@item \\1") ("TeX" 0 "@TeX{}") ("textasciitilde" 0 "~") ("textasciicircum" 0 "^") ("textbackslash" 0 "@backslash{}") ("textbar" 0 "|") ("textbf" 1 "@strong{\\1}") ("texteuro" 0 "@euro{}") ; Unfortunately, this alternate spelling doesn't actually apply to ; the usage found in Python Tutorial, which actually requires a ; Euro symbol to make sense, so this is commented out as well. ; ("texteuro" 0 "Euro ") ("textgreater" 0 ">") ("textit" 1 "@i{\\1}") ("textless" 0 "<") ("textrm" 1 "\\1") ("texttt" 1 "@code{\\1}") ("textunderscore" 0 "_") ("tilde" 0 "~") ("title" 1 (progn (setq title (match-string 1 string)) "@settitle \\1")) ("today" 0 "@today{}") ("token" 1 "@code{\\1}") ("tt" 0 "@destroy") ("ttindex" 1 (progn (setq cindex t) "@cindex{\\1}")) ("u" 0 "@backslash{}u") ("ulink" 2 "\\1") ("UNIX" 0 "UNIX") ("undefined" 0 "") ("unspecified" 0 "@dots{}") ("url" 1 "@url{\\1}") ("usepackage" 1 "") ("var" 1 "@var{\\1}") ("verbatiminput" 1 "@code{\\1}") ("version" 0 py2texi-python-version) ("versionadded" 1 "@emph{Added in Python version \\1}") ("versionchanged" 1 "@emph{Changed in Python version \\1}") ("vskip" 1 "") ("vspace" 1 "") ("warning" 1 "@emph{\\1}") ("withsubitem" 2 "\\2") ("XXX" 1 "@strong{\\1}")) "Associative list of command substitutions. Each list item is of the form (COMMAND ARGNUM SUBSTITUTION) where: - COMMAND is LaTeX command name - ARGNUM is number of (required) command arguments - SUBSTITUTION substitution for the command. It is evaled and you can reference command arguments through the \\N regexp notation in strings.") (defvar py2texi-magic "@documentclass\n" "\"Magic\" string for auxiliary insertion at the beginning of document.") (defvar py2texi-dirs '("./" "../texinputs/") "Where to search LaTeX input files.") (defvar py2texi-buffer "*py2texi*" "The name of a buffer where Texinfo is generated.") (defconst py2texi-xemacs (string-match "^XEmacs" (emacs-version)) "Running under XEmacs?") (defmacro py2texi-search (regexp &rest body) `(progn (goto-char (point-min)) (while (re-search-forward ,regexp nil t) ,@body))) (defmacro py2texi-search-safe (regexp &rest body) `(py2texi-search ,regexp (unless (py2texi-protected) ,@body))) (defun py2texi-message (message) "Report message and stop if `py2texi-stop-on-problems' is non-nil." (if py2texi-stop-on-problems (error message) (message message))) (defun py2texi-backslash-quote (string) "Double backslahes in STRING." (let ((i 0)) (save-match-data (while (setq i (string-match "\\\\" string i)) (setq string (replace-match "\\\\\\\\" t nil string)) (setq i (+ i 2)))) string)) (defun py2texi (file) "Convert Python LaTeX documentation FILE to Texinfo." (interactive "fFile to convert: ") (switch-to-buffer (get-buffer-create py2texi-buffer)) (erase-buffer) (insert-file file) (let ((case-fold-search nil) (title "") (author "") (author-address "") (appendix nil) (findex nil) (obindex nil) (cindex nil) (moindex nil) last-if) (py2texi-process-verbatims) (py2texi-process-comments) (py2texi-process-includes) (py2texi-process-funnyas) (py2texi-process-environments) (py2texi-process-commands) (py2texi-fix-indentation) (py2texi-fix-nodes)