def css(state, text, i, formats): ' Inside a <style> tag ' pat = cdata_close_pats['style'] m = pat.search(text, i) if m is None: css_text = text[i:] else: css_text = text[i:m.start()] ans = [] css_state = CSSState(state.css) for j, num, fmt in run_loop(css_state, css_state_map, state.css_formats, css_text): ans.append((num, fmt)) state.css = css_state.value if m is not None: state.clear() state.parse = State.IN_CLOSING_TAG ans.extend([(2, formats['end_tag']), (len(m.group()) - 2, formats['tag_name'])]) return ans
def css(state, text, i, formats, user_data): ' Inside a <style> tag ' pat = cdata_close_pats['style'] m = pat.search(text, i) if m is None: css_text = text[i:] else: css_text = text[i:m.start()] ans = [] css_user_data = user_data.css_user_data = user_data.css_user_data or CSSUserData() state.sub_parser_state = css_user_data.state = state.sub_parser_state or CSSState() for j, num, fmt in run_loop(css_user_data, css_state_map, formats['css_sub_formats'], css_text): ans.append((num, fmt)) if m is not None: state.sub_parser_state = None state.parse = IN_CLOSING_TAG add_tag_data(user_data, TagStart(m.start(), '', 'style', True, True)) ans.extend([(2, formats['end_tag']), (len(m.group()) - 2, formats['tag_name'])]) return ans
def css(state, text, i, formats, user_data): ' Inside a <style> tag ' pat = cdata_close_pats['style'] m = pat.search(text, i) if m is None: css_text = text[i:] else: css_text = text[i:m.start()] ans = [] css_user_data = user_data.css_user_data = user_data.css_user_data or CSSUserData( ) state.sub_parser_state = css_user_data.state = state.sub_parser_state or CSSState( ) for j, num, fmt in run_loop(css_user_data, css_state_map, formats['css_sub_formats'], css_text): ans.append((num, fmt)) if m is not None: state.sub_parser_state = None state.parse = IN_CLOSING_TAG add_tag_data(user_data, TagStart(m.start(), '', 'style', True, True)) ans.extend([(2, formats['end_tag']), (len(m.group()) - 2, formats['tag_name'])]) return ans