Lines Matching refs:markup
105 # First, the classes that represent markup elements.
842 """Encapsulates a number of ways of matching a markup element (tag or
867 markup = None
869 markup = markupName
870 markupAttrs = markup
876 or (markup and self._matches(markup, self.name)) \
877 or (not markup and self._matches(markupName, self.name)):
896 if markup:
897 found = markup
902 def search(self, markup):
903 #print 'looking for %s in %s' % (self, markup)
907 if isList(markup) and not isinstance(markup, Tag):
908 for element in markup:
915 elif isinstance(markup, Tag):
917 found = self.searchTag(markup)
919 elif isinstance(markup, NavigableString) or \
920 isString(markup):
921 if self._matches(markup, self.text):
922 found = markup
925 % markup.__class__
928 def _matches(self, markup, matchAgainst):
929 #print "Matching %s against %s" % (markup, matchAgainst)
932 result = markup != None
934 result = matchAgainst(markup)
938 if isinstance(markup, Tag):
939 markup = markup.name
940 if markup is not None and not isString(markup):
941 markup = unicode(markup)
945 result = markup and matchAgainst.search(markup)
947 and (markup is not None or not isString(matchAgainst))):
948 result = markup in matchAgainst
950 result = markup.has_key(matchAgainst)
951 elif matchAgainst and isString(markup):
952 if isinstance(markup, unicode):
958 result = matchAgainst == markup
1134 This class is useful for parsing XML or made-up markup languages,
1164 def __init__(self, markup="", parseOnlyThese=None, fromEncoding=None,
1169 provided markup (which can be a string or a file-like object)
1225 if hasattr(markup, 'read'): # It's a file-type object.
1226 markup = markup.read()
1227 self.markup = markup
1233 self.markup = None # The markup can now be GCed.
1238 markup = self.markup
1239 if isinstance(markup, unicode):
1244 (markup, [self.fromEncoding, inDocumentEncoding],
1246 markup = dammit.unicode
1249 if markup:
1254 markup = fix.sub(m, markup)
1263 self.builder.feed(markup)
1642 pathologically bad markup. It makes no assumptions about tag
1747 def __init__(self, markup, overrideEncodings=[],
1750 self.markup, documentEncoding, sniffedEncoding = \
1751 self._detectEncoding(markup, isHTML)
1754 if markup == '' or isinstance(markup, unicode):
1756 self.unicode = unicode(markup)
1769 if not u and chardet and not isinstance(self.markup, unicode):
1770 u = self._convertFrom(chardet.detect(self.markup)['encoding'])
1800 markup = self.markup
1809 markup = smart_quotes_compiled.sub(self._subMSChar, markup)
1813 u = self._toUnicode(markup, proposed)
1814 self.markup = u
1821 return self.markup