예제 #1
0
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)
예제 #2
0
 def hyperlink_is_read_if_it_has_an_anchor_attribute(self):
     run_element = xml_element("w:r")
     element = xml_element("w:hyperlink", {"w:anchor": "start"}, [run_element])
     assert_equal(
         documents.hyperlink(anchor="start", children=[documents.run([])]),
         _read_and_get_document_xml_element(element)
     )
예제 #3
0
 def hyperlink_is_read_as_internal_hyperlink_if_it_has_an_anchor_attribute(self):
     run_element = xml_element("w:r")
     element = xml_element("w:hyperlink", {"w:anchor": "start"}, [run_element])
     assert_equal(
         documents.hyperlink(anchor="start", children=[documents.run([])]),
         _read_and_get_document_xml_element(element)
     )
예제 #4
0
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)
예제 #5
0
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)
예제 #6
0
 def hyperlink_is_read_if_it_has_a_relationship_id(self):
     relationships = Relationships({"r42": Relationship(target="http://example.com")})
     run_element = xml_element("w:r")
     element = xml_element("w:hyperlink", {"r:id": "r42"}, [run_element])
     assert_equal(
         documents.hyperlink(href="http://example.com", children=[documents.run([])]),
         _read_and_get_document_xml_element(element, relationships=relationships),
     )
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 hyperlink_is_read_if_it_has_a_relationship_id(self):
     relationships = Relationships(
         {"r42": Relationship(target="http://example.com")})
     run_element = xml_element("w:r")
     element = xml_element("w:hyperlink", {"r:id": "r42"}, [run_element])
     assert_equal(
         documents.hyperlink("http://example.com", [documents.run([])]),
         _read_and_get_document_xml_element(element,
                                            relationships=relationships))
예제 #9
0
 def existing_fragment_is_replaced_when_anchor_is_set_on_external_link(self):
     relationships = Relationships([
         _hyperlink_relationship("r42", "http://example.com/#previous"),
     ])
     run_element = xml_element("w:r")
     element = xml_element("w:hyperlink", {"r:id": "r42", "w:anchor": "fragment"}, [run_element])
     assert_equal(
         documents.hyperlink(href="http://example.com/#fragment", children=[documents.run([])]),
         _read_and_get_document_xml_element(element, relationships=relationships)
     )
예제 #10
0
 def hyperlink_is_read_as_external_hyperlink_if_it_has_a_relationship_id_and_an_anchor(self):
     relationships = Relationships([
         _hyperlink_relationship("r42", "http://example.com/"),
     ])
     run_element = xml_element("w:r")
     element = xml_element("w:hyperlink", {"r:id": "r42", "w:anchor": "fragment"}, [run_element])
     assert_equal(
         documents.hyperlink(href="http://example.com/#fragment", children=[documents.run([])]),
         _read_and_get_document_xml_element(element, relationships=relationships)
     )
예제 #11
0
 def existing_fragment_is_replaced_when_anchor_is_set_on_external_link(self):
     relationships = Relationships([
         _hyperlink_relationship("r42", "http://example.com/#previous"),
     ])
     run_element = xml_element("w:r")
     element = xml_element("w:hyperlink", {"r:id": "r42", "w:anchor": "fragment"}, [run_element])
     assert_equal(
         documents.hyperlink(href="http://example.com/#fragment", children=[documents.run([])]),
         _read_and_get_document_xml_element(element, relationships=relationships)
     )
예제 #12
0
 def hyperlink_is_read_as_external_hyperlink_if_it_has_a_relationship_id_and_an_anchor(self):
     relationships = Relationships([
         _hyperlink_relationship("r42", "http://example.com/"),
     ])
     run_element = xml_element("w:r")
     element = xml_element("w:hyperlink", {"r:id": "r42", "w:anchor": "fragment"}, [run_element])
     assert_equal(
         documents.hyperlink(href="http://example.com/#fragment", children=[documents.run([])]),
         _read_and_get_document_xml_element(element, relationships=relationships)
     )
예제 #13
0
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)
예제 #14
0
def docx_hyperlink_with_href_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)
예제 #15
0
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)