⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 tohtml.py

📁 ft235 freetype 2.3. 5 freetype 2.3.5
💻 PY
📖 第 1 页 / 共 2 页
字号:
#  ToHTML (c) 2002, 2003, 2005, 2006, 2007#    David Turner <david@freetype.org>from sources import *from content import *from formatter import *import time# The following defines the HTML header used by all generated pages.#html_header_1 = """\<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN""http://www.w3.org/TR/html4/loose.dtd"><html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"><title>"""html_header_2= """ API Reference</title><style type="text/css">  body { font-family: Verdana, Geneva, Arial, Helvetica, serif;         color: #000000;         background: #FFFFFF; }  p { text-align: justify; }  h1 { text-align: center; }  li { text-align: justify; }  td { padding: 0 0.5em 0 0.5em }  a:link { color: #0000EF; }  a:visited { color: #51188E; }  a:hover { color: #FF0000; }  span.keyword { font-family: monospace;                 text-align: left;                 white-space: pre;                 color: darkblue; }  pre.colored { color: blue; }  ul.empty { list-style-type: none; }</style></head><body><center><h1>"""html_header_3=""" API Reference</h1></center>"""# The HTML footer used by all generated pages.#html_footer = """\</body></html>"""# The header and footer used for each section.#section_title_header = "<center><h1>"section_title_footer = "</h1></center>"# The header and footer used for code segments.#code_header = '<pre class="colored">'code_footer = '</pre>'# Paragraph header and footer.#para_header = "<p>"para_footer = "</p>"# Block header and footer.#block_header        = '<table align=center width="75%"><tr><td>'block_footer_start  = """\</td></tr></table><hr width="75%"><table align=center width="75%"><tr><td><font size=-2>[<a href=""""block_footer_middle = """\">Index</a>]</font></td><td width="100%"></td><td><font size=-2>[<a href=""""block_footer_end    = """\">TOC</a>]</font></td></tr></table>"""# Description header/footer.#description_header = '<table align=center width="87%"><tr><td>'description_footer = "</td></tr></table><br>"# Marker header/inter/footer combination.#marker_header = '<table align=center width="87%" cellpadding=5><tr bgcolor="#EEEEFF"><td><em><b>'marker_inter  = "</b></em></td></tr><tr><td>"marker_footer = "</td></tr></table>"# Source code extracts header/footer.#source_header = '<table align=center width="87%"><tr bgcolor="#D6E8FF"><td><pre>\n'source_footer = "\n</pre></table><br>"# Chapter header/inter/footer.#chapter_header = '<br><table align=center width="75%"><tr><td><h2>'chapter_inter  = '</h2><ul class="empty"><li>'chapter_footer = '</li></ul></td></tr></table>'# Index footer.index_footer_start = """\<hr><table><tr><td width="100%"></td><td><font size=-2>[<a href=""""index_footer_end = """\">TOC</a>]</font></td></tr></table>"""# source language keyword coloration/styling#keyword_prefix = '<span class="keyword">'keyword_suffix = '</span>'section_synopsis_header = '<h2>Synopsis</h2>'section_synopsis_footer = ''# Translate a single line of source to HTML.  This will convert# a "<" into "&lt.", ">" into "&gt.", etc.#def html_quote( line ):    result = string.replace( line,   "&", "&amp;" )    result = string.replace( result, "<", "&lt;" )    result = string.replace( result, ">", "&gt;" )    return result# same as 'html_quote', but ignores left and right brackets#def html_quote0( line ):    return string.replace( line, "&", "&amp;" )def dump_html_code( lines, prefix = "" ):    # clean the last empty lines    #    l = len( self.lines )    while l > 0 and string.strip( self.lines[l - 1] ) == "":        l = l - 1    # The code footer should be directly appended to the last code    # line to avoid an additional blank line.    #    print prefix + code_header,    for line in self.lines[0 : l+1]:        print '\n' + prefix + html_quote(line),    print prefix + code_footer,class HtmlFormatter(Formatter):    def __init__( self, processor, project_title, file_prefix ):        Formatter.__init__( self, processor )        global html_header_1, html_header_2, html_header_3, html_footer        if file_prefix:            file_prefix = file_prefix + "-"        else:            file_prefix = ""        self.project_title = project_title        self.file_prefix   = file_prefix        self.html_header   = html_header_1 + project_title + html_header_2 + \                             project_title + html_header_3        self.html_footer = "<center><font size=""-2"">generated on " +      \                            time.asctime( time.localtime( time.time() ) ) + \                           "</font></center>" + html_footer        self.columns = 3    def  make_section_url( self, section ):        return self.file_prefix + section.name + ".html"    def  make_block_url( self, block ):        return self.make_section_url( block.section ) + "#" + block.name    def  make_html_words( self, words ):        """ convert a series of simple words into some HTML text """        line = ""        if words:            line = html_quote( words[0] )            for w in words[1:]:                line = line + " " + html_quote( w )        return line    def  make_html_word( self, word ):        """analyze a simple word to detect cross-references and styling"""        # look for cross-references        #        m = re_crossref.match( word )        if m:            try:                name = m.group(1)                rest = m.group(2)                block = self.identifiers[name]                url   = self.make_block_url( block )                return '<a href="' + url + '">' + name + '</a>' + rest            except:                # we detected a cross-reference to an unknown item                sys.stderr.write( \                   "WARNING: undefined cross reference '" + name + "'.\n" )                return '?' + name + '?' + rest        # look for italics and bolds        m = re_italic.match( word )        if m:            name = m.group(1)            rest = m.group(3)            return '<i>' + name + '</i>' + rest        m = re_bold.match( word )        if m:            name = m.group(1)            rest = m.group(3)            return '<b>' + name + '</b>' + rest        return html_quote(word)    def  make_html_para( self, words ):        """ convert a paragraph's words into tagged HTML text, handle xrefs """        line = ""        if words:            line = self.make_html_word( words[0] )            for word in words[1:]:                line = line + " " + self.make_html_word( word )            # convert `...' quotations into real left and right single quotes            line = re.sub( r"(^|\W)`(.*?)'(\W|$)",                           r'\1&lsquo;\2&rsquo;\3',                           line )        return para_header + line + para_footer    def  make_html_code( self, lines ):        """ convert a code sequence to HTML """        line = code_header + '\n'        for l in lines:            line = line + html_quote( l ) + '\n'        return line + code_footer    def  make_html_items( self, items ):        """ convert a field's content into some valid HTML """        lines = []        for item in items:            if item.lines:

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -