following, break # before the bullet if self.pInListCounter == 1: offset -= 2 # put a newline at the beginning start = self.buffer.get_iter_at_offset(offset) self.buffer.insert(start, '\n') offset += 1 current += 1 # put a newline at the end start = self.buffer.get_iter_at_offset(current) self.buffer.insert(start, '\n') current += 1 self.iter = self.buffer.get_iter_at_offset(current) start = self.buffer.get_iter_at_offset(offset) self.buffer.apply_tag_by_name(tag, start, self.iter) # all other markup def handle_data(self, data): if self.ignoreData == 0: data = data.replace('\n', ' ') data = self.whiteSpaceNuker.sub(' ', data) if self.startOfP: if data.startswith(' '): data = data[1:] self.startOfP = 0 # print '|%s|' % (data,) if data: self.buffer.insert(self.iter, data) self.onBlankLine = 0 else: self.lastDataEmpty = 1 def handle_charref(self, name): if self.ignoreData == 0: self.buffer.insert(self.iter, unichr(int(name))) def handle_entityref(self, name): if self.ignoreData != 0: return if name == 'copy': # (c) is unicode 00A9 self.buffer.insert(self.iter, unichr(0xA9)) if __name__ == '__main__': def quit(*args): gtk.main_quit() import sys f = open(sys.argv[1], 'r') buffer = HTMLBuffer() buffer.feed(f.read()) buffer.close() win = gtk.Window() view = gtk.TextView() view.set_buffer(buffer.get_buffer()) view.set_property("editable", gtk.FALSE) view.set_property("cursor_visible", gtk.FALSE) view.set_wrap_mode(gtk.WRAP_WORD) sw = gtk.ScrolledWindow() sw.add(view) win = gtk.Window() win.connect('destroy', quit) win.add(sw) win.show_all() win.set_size_request(300, 300) gtk.main()