示例#1
0
    def test_html(self):
        text = '''* header1
paraparapara
** header2-1
[[image]]
para*para*2[[http://example.com][hyperlink]]
** header2-2
| a | b |
| 1 | 2 |

*** header3-1
#+BEGIN_QUOTE
quoted
=quoted_decorated=
#+END_QUOTE

*** header3-2
#+BEGIN_SRC python
python code
=hoge=
#+END_SRC'''
        o = Org(text)
        eq_(
            o.html(),
            '<h1>header1</h1><p>paraparapara</p><h2>header2-1</h2><p><img src="image">para<span style="font-weight: bold;">para</span>2<a href="http://example.com">hyperlink</a></p><h2>header2-2</h2><table><tr><td>a</td><td>b</td></tr><tr><td>1</td><td>2</td></tr></table><h3>header3-1</h3><blockquote>quoted<code>quoted_decorated</code></blockquote><h3>header3-2</h3><pre><code class="python">python code=hoge=</code></pre>'
        )
示例#2
0
 def test_link_and_image(self):
     text = '''hoge[[http://example.com]]fuga[[picture]]piyo'''
     o = Org(text)
     eq_(str(o), 'Org(Paragraph(Text))')
     eq_(o.children[0].children[0].get_text(), 'hogeLinkfugaImagepiyo')
     text = '''hoge[[picture]]fuga[[http://example.com]]piyo'''
     o = Org(text)
     eq_(str(o), 'Org(Paragraph(Text))')
     eq_(o.children[0].children[0].get_text(), 'hogeImagefugaLinkpiyo')
示例#3
0
 def test_link(self):
     text = '''[[http://example.com]]'''
     o = Org(text)
     eq_(str(o), 'Org(Paragraph(Text))')
     eq_(o.children[0].children[0].get_text(), 'Link')
     text = '''[[http://example.com][example]]'''
     o = Org(text)
     eq_(str(o), 'Org(Paragraph(Text))')
     eq_(o.children[0].children[0].get_text(), 'Link')
     text = '''hoge[[http://example.com]]fuga'''
     o = Org(text)
     eq_(str(o), 'Org(Paragraph(Text))')
     eq_(o.children[0].children[0].get_text(), 'hogeLinkfuga')
示例#4
0
 def test_inlinecode(self):
     text = '=inline text='
     o = Org(text)
     eq_(o.html(), '<p><code>inline text</code></p>')
     text = '=/inline italic text/='
     o = Org(text)
     eq_(o.html(), '<p><code>/inline italic text/</code></p>')
     text = '=<tag>='
     o = Org(text)
     eq_(o.html(), '<p><code>&lt;tag&gt;</code></p>')
示例#5
0
    def test_unorderedlist(self):
        text = '''- listitem1
- listitem2
+ listitem3
+ listitem4'''
        o = Org(text)
        eq_(str(o), 'Org(UnOrderedList(ListItem ListItem ListItem ListItem))')
示例#6
0
    def test_orderedlist(self):
        text = '''1. listitem1
2. listitem2
3) listitem3
4) listitem4'''
        o = Org(text)
        eq_(str(o), 'Org(OrderedList(ListItem ListItem ListItem ListItem))')
示例#7
0
    def test_blockquote(self):
        text = '''#+BEGIN_QUOTE: http://exapmle.com
quoted line1
quoted line2
#+END_QUOTE'''
        o = Org(text)
        eq_(str(o), 'Org(Blockquote(Text Text))')
示例#8
0
    def test_src_with_type(self):
        text = '''#+BEGIN_SRC python
source code
source code
#+END_SRC'''
        o = Org(text)
        eq_(str(o), 'Org(CodeBlock(Text Text))')
示例#9
0
    def test_src(self):
        text = '''#+BEGIN_SRC
source code
source code
#+END_SRC'''
        o = Org(text)
        eq_(str(o), 'Org(CodeBlock(Text Text))')
示例#10
0
    def test_src_with_some_decoration(self):
        text = '''#+BEGIN_SRC
=source code=
+source code+
#+END_SRC'''
        o = Org(text)
        eq_(str(o), 'Org(CodeBlock(Text Text))')
示例#11
0
    def test_new_paragraph(self):
        text = '''para1-1
para1-2

para2-1
para2-2'''
        o = Org(text)
        eq_(str(o), 'Org(Paragraph(Text Text) Paragraph(Text Text))')
示例#12
0
    def test_slide_heading_html(self):
        text = '''* header1
paraparapara
** header2-1
[[image]]
para*para*2[[http://example.com][hyperlink]]
** header2-2
| a | b |
| 1 | 2 |

*** header3
#+BEGIN_QUOTE
quoted
#+END_QUOTE'''
        o = Org(text, default_heading=2)
        eq_(
            o.html(),
            '<h2>header1</h2><p>paraparapara</p><h3>header2-1</h3><p><img src="image">para<span style="font-weight: bold;">para</span>2<a href="http://example.com">hyperlink</a></p><h3>header2-2</h3><table><tr><td>a</td><td>b</td></tr><tr><td>1</td><td>2</td></tr></table><h4>header3</h4><blockquote>quoted</blockquote>'
        )
示例#13
0
    def test_table(self):
        text = '''| col1-1 | col2-1|col3-1 |col4-1|
| col1-2|col2-2 |col3-2| col4-2 |
|col1-3 |col2-3| col3-3 | col4-3|
|col1-4| col2-4 | col3-4|col4-4 |'''
        o = Org(text)
        eq_(
            str(o),
            'Org(Table(TableRow(TableCell(Text) TableCell(Text) TableCell(Text) TableCell(Text)) TableRow(TableCell(Text) TableCell(Text) TableCell(Text) TableCell(Text)) TableRow(TableCell(Text) TableCell(Text) TableCell(Text) TableCell(Text)) TableRow(TableCell(Text) TableCell(Text) TableCell(Text) TableCell(Text))))'
        )
示例#14
0
    def test_heading(self):
        text = '''* Heading1
** Heading2
*** Heading3
**** Heading4
***** Heading5-1
****** Heading6
***** Heading5-2'''
        o = Org(text)
        eq_(
            str(o),
            'Org(Heading1(Heading2(Heading3(Heading4(Heading5(Heading6()) Heading5())))))'
        )
示例#15
0
    def test_nested_unorderedlist(self):
        text = '''- listitem1
- listitem2
  + shallowitem1
  + shallowitem2
     - deepitem1
     - deepitem2
  + shallowitem3
- listitem3'''
        o = Org(text)
        eq_(
            str(o),
            'Org(UnOrderedList(ListItem ListItem UnOrderedList(ListItem ListItem UnOrderedList(ListItem ListItem) ListItem) ListItem))'
        )
示例#16
0
    def test_nested_orderedlist(self):
        text = '''1. listitem1
2. listitem2
  1. shallowitem1
  2. shallowitem2
     1. deepitem1
     2. deepitem2
  3. shallowitem3
3. listitem3'''
        o = Org(text)
        eq_(
            str(o),
            'Org(OrderedList(ListItem ListItem OrderedList(ListItem ListItem OrderedList(ListItem ListItem) ListItem) ListItem))'
        )
示例#17
0
    def test_definitionlist(self):
        text = '''- listtitle1:: listdescription1
- listtitle2::listdescription2
- listtitle3 :: listdescription3
- listtitle4::listdescription4
+ listtitle5:: listdescription5
+ listtitle6::listdescription6
+ listtitle7 :: listdescription7
+ listtitle8::listdescription8'''
        o = Org(text)
        eq_(
            str(o),
            'Org(DefinitionList(DefinitionListItem(DefinitionListItemTitle DefinitionListItemDescription) DefinitionListItem(DefinitionListItemTitle DefinitionListItemDescription) DefinitionListItem(DefinitionListItemTitle DefinitionListItemDescription) DefinitionListItem(DefinitionListItemTitle DefinitionListItemDescription) DefinitionListItem(DefinitionListItemTitle DefinitionListItemDescription) DefinitionListItem(DefinitionListItemTitle DefinitionListItemDescription) DefinitionListItem(DefinitionListItemTitle DefinitionListItemDescription) DefinitionListItem(DefinitionListItemTitle DefinitionListItemDescription)))'
        )
示例#18
0
    def text_nested_definitionlist(self):
        text = '''- listitem1:: desc1
- listitem2 ::desc2
  + shallowitem1 :: shallowdesc1
  + shallowitem2::shallowdesc2
     - deepitem1::deepdesc1
     - deepitem2 :: deepdesc2
  + shallowitem3:: shallowdesc3
- listitem3 :: desc3'''
        o = Org(text)
        eq_(
            str(o),
            'Org(DefinitionList(DefinitionListItem(DefinitionListItemTitle DefinitionListItemDescription) DefinitionListItem(DefinitionListItemTitle DefinitionListItemDescription) DefinitionList(DefinitionListItem(DefinitionListItemTitle DefinitionListItemDescription) DefinitionListItem(DefinitionListItemTitle DefinitionListItemDescription) DefinitionList(DefinitionListItem(DefinitionListItemTitle DefinitionListItemDescription) DefinitionListItem(DefinitionListItemTitle DefinitionListItemDescription)) DefinitionListItem(DefinitionListItemTitle DefinitionListItemDescription)) DefinitionListItem(DefinitionListItemTitle DefinitionListItemDescription)))'
        )
示例#19
0
    def test_mix(self):
        text = '''* header1
paraparapara
** header2-1
[[image]]
para*para*2[[http://example.com][hyperlink]]
** header2-2
| a | b |
| 1 | 2 |

*** header3
#+BEGIN_QUOTE
quoted
- hoge
- fuga
#+END_QUOTE'''
        o = Org(text)
        eq_(
            str(o),
            'Org(Heading1(Paragraph(Text) Heading2(Paragraph(Text Text)) Heading2(Table(TableRow(TableCell(Text) TableCell(Text)) TableRow(TableCell(Text) TableCell(Text))) Heading3(Blockquote(Text UnOrderedList(ListItem ListItem))))))'
        )
示例#20
0
 def test_bold(self):
     text = '''hoge*bold*fuga'''
     o = Org(text)
     eq_(str(o), 'Org(Paragraph(Text))')
     eq_(o.children[0].children[0].get_text(), 'hogeBoldTextfuga')
示例#21
0
 def test_openless_src(self):
     text = '''#+END_SRC'''
     Org(text)
示例#22
0
 def test_italic(self):
     text = '''hoge/italic/fuga'''
     o = Org(text)
     eq_(str(o), 'Org(Paragraph(Text))')
     eq_(o.children[0].children[0].get_text(), 'hogeItalicTextfuga')
示例#23
0
 def test_org(self):
     text = ''''''
     o = Org(text)
     eq_(str(o), 'Org()')
示例#24
0
 def test_endless_blockquote(self):
     text = '''#+BEGIN_QUOTE'''
     Org(text)
示例#25
0
 def test_underlined(self):
     text = '''hoge_underlined_fuga'''
     o = Org(text)
     eq_(str(o), 'Org(Paragraph(Text))')
     eq_(o.children[0].children[0].get_text(), 'hogeUnderlinedTextfuga')
示例#26
0
 def test_openless_blockquote(self):
     text = '''#+END_QUOTE'''
     Org(text)
示例#27
0
    def test_blockquote_with_some_decoration(self):
        text = '''#+BEGIN_QUOTE
=quoted line=
#+END_QUOTE'''
        o = Org(text)
        eq_(str(o), 'Org(Blockquote(Text))')
示例#28
0
 def test_linethrough(self):
     text = '''hoge+linethrough+fuga'''
     o = Org(text)
     eq_(str(o), 'Org(Paragraph(Text))')
     eq_(o.children[0].children[0].get_text(), 'hogeLinethroughTextfuga')
示例#29
0
    def test_slided_heading(self):
        text = '''* Heading2
** Heading3'''
        o = Org(text, default_heading=2)
        eq_(str(o), 'Org(Heading2(Heading3()))')
示例#30
0
 def test_inlinecode(self):
     text = '''hoge=code=fuga'''
     o = Org(text)
     eq_(str(o), 'Org(Paragraph(Text))')
     eq_(o.children[0].children[0].get_text(), 'hogeInlineCodeTextfuga')