示例#1
0
 def test_get_link_list(self):
     link1 = odf_create_link('http://example.com/', name='link1')
     link2 = odf_create_link('http://example.com/', name='link2')
     paragraph = self.paragraph
     paragraph.append(link1)
     paragraph.append(link2)
     element = self.body.get_links()[1]
     expected = ('<text:a xlink:href="http://example.com/" '
                 'office:name="link2"/>')
     self.assertEqual(element.serialize(), expected)
示例#2
0
 def test_get_link_list(self):
     link1 = odf_create_link('http://example.com/', name='link1')
     link2 = odf_create_link('http://example.com/', name='link2')
     paragraph = self.paragraph
     paragraph.append(link1)
     paragraph.append(link2)
     element = self.body.get_links()[1]
     expected = ('<text:a xlink:href="http://example.com/" '
                 'office:name="link2"/>')
     self.assertEqual(element.serialize(), expected)
示例#3
0
 def test_get_link_list_not_found(self):
     link1 = odf_create_link('http://example.com/', name='link1',
                             title='title1')
     link2 = odf_create_link('http://example.com/', name='link2',
                             title='title2')
     paragraph = self.paragraph
     paragraph.append(link1)
     paragraph.append(link2)
     # Not found
     element = self.body.get_links(name='link1', title='title2')
     self.assertEqual(element, [])
示例#4
0
 def test_get_link_list_href(self):
     link1 = odf_create_link('http://example.com/', name='link1',
                             title='title1')
     link2 = odf_create_link('http://example.com/', name='link2',
                             title='title2')
     paragraph = self.paragraph
     paragraph.append(link1)
     paragraph.append(link2)
     # url
     elements = self.body.get_links(url=ur'\.com')
     self.assertEqual(len(elements), 2)
示例#5
0
 def test_get_link_list_not_found(self):
     link1 = odf_create_link('http://example.com/',
                             name='link1',
                             title='title1')
     link2 = odf_create_link('http://example.com/',
                             name='link2',
                             title='title2')
     paragraph = self.paragraph
     paragraph.append(link1)
     paragraph.append(link2)
     # Not found
     element = self.body.get_links(name='link1', title='title2')
     self.assertEqual(element, [])
示例#6
0
 def test_get_link_list_name_and_title(self):
     link1 = odf_create_link('http://example.com/', name='link1',
                             title='title1')
     link2 = odf_create_link('http://example.com/', name='link2',
                             title='title2')
     paragraph = self.paragraph
     paragraph.append(link1)
     paragraph.append(link2)
     # name and title
     element = self.body.get_links(name='link1', title='title1')[0]
     expected = ('<text:a xlink:href="http://example.com/" '
                 'office:name="link1" office:title="title1"/>')
     self.assertEqual(element.serialize(), expected)
示例#7
0
 def test_get_link_list_href(self):
     link1 = odf_create_link('http://example.com/',
                             name='link1',
                             title='title1')
     link2 = odf_create_link('http://example.com/',
                             name='link2',
                             title='title2')
     paragraph = self.paragraph
     paragraph.append(link1)
     paragraph.append(link2)
     # url
     elements = self.body.get_links(url=r'\.com')
     self.assertEqual(len(elements), 2)
示例#8
0
 def test_get_link_list_name_and_title(self):
     link1 = odf_create_link('http://example.com/',
                             name='link1',
                             title='title1')
     link2 = odf_create_link('http://example.com/',
                             name='link2',
                             title='title2')
     paragraph = self.paragraph
     paragraph.append(link1)
     paragraph.append(link2)
     # name and title
     element = self.body.get_links(name='link1', title='title1')[0]
     expected = ('<text:a xlink:href="http://example.com/" '
                 'office:name="link1" office:title="title1"/>')
     self.assertEqual(element.serialize(), expected)
示例#9
0
def convert_reference(node, context):
    refuri = node.get("refuri")
    text = node.astext()

    link = odf_create_link(refuri)
    link.set_text(text)
    context["top"].append_element(link)
示例#10
0
 def test_create_link2(self):
     link = odf_create_link('http://example.com/', name=u'link2',
                            target_frame='_blank', style='style1',
                            visited_style='style2')
     expected = ('<text:a xlink:href="http://example.com/" '
                   'office:name="link2" office:target-frame-name="_blank" '
                   'xlink:show="new" text:style-name="style1" '
                   'text:visited-style-name="style2"/>')
     self.assertEqual(link.serialize(), expected)
示例#11
0
 def test_create_link2(self):
     link = odf_create_link('http://example.com/',
                            name='link2',
                            target_frame='_blank',
                            style='style1',
                            visited_style='style2')
     expected = ('<text:a xlink:href="http://example.com/" '
                 'office:name="link2" office:target-frame-name="_blank" '
                 'xlink:show="new" text:style-name="style1" '
                 'text:visited-style-name="style2"/>')
     self.assertEqual(link.serialize(), expected)
示例#12
0
 def link(self, link, title, content):
     lnk = odf_create_link(link,
                           text=content.get()[0].get_text(),
                           title=unicode(title))
     return ODFPartialTree.from_metrics_provider([lnk], self)
示例#13
0
 def autolink(self, link, is_email=False):
     text = link
     if is_email:
         link = 'mailto:%s' % link
     lnk = odf_create_link(link, text=unicode(text))
     return ODFPartialTree.from_metrics_provider([lnk], self)
示例#14
0
 def link(self, link, title, content):
     lnk = odf_create_link(link,
                           text=content.get()[0].get_text(),
                           title=unicode(title))
     return ODFPartialTree.from_metrics_provider([lnk], self)
示例#15
0
 def autolink(self, link, is_email=False):
     text = link
     if is_email:
         link = 'mailto:%s' % link
     lnk = odf_create_link(link, text=unicode(text))
     return ODFPartialTree.from_metrics_provider([lnk], self)
示例#16
0
 def test_create_link1(self):
     link = odf_create_link('http://example.com/')
     expected = '<text:a xlink:href="http://example.com/"/>'
     self.assertEqual(link.serialize(), expected)
示例#17
0
 def test_create_link1(self):
     link = odf_create_link('http://example.com/')
     expected = '<text:a xlink:href="http://example.com/"/>'
     self.assertEqual(link.serialize(), expected)