예제 #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
파일: odpdown.py 프로젝트: rombert/odpdown
 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
파일: odpdown.py 프로젝트: rombert/odpdown
 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)