summaryrefslogtreecommitdiffstats
path: root/debian
diff options
context:
space:
mode:
authornima <nima@abc39116-655e-4be6-ad55-d661dc543056>2008-12-21 07:57:49 +0000
committernima <nima@abc39116-655e-4be6-ad55-d661dc543056>2008-12-21 07:57:49 +0000
commit8b39733bc2b67ba2b229cbe119d553a9247c77a2 (patch)
treec72054d29bc106d196604528dc7aa61e504c3379 /debian
parent0ff1b5b45facd7543529dab5711cf2812c47c218 (diff)
Cleanup.
git-svn-id: svn://svn.autonomy.net.au/python-dmidecode@156 abc39116-655e-4be6-ad55-d661dc543056
Diffstat (limited to 'debian')
0 files changed, 0 insertions, 0 deletions
/a> 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210
#
# htmlbuffer.py - A quick hacked up HTML parser that creates a GtkTextBuffer
#                 that resembles rendered HTML.
#
# Matt Wilson <msw@redhat.com>
#
# Copyright 2001-2002 Red Hat, Inc.
#
# This software may be freely redistributed under the terms of the GNU
# library public license.
#
# You should have received a copy of the GNU Library Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#

import HTMLParser
import sys
import gtk
import pango
import string
import re

class HTMLBuffer(HTMLParser.HTMLParser):
    ignoreTags = ('title',)
    noTagTags = ('html', 'head', 'span')
    newlineTags = ('p', 'h1', 'h2')
    entityRefMap = { 'copy': unichr(0xA9),
                     'lt': '<',
                     'gt': '>',
                     'quot': '"',
                     'nbsp': ' '}
    whiteSpaceNuker = re.compile(r"""\s+""", re.MULTILINE) 
    def __init__(self):
        self.buffer = gtk.TextBuffer(None)
        self.ignoreData = 0
        self.inList = 0
        self.pInListCounter = 0
        self.startOfP = 0
        self.lastTag = None
        self.lastDataEmpty = 0
        self.onBlankLine = 0
        HTMLParser.HTMLParser.__init__(self)
        if gtk.gdk.screen_width() >= 800:
            baseSize = 12
        else:
            baseSize = 10

        baseFont = 'sans'

        tag = self.buffer.create_tag('body')
        tag.set_property('font', '%s %d' % (baseFont, baseSize))
            
        tag = self.buffer.create_tag('tt')
        tag.set_property('font', 'Monospace %d' % (baseSize,))

        tag = self.buffer.create_tag('keycap')
        tag.set_property('font', 'Monospace %d' % (baseSize,))

        tag = self.buffer.create_tag('a')
        tag.set_property('font', '%s %d' % (baseFont, baseSize))

        tag = self.buffer.create_tag('h1')
        tag.set_property('font', '%s %d' % (baseFont, baseSize + 10))
        tag.set_property('weight', pango.WEIGHT_BOLD)        

        tag = self.buffer.create_tag('h2')
        tag.set_property('font', '%s %d' % (baseFont, baseSize + 4))
        tag.set_property('weight', pango.WEIGHT_BOLD)

        tag = self.buffer.create_tag('h3')
        tag.set_property('font', '%s %d' % (baseFont, baseSize + 3))
        tag.set_property('weight', pango.WEIGHT_BOLD)

        tag = self.buffer.create_tag('b')
        tag.set_property('weight', pango.WEIGHT_BOLD)

        tag = self.buffer.create_tag('i')
        tag.set_property('style', pango.STYLE_ITALIC)

        tag = self.buffer.create_tag('em')
        tag.set_property('style', pango.STYLE_ITALIC)

        tag = self.buffer.create_tag('ul')
        tag.set_property('left-margin', 20)

        self.buffer.create_tag('p')