def error_002_invalid_tags(text):
"""Fix the error and return (new_text, replacements_count) tuple."""
(text, fixed_br) = fix_unpair_tag(text, "br", count_selfclosing=False)
(text, fixed_hr) = fix_unpair_tag(text, "hr", count_selfclosing=False)
fixed_total = fixed_br + fixed_hr
(text, fixed_clear) = re.subn(r"<br clear=\"?(left|right)\"?\s*/?>", "{{clear|\\1}}", text)
(text, fixed_clear_all) = re.subn(r"<br clear=\"?(?:all|both)\"?\s*/?>", "{{clear}}", text)
fixed_total += fixed_clear + fixed_clear_all
(text, fixed_small) = fix_pair_tag(text, "small")
(text, fixed_center) = fix_pair_tag(text, "center")
(text, fixed_div) = fix_pair_tag(text, "div", recursive=True)
(text, fixed_span) = fix_pair_tag(text, "span", recursive=True)
fixed_total += fixed_small + fixed_center + fixed_div + fixed_span
return (text, fixed_total)
评论列表
文章目录