本文整理匯總了Python中sgml.HTMLParser.HTMLParser.unknown_entityref方法的典型用法代碼示例。如果您正苦於以下問題:Python HTMLParser.unknown_entityref方法的具體用法?Python HTMLParser.unknown_entityref怎麽用?Python HTMLParser.unknown_entityref使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類sgml.HTMLParser.HTMLParser
的用法示例。
在下文中一共展示了HTMLParser.unknown_entityref方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: unknown_entityref
# 需要導入模塊: from sgml.HTMLParser import HTMLParser [as 別名]
# 或者: from sgml.HTMLParser.HTMLParser import unknown_entityref [as 別名]
def unknown_entityref(self, entname, terminator):
if self.suppress_output:
return
img = self.load_dingbat(entname)
if img:
if type(img) is TupleType:
s, tag = img
if tag:
if tag != "_ding":
tag = (self.formatter.writer.fonttag or '') + tag
self.viewer.configure_fonttag(tag)
self.formatter.push_style(tag)
self.viewer.text.tag_raise(tag)
self.handle_data(s)
self.formatter.pop_style()
else:
self.handle_data(s)
else:
bgcolor = self.viewer.text['background']
label = Label(self.viewer.text, image=img,
background=bgcolor, borderwidth=0)
self.add_subwindow(label)
# this needs to be done *after* the add_subwindow()
# call to get the right <Button-3> bindings.
if self.anchor:
IconicEntityLinker(self.viewer, self.anchor,
self.target, label)
else:
# Could not load dingbat, allow parent class to handle:
HTMLParser.unknown_entityref(self, entname, terminator)
示例2: unknown_entityref
# 需要導入模塊: from sgml.HTMLParser import HTMLParser [as 別名]
# 或者: from sgml.HTMLParser.HTMLParser import unknown_entityref [as 別名]
def unknown_entityref(self, entname, terminator):
dingbat = self.load_dingbat(entname)
if type(dingbat) is types.TupleType:
apply(self.formatter.writer.ps.push_font_string, dingbat)
self.formatter.assert_line_data()
elif dingbat:
dingbat.restrict(0.9 * self.formatter.writer.ps.get_fontsize(),
self.formatter.writer.ps.get_pagewidth())
self.formatter.writer.send_eps_data(dingbat, 'absmiddle')
self.formatter.assert_line_data()
else:
HTMLParser.unknown_entityref(self, entname, terminator)