tests/test-minirst.py
changeset 36706 87b8fc4533ca
parent 31130 6582b3716ae0
child 37881 672f51ec0d47
equal deleted inserted replaced
36705:c6901665cd5b 36706:87b8fc4533ca
    26     print("== %s ==" % title)
    26     print("== %s ==" % title)
    27     debugformat(text, 60, **kwargs)
    27     debugformat(text, 60, **kwargs)
    28     debugformat(text, 30, **kwargs)
    28     debugformat(text, 30, **kwargs)
    29     debugformat(text, 'html', **kwargs)
    29     debugformat(text, 'html', **kwargs)
    30 
    30 
    31 paragraphs = """
    31 paragraphs = b"""
    32 This is some text in the first paragraph.
    32 This is some text in the first paragraph.
    33 
    33 
    34   A small indented paragraph.
    34   A small indented paragraph.
    35   It is followed by some lines
    35   It is followed by some lines
    36   containing random whitespace.
    36   containing random whitespace.
    37  \n  \n   \nThe third and final paragraph.
    37  \n  \n   \nThe third and final paragraph.
    38 """
    38 """
    39 
    39 
    40 debugformats('paragraphs', paragraphs)
    40 debugformats(b'paragraphs', paragraphs)
    41 
    41 
    42 definitions = """
    42 definitions = b"""
    43 A Term
    43 A Term
    44   Definition. The indented
    44   Definition. The indented
    45   lines make up the definition.
    45   lines make up the definition.
    46 Another Term
    46 Another Term
    47   Another definition. The final line in the
    47   Another definition. The final line in the
    50 
    50 
    51   A Nested/Indented Term
    51   A Nested/Indented Term
    52     Definition.
    52     Definition.
    53 """
    53 """
    54 
    54 
    55 debugformats('definitions', definitions)
    55 debugformats(b'definitions', definitions)
    56 
    56 
    57 literals = r"""
    57 literals = br"""
    58 The fully minimized form is the most
    58 The fully minimized form is the most
    59 convenient form::
    59 convenient form::
    60 
    60 
    61   Hello
    61   Hello
    62     literal
    62     literal
    74   This literal block is started with '::',
    74   This literal block is started with '::',
    75     the so-called expanded form. The paragraph
    75     the so-called expanded form. The paragraph
    76       with '::' disappears in the final output.
    76       with '::' disappears in the final output.
    77 """
    77 """
    78 
    78 
    79 debugformats('literals', literals)
    79 debugformats(b'literals', literals)
    80 
    80 
    81 lists = """
    81 lists = b"""
    82 - This is the first list item.
    82 - This is the first list item.
    83 
    83 
    84   Second paragraph in the first list item.
    84   Second paragraph in the first list item.
    85 
    85 
    86 - List items need not be separated
    86 - List items need not be separated
   125 * This is the second bullet
   125 * This is the second bullet
   126   It has 2 lines
   126   It has 2 lines
   127 * This is the third bullet
   127 * This is the third bullet
   128 """
   128 """
   129 
   129 
   130 debugformats('lists', lists)
   130 debugformats(b'lists', lists)
   131 
   131 
   132 options = """
   132 options = b"""
   133 There is support for simple option lists,
   133 There is support for simple option lists,
   134 but only with long options:
   134 but only with long options:
   135 
   135 
   136 -X, --exclude  filter  an option with a short and long option with an argument
   136 -X, --exclude  filter  an option with a short and long option with an argument
   137 -I, --include          an option with both a short option and a long option
   137 -I, --include          an option with both a short option and a long option
   151 marker after the option. It is treated as a normal paragraph:
   151 marker after the option. It is treated as a normal paragraph:
   152 
   152 
   153 --foo bar baz
   153 --foo bar baz
   154 """
   154 """
   155 
   155 
   156 debugformats('options', options)
   156 debugformats(b'options', options)
   157 
   157 
   158 fields = """
   158 fields = b"""
   159 :a: First item.
   159 :a: First item.
   160 :ab: Second item. Indentation and wrapping
   160 :ab: Second item. Indentation and wrapping
   161      is handled automatically.
   161      is handled automatically.
   162 
   162 
   163 Next list:
   163 Next list:
   164 
   164 
   165 :small: The larger key below triggers full indentation here.
   165 :small: The larger key below triggers full indentation here.
   166 :much too large: This key is big enough to get its own line.
   166 :much too large: This key is big enough to get its own line.
   167 """
   167 """
   168 
   168 
   169 debugformats('fields', fields)
   169 debugformats(b'fields', fields)
   170 
   170 
   171 containers = """
   171 containers = b"""
   172 Normal output.
   172 Normal output.
   173 
   173 
   174 .. container:: debug
   174 .. container:: debug
   175 
   175 
   176    Initial debug output.
   176    Initial debug output.
   182    .. container:: debug
   182    .. container:: debug
   183 
   183 
   184       Debug output.
   184       Debug output.
   185 """
   185 """
   186 
   186 
   187 debugformats('containers (normal)', containers)
   187 debugformats(b'containers (normal)', containers)
   188 debugformats('containers (verbose)', containers, keep=['verbose'])
   188 debugformats(b'containers (verbose)', containers, keep=['verbose'])
   189 debugformats('containers (debug)', containers, keep=['debug'])
   189 debugformats(b'containers (debug)', containers, keep=['debug'])
   190 debugformats('containers (verbose debug)', containers,
   190 debugformats(b'containers (verbose debug)', containers,
   191             keep=['verbose', 'debug'])
   191             keep=['verbose', 'debug'])
   192 
   192 
   193 roles = """Please see :hg:`add`."""
   193 roles = b"""Please see :hg:`add`."""
   194 debugformats('roles', roles)
   194 debugformats(b'roles', roles)
   195 
   195 
   196 
   196 
   197 sections = """
   197 sections = b"""
   198 Title
   198 Title
   199 =====
   199 =====
   200 
   200 
   201 Section
   201 Section
   202 -------
   202 -------
   205 ''''''''''
   205 ''''''''''
   206 
   206 
   207 Markup: ``foo`` and :hg:`help`
   207 Markup: ``foo`` and :hg:`help`
   208 ------------------------------
   208 ------------------------------
   209 """
   209 """
   210 debugformats('sections', sections)
   210 debugformats(b'sections', sections)
   211 
   211 
   212 
   212 
   213 admonitions = """
   213 admonitions = b"""
   214 .. note::
   214 .. note::
   215 
   215 
   216    This is a note
   216    This is a note
   217 
   217 
   218    - Bullet 1
   218    - Bullet 1
   223 
   223 
   224 .. danger::
   224 .. danger::
   225    This is danger
   225    This is danger
   226 """
   226 """
   227 
   227 
   228 debugformats('admonitions', admonitions)
   228 debugformats(b'admonitions', admonitions)
   229 
   229 
   230 comments = """
   230 comments = b"""
   231 Some text.
   231 Some text.
   232 
   232 
   233 .. A comment
   233 .. A comment
   234 
   234 
   235    .. An indented comment
   235    .. An indented comment
   239 ..
   239 ..
   240 
   240 
   241 Empty comment above
   241 Empty comment above
   242 """
   242 """
   243 
   243 
   244 debugformats('comments', comments)
   244 debugformats(b'comments', comments)
   245 
   245 
   246 
   246 
   247 data = [['a', 'b', 'c'],
   247 data = [[b'a', b'b', b'c'],
   248          ['1', '2', '3'],
   248          [b'1', b'2', b'3'],
   249          ['foo', 'bar', 'baz this list is very very very long man']]
   249          [b'foo', b'bar', b'baz this list is very very very long man']]
   250 
   250 
   251 rst = minirst.maketable(data, 2, True)
   251 rst = minirst.maketable(data, 2, True)
   252 table = ''.join(rst)
   252 table = b''.join(rst)
   253 
   253 
   254 print(table)
   254 print(table)
   255 
   255 
   256 debugformats('table', table)
   256 debugformats(b'table', table)
   257 
   257 
   258 data = [['s', 'long', 'line\ngoes on here'],
   258 data = [[b's', b'long', b'line\ngoes on here'],
   259         ['', 'xy', 'tried to fix here\n        by indenting']]
   259         [b'', b'xy', b'tried to fix here\n        by indenting']]
   260 
   260 
   261 rst = minirst.maketable(data, 1, False)
   261 rst = minirst.maketable(data, 1, False)
   262 table = ''.join(rst)
   262 table = b''.join(rst)
   263 
   263 
   264 print(table)
   264 print(table)
   265 
   265 
   266 debugformats('table+nl', table)
   266 debugformats(b'table+nl', table)
   267 
   267