def paragraphs_are_terminated_with_newlines(): element = documents.paragraph(children=[ documents.Text("Hello "), documents.Text("world."), ], ) result = extract_raw_text_from_element(element) assert_equal("Hello world.\n\n", result)
def docx_hyperlinks_can_be_collapsed(): result = convert_document_element_to_html( documents.document(children=[ documents.hyperlink(href="http://example.com", children=[documents.Text("Hello ")]), documents.hyperlink(href="http://example.com", children=[documents.Text("world")]), ])) assert_equal('<a href="http://example.com">Hello world</a>', result.value)
def docx_hyperlink_with_internal_anchor_reference_is_converted_to_anchor_tag(): result = convert_document_element_to_html( documents.hyperlink(anchor="start", children=[documents.Text("Hello")]), id_prefix="doc-42-", ) assert_equal('<a href="#doc-42-start">Hello</a>', result.value)
def can_read_text_within_document(self): element = _document_element_with_text("Hello!") assert_equal( documents.document([ documents.paragraph( [documents.run([documents.Text("Hello!")])]) ]), _read_and_get_document_xml_element(element))
def hyperlink_target_frame_is_used_as_anchor_target(): result = convert_document_element_to_html( documents.hyperlink( anchor="start", target_frame="_blank", children=[documents.Text("Hello")], ), ) assert_equal('<a href="#start" target="_blank">Hello</a>', result.value)
def runs_are_converted_by_satisfying_matching_paths(): result = convert_document_element_to_html( documents.run(style_id="TipsRun", children=[documents.Text("Tip")]), style_map=[ style_reader.read_style("r.TipsRun => span.tip") ] ) assert_equal('<span class="tip">Tip</span>', result.value)
def docx_hyperlink_is_converted_to_anchor_tag(): result = convert_document_element_to_html( documents.hyperlink(href="http://example.com", children=[documents.Text("Hello")]), ) assert_equal('<a href="http://example.com">Hello</a>', result.value)
def can_read_text_within_run(): element = _run_element_with_text("Hello!") assert_equal( documents.run([documents.Text("Hello!")]), _read_and_get_document_xml_element(element) )
def text_from_text_element_is_read(): element = _text_element("Hello!") assert_equal(documents.Text("Hello!"), _read_and_get_document_xml_element(element))
def unrecognised_children_are_ignored(): element = xml_element("w:r", {}, [_text_element("Hello!"), xml_element("w:huh", {}, [])]) assert_equal( documents.run([documents.Text("Hello!")]), _read_document_xml_element(element).value )
def raw_text_of_text_element_is_value(): assert_equal("Hello", extract_raw_text_from_element(documents.Text("Hello")))
def raw_text_of_paragraph_is_terminated_with_newlines(): paragraph = documents.paragraph(children=[documents.Text("Hello")]) assert_equal("Hello\n\n", extract_raw_text_from_element(paragraph))
def text_element_is_converted_to_text_content(): element = documents.Text("Hello.") result = extract_raw_text_from_element(element) assert_equal("Hello.", result)