# Copyright: This module has been placed in the public domain.
"""
Test for fragment code in HTML writer.
Note: the 'body' and 'whole' entries have been removed from the parts
dictionaries (redundant), along with 'meta' and 'stylesheet' entries with
standard values, and any entries with empty values.
"""
from .__init__ import DocutilsTestSupport
from docutils import core
def suite():
s = DocutilsTestSupport.HtmlPublishPartsTestSuite()
s.generateTests(totest)
return s
totest = {}
totest['Title promotion'] = ({'stylesheet_path': '',
'embed_stylesheet': 0}, [
["""\
Simple String
""",
"""\
{'fragment': '''Simple String
\\n''',
'html_body': '''\\n''',
'html_head': '''...\\n'''}
"""],
["""\
Simple String with *markup*
""",
"""\
{'fragment': '''Simple String with markup
\\n''',
'html_body': '''
Simple String with markup
\\n''',
'html_head': '''...\\n'''}
"""],
["""\
Simple String with an even simpler ``inline literal``
""",
"""\
{'fragment': '''Simple String with an even simpler inline literal
\\n''',
'html_body': '''
Simple String with an even simpler inline literal
\\n''',
'html_head': '''...\\n'''}
"""],
["""\
A simple `anonymous reference`__
__ http://www.test.com/test_url
""",
"""\
{'fragment': '''A simple anonymous reference
\\n''',
'html_body': '''\\n''',
'html_head': '''...\\n'''}
"""],
["""\
One paragraph.
Two paragraphs.
""",
"""\
{'fragment': '''One paragraph.
Two paragraphs.
\\n''',
'html_body': '''
One paragraph.
Two paragraphs.
\\n''',
'html_head': '''...\\n'''}
"""],
["""\
A simple `named reference`_ with stuff in between the
reference and the target.
.. _`named reference`: http://www.test.com/test_url
""",
"""\
{'fragment': '''A simple named reference with stuff in between the
reference and the target.
\\n''',
'html_body': '''
A simple named reference with stuff in between the
reference and the target.
\\n''',
'html_head': '''...\\n'''}
"""],
["""\
+++++
Title
+++++
Subtitle
========
Some stuff
Section
-------
Some more stuff
Another Section
...............
And even more stuff
""",
"""\
{'fragment': '''Some stuff
Section
Some more stuff
Another Section
And even more stuff
\\n''',
'html_body': '''
Title
Subtitle
Some stuff
Section
Some more stuff
Another Section
And even more stuff
\\n''',
'html_head': '''...Title\\n''',
'html_subtitle': '''Subtitle
\\n''',
'html_title': '''Title
\\n''',
'subtitle': '''Subtitle''',
'title': '''Title'''}
"""],
["""\
+++++
Title
+++++
:author: me
Some stuff
""",
"""\
{'docinfo': '''\\n''',
'fragment': '''Some stuff
\\n''',
'html_body': '''\\n''',
'html_head': '''...Title
\\n''',
'html_title': '''Title
\\n''',
'meta': '''\\n''',
'title': '''Title'''}
"""]
])
totest['No title promotion'] = ({'doctitle_xform' : 0,
'stylesheet_path': '',
'embed_stylesheet': 0}, [
["""\
Simple String
""",
"""\
{'fragment': '''Simple String
\\n''',
'html_body': '''\\n''',
'html_head': '''...\\n'''}
"""],
["""\
Simple String with *markup*
""",
"""\
{'fragment': '''Simple String with markup
\\n''',
'html_body': '''
Simple String with markup
\\n''',
'html_head': '''...\\n'''}
"""],
["""\
Simple String with an even simpler ``inline literal``
""",
"""\
{'fragment': '''Simple String with an even simpler inline literal
\\n''',
'html_body': '''
Simple String with an even simpler inline literal
\\n''',
'html_head': '''...\\n'''}
"""],
["""\
A simple `anonymous reference`__
__ http://www.test.com/test_url
""",
"""\
{'fragment': '''A simple anonymous reference
\\n''',
'html_body': '''\\n''',
'html_head': '''...\\n'''}
"""],
["""\
A simple `named reference`_ with stuff in between the
reference and the target.
.. _`named reference`: http://www.test.com/test_url
""",
"""\
{'fragment': '''A simple named reference with stuff in between the
reference and the target.
\\n''',
'html_body': '''
A simple named reference with stuff in between the
reference and the target.
\\n''',
'html_head': '''...\\n'''}
"""],
["""\
+++++
Title
+++++
Not A Subtitle
==============
Some stuff
Section
-------
Some more stuff
Another Section
...............
And even more stuff
""",
"""\
{'fragment': '''
Title
Not A Subtitle
Some stuff
Section
Some more stuff
Another Section
And even more stuff
\\n''',
'html_body': '''
Title
Not A Subtitle
Some stuff
Section
Some more stuff
Another Section
And even more stuff
\\n''',
'html_head': '''...\\n'''}
"""],
["""\
* bullet
* list
""",
"""\
{'fragment': '''\\n''',
'html_body': '''\\n''',
'html_head': '''...\\n'''}
"""],
["""\
Not a docinfo.
:This: .. _target:
is
:a:
:simple:
:field: list
""",
"""\
{'fragment': '''Not a docinfo.
This: | is
|
a: | |
simple: | |
field: | list |
\\n''',
'html_body': '''
Not a docinfo.
This: | is
|
a: | |
simple: | |
field: | list |
\\n''',
'html_head': '''...\\n'''}
"""],
["""\
Not a docinfo.
:This is: a
:simple field list with loooong field: names
""",
"""\
{'fragment': '''Not a docinfo.
This is: | a |
simple field list with loooong field: |
| names |
\\n''',
'html_body': '''
Not a docinfo.
This is: | a |
simple field list with loooong field: |
| names |
\\n''',
'html_head': '''...\\n'''}
"""],
])
if __name__ == '__main__':
import unittest
unittest.main(defaultTest='suite')