def bullets_of_multiple_depth_are_converted_to_nested_lists(): document = openxml.document([ _paragraph_of_text("Food", style="Bullet1"), _paragraph_of_text("Apples", style="Bullet2"), _paragraph_of_text("Bananas", style="Bullet2"), _paragraph_of_text("Drinks", style="Bullet1"), ]) expected_html = html.fragment([ html.element("ul", [ html.element("li", [ html.text("Food"), html.element("ul", [ html.element("li", [html.text("Apples")]), html.element("li", [html.text("Bananas")]) ]) ]), html.element("li", [html.text("Drinks")]) ]) ]) generator = HtmlGenerator(paragraph_styles=[ styles.map_word_style("Bullet1").to(styles.unordered_list(depth=1)), styles.map_word_style("Bullet2").to(styles.unordered_list(depth=2)) ]) assert_equal(expected_html, generator.html_for_document(document))
def _create_paragraph_styles(): return [ styles.map_word_style("Heading1").to(styles.top_level_element("h1")), styles.map_word_style("Heading2").to(styles.top_level_element("h2")), styles.map_word_style("Heading3").to(styles.top_level_element("h3")), styles.map_word_style("Heading4").to(styles.top_level_element("h4")), styles.map_word_style("ListParagraph", numbering_level=0).to(styles.unordered_list(depth=1)), styles.map_word_style("ListParagraph", numbering_level=1).to(styles.unordered_list(depth=2)), styles.map_word_style("ListParagraph", numbering_level=2).to(styles.unordered_list(depth=3)), styles.map_word_style("ListParagraph", numbering_level=3).to(styles.unordered_list(depth=4)), ]
def consecutive_word_bullet_paragraphs_are_converted_to_single_html_list(): document = openxml.document([ _paragraph_of_text("Apples", style="Bullet1"), _paragraph_of_text("Bananas", style="Bullet1") ]) expected_html = html.fragment([ html.element("ul", [ html.element("li", [html.text("Apples")]), html.element("li", [html.text("Bananas")]) ]) ]) generator = HtmlGenerator(paragraph_styles=[ styles.map_word_style("Bullet1").to(styles.unordered_list()) ]) assert_equal(expected_html, generator.html_for_document(document))