Ejemplo n.º 1
0
 def test_spaces_around_header_string_SHOULD_not_appear_in_header(self):
     expected = [lists.HeaderContentList([_list_item('item 1'),
                                          _list_item('item 2')],
                                         self.EXPECTED_LIST_FORMAT)]
     actual = sut.parse(['  *   item 1',
                         '  *  item 2   '])
     check(self, expected, actual)
Ejemplo n.º 2
0
 def test_single_line_text_blocks(self):
     check(self,
           [Paragraph([StringText('text in para 1')]),
            Paragraph([StringText('text in para 2')])],
           sut.parse(['text in para 1'] +
                     sut.PARAGRAPH_SEPARATOR_LINES +
                     ['text in para 2']))
Ejemplo n.º 3
0
 def test_list_with_item_multiple_paragraphs_contents_in_middle_of_paragraphs(self):
     expected = [
         Paragraph([StringText('first paragraph')]),
         lists.HeaderContentList([
             _list_item('item 1',
                        [
                            Paragraph([StringText('line 1 in contents paragraph 1'),
                                       StringText('line 2 in contents paragraph 1')]),
                            Paragraph([StringText('line 1 in contents paragraph 2')]),
                        ]),
         ],
             self.EXPECTED_LIST_FORMAT),
         Paragraph([StringText('last paragraph')]),
     ]
     actual = sut.parse(['first paragraph',
                         '',
                         '',
                         '  * item 1',
                         '',
                         '    line 1 in contents paragraph 1',
                         '',
                         '    line 2 in contents paragraph 1',
                         '',
                         '',
                         '    line 1 in contents paragraph 2',
                         '',
                         '',
                         'last paragraph'])
     check(self, expected, actual)
Ejemplo n.º 4
0
 def test_single_literal_block_w_class(self):
     check(self,
           [sut.LiteralLayout(lines_content(['literal line']), 'the-class')],
           sut.parse(['```:the-class',
                      'literal line',
                      '```',
                      ]))
Ejemplo n.º 5
0
 def test_list_with_item_multiple_paragraphs_contents_before_other_item(self):
     expected = [
         lists.HeaderContentList([
             _list_item('item 1',
                        [
                            Paragraph([StringText('item 1 contents paragraph 1')]),
                            Paragraph([StringText('item 1 contents paragraph 2')]),
                        ]),
             _list_item('item 2',
                        [
                            Paragraph([StringText('item 2 contents paragraph 1')]),
                        ]),
         ],
             self.EXPECTED_LIST_FORMAT),
         Paragraph([StringText('last paragraph')]),
     ]
     actual = sut.parse(['  * item 1',
                         '',
                         '    item 1 contents paragraph 1',
                         '',
                         '',
                         '    item 1 contents paragraph 2',
                         '',
                         '  * item 2',
                         '',
                         '    item 2 contents paragraph 1',
                         '',
                         'last paragraph'])
     check(self, expected, actual)
Ejemplo n.º 6
0
 def test_single_line_text_blocks(self):
     check(self,
           [Paragraph([StringText('text 1'),
                       StringText('text 2')])],
           sut.parse(['text 1'] +
                     sut.TEXT_SEPARATOR_LINES +
                     ['text 2']))
Ejemplo n.º 7
0
 def test_escaping_markup_token_inside_literal_block(self):
     check(self,
           [sut.LiteralLayout(lines_content(['```']))],
           sut.parse(['```',
                      '\\```',
                      '```',
                      ]))
Ejemplo n.º 8
0
 def test_single_list_with_multiple_items_with_other_indentation_level(self):
     expected = [lists.HeaderContentList([_list_item('item 1'),
                                          _list_item('item 2')],
                                         self.EXPECTED_LIST_FORMAT)]
     actual = sut.parse(['    * item 1',
                         '    * item 2'])
     check(self, expected, actual)
Ejemplo n.º 9
0
 def test_single_list_with_multiple_items_with_trailing_blank_lines(self):
     expected = [lists.HeaderContentList([_list_item('item 1'),
                                          _list_item('item 2')],
                                         self.EXPECTED_LIST_FORMAT)]
     actual = sut.parse(['  * item 1',
                         '  * item 2',
                         ''])
     check(self, expected, actual)
Ejemplo n.º 10
0
 def test_larger_paragraph_separator(self):
     check(self,
           [Paragraph([StringText('text in para 1')]),
            Paragraph([StringText('text in para 2')])],
           sut.parse(['text in para 1'] +
                     sut.PARAGRAPH_SEPARATOR_LINES +
                     sut.PARAGRAPH_SEPARATOR_LINES +
                     ['text in para 2']))
Ejemplo n.º 11
0
 def test_single_list_with_multiple_items_separated_by_empty_line(self):
     expected = [lists.HeaderContentList([_list_item('item 1'),
                                          _list_item('item 2')],
                                         self.EXPECTED_LIST_FORMAT)]
     actual = sut.parse(['  * item 1',
                         '',
                         '  * item 2'])
     check(self, expected, actual)
Ejemplo n.º 12
0
 def test_single_text_block_on_multiple_lines(self):
     input_lines = ['the',
                    'text',
                    'block'
                    ]
     check(self,
           [Paragraph([StringText(' '.join(input_lines))])],
           sut.parse(input_lines))
Ejemplo n.º 13
0
 def test_multi_line_text_blocks(self):
     input_lines = ['text',
                    '1'] + \
                   sut.TEXT_SEPARATOR_LINES + \
                   ['text',
                    '2']
     check(self,
           [Paragraph([StringText('text 1'),
                       StringText('text 2')])],
           sut.parse(input_lines))
Ejemplo n.º 14
0
 def test_single_list_with_single_item_with_contents_on_next_line(self):
     expected = [lists.HeaderContentList([
         _list_item('item',
                    [
                        Paragraph([StringText('contents')]),
                    ])],
         self.EXPECTED_LIST_FORMAT)]
     actual = sut.parse(['  1. item',
                         '     contents',
                         ])
     check(self, expected, actual)
Ejemplo n.º 15
0
 def test_literal_block_with_blank_lines_should_not_split_block(self):
     check(self,
           [sut.LiteralLayout(lines_content(['first line'] +
                                            sut.PARAGRAPH_SEPARATOR_LINES +
                                            ['last line']))],
           sut.parse(['```',
                      'first line'] +
                     sut.PARAGRAPH_SEPARATOR_LINES +
                     ['last line',
                      '```',
                      ]))
Ejemplo n.º 16
0
 def test_multiple_text_blocks(self):
     check(self,
           [Paragraph([StringText('text 1 in para 1'),
                       StringText('text 2 in para 1')]),
            Paragraph([StringText('text 1 in para 2'),
                       StringText('text 2 in para 2')])],
           sut.parse(['text 1 in para 1'] +
                     sut.TEXT_SEPARATOR_LINES +
                     ['text 2 in para 1'] +
                     sut.PARAGRAPH_SEPARATOR_LINES +
                     ['text 1 in para 2'] +
                     sut.TEXT_SEPARATOR_LINES +
                     ['text 2 in para 2']))
Ejemplo n.º 17
0
 def test_literal_block_between_paragraph_blocks(self):
     check(self,
           [
               Paragraph([StringText('para 1')]),
               sut.LiteralLayout(lines_content(['literal line'])),
               Paragraph([StringText('para 2')]),
           ],
           sut.parse(['para 1'] +
                     sut.PARAGRAPH_SEPARATOR_LINES +
                     ['```',
                      'literal line',
                      '```'] +
                     sut.PARAGRAPH_SEPARATOR_LINES +
                     ['para 2']))
Ejemplo n.º 18
0
 def test_list_in_middle_of_paragraphs(self):
     expected = [
         Paragraph([StringText('first paragraph')]),
         lists.HeaderContentList([_list_item('item 1'),
                                  _list_item('item 2')],
                                 self.EXPECTED_LIST_FORMAT),
         Paragraph([StringText('last paragraph')]),
     ]
     actual = sut.parse(['first paragraph',
                         '',
                         '',
                         '  * item 1',
                         '  * item 2',
                         '',
                         '',
                         'last paragraph'])
     check(self, expected, actual)
Ejemplo n.º 19
0
    def test_single_list_with_with_contents(self):
        expected = [lists.HeaderContentList([
            _list_item('item 1',
                       [
                           Paragraph([StringText('contents 1')]),
                       ]),
            _list_item('item 2',
                       [
                           Paragraph([StringText('contents 2')]),
                       ]),
        ],
            self.EXPECTED_LIST_FORMAT)]
        actual = sut.parse(['  * item 1',

                            '    contents 1',
                            '  * item 2',
                            '    contents 2',
                            ])
        check(self, expected, actual)
Ejemplo n.º 20
0
 def test_nested_lists(self):
     expected = [
         lists.HeaderContentList([
             _list_item('itemized item 1',
                        [
                            Paragraph([StringText('item 1 contents paragraph')]),
                            lists.HeaderContentList(
                                [
                                    _list_item('ordered item 1/1',
                                               [
                                                   Paragraph([StringText('item 1/1 contents paragraph')]),
                                               ]),
                                    _list_item('ordered item 1/2',
                                               []),
                                ],
                                self.EXPECTED_ORDERED_LIST_FORMAT),
                        ]),
             _list_item('itemized item 2',
                        []),
         ],
             self.EXPECTED_ITEMIZED_LIST_FORMAT),
     ]
     actual = sut.parse(['  * itemized item 1',
                         '',
                         '    item 1 contents paragraph',
                         '',
                         '',
                         '      1. ordered item 1/1',
                         '',
                         '         item 1/1 contents paragraph',
                         '',
                         '      1. ordered item 1/2',
                         '',
                         '  * itemized item 2',
                         ])
     check(self, expected, actual)
Ejemplo n.º 21
0
 def test_strip_text_strings(self):
     check(self,
           [Paragraph([StringText('the text block')])],
           sut.parse(['  the text block   ']))
Ejemplo n.º 22
0
 def test_single_text_block_on_single_line(self):
     check(self,
           [Paragraph([StringText('the text block')])],
           sut.parse(['the text block']))
Ejemplo n.º 23
0
 def test_empty_input(self):
     check(self,
           [],
           sut.parse([]))
Ejemplo n.º 24
0
 def test_escaping_markup_token_should_make_contents_be_treated_as_normal_paragraph(self):
     check(self,
           [Paragraph([StringText('``` line')])],
           sut.parse(['\\```',
                      'line',
                      ]))
Ejemplo n.º 25
0
 def test_escaping_backslash(self):
     check(self,
           [Paragraph([StringText('\\``` line')])],
           sut.parse(['\\\\```',
                      'line',
                      ]))
Ejemplo n.º 26
0
 def test_missing_closing_brace_should_raise_exception(self):
     with self.assertRaises(ValueError):
         sut.parse(['```',
                    'literal line',
                    ])
Ejemplo n.º 27
0
 def test_single_list_with_single_item_as_last_line(self):
     expected = [lists.HeaderContentList([_list_item('item')],
                                         self.EXPECTED_LIST_FORMAT)]
     actual = sut.parse(['  1. item'])
     check(self, expected, actual)
Ejemplo n.º 28
0
 def test_single_list_with_single_item_followed_by_empty_line(self):
     expected = [lists.HeaderContentList([_list_item('item')],
                                         self.EXPECTED_LIST_FORMAT)]
     actual = sut.parse(['  * item',
                         ''])
     check(self, expected, actual)