Ejemplo n.º 1
0
    def test_title_underline(self):
        text = u"""\
I am the prince of the titles
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%"""
        events = parse_blocks(text)
        events = parse_titles(events)
        events = list(events)
        self.assertEqual(len(events), 1)
        self.assertEqual(events[0], (XTITLE,
            (u'', u'I am the prince of the titles', u'%')))
Ejemplo n.º 2
0
    def test_title_overline(self):
        text = u"""\
#############################
I am the king of the titles
#############################"""
        events = parse_blocks(text)
        events = parse_titles(events)
        events = list(events)
        self.assertEqual(len(events), 1)
        self.assertEqual(events[0], (XTITLE,
            (u'#', u'I am the king of the titles', u'#')))
Ejemplo n.º 3
0
    def test_title_underline(self):
        text = u"""\
I am the prince of the titles
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%"""
        events = parse_blocks(text)
        events = parse_titles(events)
        events = list(events)
        self.assertEqual(len(events), 1)
        self.assertEqual(events[0],
                         (XTITLE,
                          (u'', u'I am the prince of the titles', u'%')))
Ejemplo n.º 4
0
    def test_paragraph(self):
        text = u"""\
I am a paragraph.

I am another one."""
        events = parse_blocks(text)
        events = parse_titles(events)
        events = list(events)
        self.assertEqual(len(events), 2)
        self.assertEqual(events[0], (XPARAGRAPH, u'I am a paragraph.'))
        self.assertEqual(events[1], (XPARAGRAPH, u'I am another one.'))
Ejemplo n.º 5
0
    def test_paragraph(self):
        text = u"""\
I am a paragraph.

I am another one."""
        events = parse_blocks(text)
        events = parse_titles(events)
        events = list(events)
        self.assertEqual(len(events), 2)
        self.assertEqual(events[0], (XPARAGRAPH, u'I am a paragraph.'))
        self.assertEqual(events[1], (XPARAGRAPH, u'I am another one.'))
Ejemplo n.º 6
0
    def test_title_overline(self):
        text = u"""\
#############################
I am the king of the titles
#############################"""
        events = parse_blocks(text)
        events = parse_titles(events)
        events = list(events)
        self.assertEqual(len(events), 1)
        self.assertEqual(events[0],
                         (XTITLE,
                          (u'#', u'I am the king of the titles', u'#')))
Ejemplo n.º 7
0
    def test_title_paragraph(self):
        text = u"""\
Please allow to introduce myself
````````````````````````````````
I'm a man of wealth and taste"""
        events = parse_blocks(text)
        events = parse_titles(events)
        events = list(events)
        self.assertEqual(len(events), 2)
        self.assertEqual(events[0], (XTITLE,
            (u'', u'Please allow to introduce myself', u'`')))
        self.assertEqual(events[1], (XPARAGRAPH,
            u"I'm a man of wealth and taste"))
Ejemplo n.º 8
0
    def test_title_paragraph(self):
        text = u"""\
Please allow to introduce myself
````````````````````````````````
I'm a man of wealth and taste"""
        events = parse_blocks(text)
        events = parse_titles(events)
        events = list(events)
        self.assertEqual(len(events), 2)
        self.assertEqual(events[0],
                         (XTITLE,
                          (u'', u'Please allow to introduce myself', u'`')))
        self.assertEqual(events[1],
                         (XPARAGRAPH, u"I'm a man of wealth and taste"))
Ejemplo n.º 9
0
    def test_paragraph_literal(self):
        text = u"""\
The code reads as follow::

    >>> from itools.rest import parser

But failed with a NotImplementedError."""
        events = parse_blocks(text)
        events = parse_literal_blocks(events)
        events = parse_titles(events)
        events = list(events)
        self.assertEqual(len(events), 3)
        self.assertEqual(events[0], (XPARAGRAPH, u'The code reads as follow:'))
        self.assertEqual(events[1], (XLITERAL_BLOCK,
            u'    >>> from itools.rest import parser'))
        self.assertEqual(events[2], (XPARAGRAPH,
            u'But failed with a NotImplementedError.'))
Ejemplo n.º 10
0
    def test_paragraph_literal(self):
        text = u"""\
The code reads as follow::

    >>> from itools.rest import parser

But failed with a NotImplementedError."""
        events = parse_blocks(text)
        events = parse_literal_blocks(events)
        events = parse_titles(events)
        events = list(events)
        self.assertEqual(len(events), 3)
        self.assertEqual(events[0], (XPARAGRAPH, u'The code reads as follow:'))
        self.assertEqual(
            events[1],
            (XLITERAL_BLOCK, u'    >>> from itools.rest import parser'))
        self.assertEqual(
            events[2], (XPARAGRAPH, u'But failed with a NotImplementedError.'))
Ejemplo n.º 11
0
    def test_paragraph_list(self):
        text = u"""\
* I am a block.

  I am the same block.

I am a paragraph."""
        events = parse_blocks(text)
        events = parse_lists(events)
        events = parse_titles(events)
        events = list(events)
        self.assertEqual(len(events), 7)
        self.assertEqual(events[0], (XLIST_BEGIN, u'*'))
        self.assertEqual(events[1], (XLIST_ITEM_BEGIN, 2))
        self.assertEqual(events[2], (XPARAGRAPH, u'I am a block.'))
        self.assertEqual(events[3], (XPARAGRAPH, u'I am the same block.'))
        self.assertEqual(events[4], (XLIST_ITEM_END, 2))
        self.assertEqual(events[5], (XLIST_END, u'*'))
        self.assertEqual(events[6], (XPARAGRAPH, u'I am a paragraph.'))
Ejemplo n.º 12
0
    def test_paragraph_list(self):
        text = u"""\
* I am a block.

  I am the same block.

I am a paragraph."""
        events = parse_blocks(text)
        events = parse_lists(events)
        events = parse_titles(events)
        events = list(events)
        self.assertEqual(len(events), 7)
        self.assertEqual(events[0], (XLIST_BEGIN, u'*'))
        self.assertEqual(events[1], (XLIST_ITEM_BEGIN, 2))
        self.assertEqual(events[2], (XPARAGRAPH, u'I am a block.'))
        self.assertEqual(events[3], (XPARAGRAPH, u'I am the same block.'))
        self.assertEqual(events[4], (XLIST_ITEM_END, 2))
        self.assertEqual(events[5], (XLIST_END, u'*'))
        self.assertEqual(events[6], (XPARAGRAPH, u'I am a paragraph.'))