def test_formatting(): # standard line h = HtmlElement() assert _get_text(h) == 'firstEhre sei Gott!last' h.display = Display.block h.margin_before = 1 h.margin_after = 2 print(h) print(_get_text(h)) assert _get_text(h) == 'first\n\nEhre sei Gott!\n\n\nlast' # list bullet without padding_inline h.list_bullet = "* " assert _get_text(h) == 'first\n\n* Ehre sei Gott!\n\n\nlast' # add a padding_inline h.padding_inline = 3 assert _get_text(h) == 'first\n\n * Ehre sei Gott!\n\n\nlast' # and prefixes + suffixes h.prefix = '>>' h.suffix = '<<' assert _get_text(h)== 'first\n\n * >>Ehre sei Gott!<<\n\n\nlast'
def test_html_element_refinement(): new = HtmlElement('span', display=Display.inline, prefix=' ', suffix=' ', limit_whitespace_affixes=True) pre = HtmlElement('pre', display=Display.block, whitespace=WhiteSpace.pre) code = HtmlElement('code') # refinement with pre and whitespaces refined = pre.get_refined_html_element(copy(new)) assert refined.prefix == '' assert refined.suffix == '' # refinement with code and whitespaces refined = code.get_refined_html_element(copy(new)) assert refined.prefix == ' ' assert refined.suffix == ' ' # refinement with pre and non-whitespaces new.prefix = ' 1. ' new.suffix = '<' refined = pre.get_refined_html_element(copy(new)) assert refined.prefix == ' 1. ' assert refined.suffix == '<' # refinement with code and non-whitespaces refined = code.get_refined_html_element(copy(new)) assert refined.prefix == ' 1. ' assert refined.suffix == '<'