def _analyze_html_tag(t): text = t.text selfClosing = False if text.startswith(u"</"): name = text[2:-1] isEndToken = True elif text.endswith("/>"): name = text[1:-2] selfClosing = True isEndToken = False # ??? else: name = text[1:-1] isEndToken = False name, values = _split_tag(name) t.vlist = parseParams(values) name = name.lower() if name == 'br': isEndToken = False t.rawtagname = name t.tag_selfClosing = selfClosing t.tag_isEndToken = isEndToken if isEndToken: t.type = t.t_html_tag_end
def _analyze_html_tag(t): text = t.text selfClosing = False if text.startswith(u"</"): name = text[2:-1] isEndToken = True elif text.endswith("/>"): name = text[1:-2] selfClosing = True isEndToken = False # ??? else: name = text[1:-1] isEndToken = False name, values = _split_tag(name) t.vlist = parseParams(values) name = name.lower() if name=='br': isEndToken = False t.rawtagname = name t.tag_selfClosing = selfClosing t.tag_isEndToken = isEndToken if isEndToken: t.type = t.t_html_tag_end
def find_modifier(self, row): children = row.children for i, x in enumerate(children): if x.type in (T.t_newline, T.t_break): mod = T.join_as_text(children[:i]) #print "MODIFIER:", repr(mod) row.vlist = util.parseParams(mod) del children[:i] return
def find_modifier(self, cell): children = cell.children if not children: return for i, x in enumerate(children): t = children[i] if t.type == T.t_2box_open: break if t.type == T.t_special and t.text == "|": mod = T.join_as_text(children[:i]) cell.vlist = util.parseParams(mod) del children[:i + 1] return
def __init__(self, tokens, xopts): self.tagextensions = tagext.default_registry uniquifier = xopts.uniquifier if uniquifier is None: return i = 0 while i < len(tokens): t = tokens[i] if t.type != T.t_uniq: i += 1 continue text = t.text try: match = uniquifier.uniq2repl[text] except KeyError: t.type == T.t_text i += 1 continue vlist = match["vlist"] if vlist: vlist = util.parseParams(vlist) else: vlist = None inner = match["inner"] name = match["tagname"] try: m = getattr(self, "create_" + str(name)) except AttributeError: m = self._create_generic tokens[i] = m(name, vlist, inner or u"", xopts) if tokens[i] is None: del tokens[i] else: i += 1
def find_caption(self, table): children = table.children start = None i = 0 while i < len(children): t = children[i] if t.type == T.t_tablecaption: start = i i += 1 break if t.text is None or t.text.strip(): return i += 1 modifier = None while i < len(children): t = children[i] if t.tagname not in ("ref", ) and (t.text is None or t.text.startswith("\n")): if modifier: mod = T.join_as_text(children[start:modifier]) vlist = util.parseParams(mod) sub = children[modifier + 1:i] else: sub = children[start + 1:i] vlist = {} caption = T(type=T.t_complex_caption, children=sub, vlist=vlist) children[start:i] = [caption] return elif t.text == "|" and modifier is None: modifier = i elif t.type == T.t_2box_open and modifier is None: modifier = 0 i += 1
def find_caption(self, table): children = table.children start = None i = 0 while i < len(children): t = children[i] if t.type == T.t_tablecaption: start = i i += 1 break if t.text is None or t.text.strip(): return i += 1 modifier = None while i < len(children): t = children[i] if t.tagname not in ("ref",) and (t.text is None or t.text.startswith("\n")): if modifier: mod = T.join_as_text(children[start:modifier]) vlist = util.parseParams(mod) sub = children[modifier + 1:i] else: sub = children[start + 1:i] vlist = {} caption = T(type=T.t_complex_caption, children=sub, vlist=vlist) children[start:i] = [caption] return elif t.text == "|" and modifier is None: modifier = i elif t.type == T.t_2box_open and modifier is None: modifier = 0 i += 1
def compute_mod(): mod = T.join_as_text(children[:i]) #print "MODIFIER:", repr(mod) table.vlist = util.parseParams(mod) del children[:i]
def test_display_none(): r = parseParams("class=geo style=display:none") assert r == {'class': 'geo', 'style': {'display': 'none'}}
def test_bgcolor_hashmark_no_doublequote(): """http://code.pediapress.com/wiki/ticket/654""" r = parseParams("bgcolor=#ffffff") assert r == dict(bgcolor="#ffffff")
def check(s, expected): res= util.parseParams(s) print repr(s), "-->", res, "expected:", expected assert res==expected, "bad result"
def check(s, expected): res = util.parseParams(s) print repr(s), "-->", res, "expected:", expected assert res == expected, "bad result"