HELLO·Android
系统源代码
IT资讯
技术文章
我的收藏
注册
登录
-
我收藏的文章
创建代码块
我的代码块
我的账号
Pie
|
9.0.0_r8
下载
查看原文件
收藏
根目录
external
python
cpython3
Tools
scripts
texi2html.py
#! /usr/bin/env python3 # Convert GNU texinfo files into HTML, one file per node. # Based on Texinfo 2.14. # Usage: texi2html [-d] [-d] [-c] inputfile outputdirectory # The input file must be a complete texinfo file, e.g. emacs.texi. # This creates many files (one per info node) in the output directory, # overwriting existing files of the same name. All files created have # ".html" as their extension. # XXX To do: # - handle @comment*** correctly # - handle @xref {some words} correctly # - handle @ftable correctly (items aren't indexed?) # - handle @itemx properly # - handle @exdent properly # - add links directly to the proper line from indices # - check against the definitive list of @-cmds; we still miss (among others): # - @defindex (hard) # - @c(omment) in the middle of a line (rarely used) # - @this* (not really needed, only used in headers anyway) # - @today{} (ever used outside title page?) # More consistent handling of chapters/sections/etc. # Lots of documentation # Many more options: # -top designate top node # -links customize which types of links are included # -split split at chapters or sections instead of nodes # -name Allow different types of filename handling. Non unix systems # will have problems with long node names # ... # Support the most recent texinfo version and take a good look at HTML 3.0 # More debugging output (customizable) and more flexible error handling # How about icons ? # rpyron 2002-05-07 # Robert Pyron
# 1. BUGFIX: In function makefile(), strip blanks from the nodename. # This is necessary to match the behavior of parser.makeref() and # parser.do_node(). # 2. BUGFIX fixed KeyError in end_ifset (well, I may have just made # it go away, rather than fix it) # 3. BUGFIX allow @menu and menu items inside @ifset or @ifclear # 4. Support added for: # @uref URL reference # @image image file reference (see note below) # @multitable output an HTML table # @vtable # 5. Partial support for accents, to match MAKEINFO output # 6. I added a new command-line option, '-H basename', to specify # HTML Help output. This will cause three files to be created # in the current directory: # `basename`.hhp HTML Help Workshop project file # `basename`.hhc Contents file for the project # `basename`.hhk Index file for the project # When fed into HTML Help Workshop, the resulting file will be # named `basename`.chm. # 7. A new class, HTMLHelp, to accomplish item 6. # 8. Various calls to HTMLHelp functions. # A NOTE ON IMAGES: Just as 'outputdirectory' must exist before # running this program, all referenced images must already exist # in outputdirectory. import os import sys import string import re MAGIC = '\\input texinfo' cmprog = re.compile('^@([a-z]+)([ \t]|$)') # Command (line-oriented) blprog = re.compile('^[ \t]*$') # Blank line kwprog = re.compile('@[a-z]+') # Keyword (embedded, usually # with {} args) spprog = re.compile('[\n@{}&<>]') # Special characters in # running text # # menu item (Yuck!) miprog = re.compile(r'^\* ([^:]*):(:|[ \t]*([^\t,\n.]+)([^ \t\n]*))[ \t\n]*') # 0 1 1 2 3 34 42 0 # ----- ---------- --------- # -|----------------------------- # ----------------------------------------------------- class HTMLNode: """Some of the parser's functionality is separated into this class. A Node accumulates its contents, takes care of links to other Nodes and saves itself when it is finished and all links are resolved. """ DOCTYPE = '' type = 0 cont = '' epilogue = '