Please wait. This can take some minutes ...
Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance.
Project price only 1 $
You can buy this project and download/modify it how often you want.
test.test_parsers.test_rst.test_inline_markup.py Maven / Gradle / Ivy
#! /usr/bin/env python
# -*- coding: utf8 -*-
# $Id: test_inline_markup.py 7243 2011-12-05 19:35:32Z milde $
# Author: David Goodger
# Copyright: This module has been placed in the public domain.
"""
Tests for inline markup in docutils/parsers/rst/states.py.
Interpreted text tests are in a separate module, test_interpreted.py.
"""
from __init__ import DocutilsTestSupport
def suite():
s = DocutilsTestSupport.ParserTestSuite()
s.generateTests(totest)
return s
totest = {}
totest['emphasis'] = [
["""\
*emphasis*
""",
"""\
emphasis
"""],
[u"""\
l'*emphasis* with the *emphasis*' apostrophe.
l\u2019*emphasis* with the *emphasis*\u2019 apostrophe.
""",
u"""\
l\'
emphasis
with the \n\
emphasis
\' apostrophe.
l\u2019
emphasis
with the \n\
emphasis
\u2019 apostrophe.
"""],
["""\
*emphasized sentence
across lines*
""",
"""\
emphasized sentence
across lines
"""],
["""\
*emphasis without closing asterisk
""",
"""\
*
emphasis without closing asterisk
Inline emphasis start-string without end-string.
"""],
[r"""some punctuation is allowed around inline markup, e.g.
/*emphasis*/, -*emphasis*-, and :*emphasis*: (delimiters),
(*emphasis*), [*emphasis*], <*emphasis*>, {*emphasis*} (open/close pairs)
but not
)*emphasis*(, ]*emphasis*[, >*emphasis*>, }*emphasis*{ (close/open pairs)
(*), [*], '*' or '"*"' ("quoted" start-string),
x*2* or 2*x* (alphanumeric char before),
\*args or * (escaped, whitespace behind start-string)
or *the\* *stars\* *inside* (escaped, whitespace before end-string).
However, '*args' will trigger a warning and may be problematic.
what about *this**?
""",
"""\
some punctuation is allowed around inline markup, e.g.
/
emphasis
/, -
emphasis
-, and :
emphasis
: (delimiters),
(
emphasis
), [
emphasis
], <
emphasis
>, {
emphasis
} (open/close pairs)
but not
)*emphasis*(, ]*emphasis*[, >*emphasis*>, }*emphasis*{ (close/open pairs)
(*), [*], '*' or '"*"' ("quoted" start-string),
x*2* or 2*x* (alphanumeric char before),
*args or * (escaped, whitespace behind start-string)
or \n\
the* *stars* *inside
(escaped, whitespace before end-string).
However, '
*
args' will trigger a warning and may be problematic.
Inline emphasis start-string without end-string.
what about \n\
this*
?
"""],
[u"""\
Quotes around inline markup:
'*emphasis*' "*emphasis*" Straight,
‘*emphasis*’ “*emphasis*” English, ...,
« *emphasis* » ‹ *emphasis* › « *emphasis* » ‹ *emphasis* ›
« *emphasis* » ‹ *emphasis* › French,
„*emphasis*“ ‚*emphasis*‘ »*emphasis*« ›*emphasis*‹ German, Czech, ...,
„*emphasis*” «*emphasis*» Romanian,
“*emphasis*„ ‘*emphasis*‚ Greek,
「*emphasis*」 『*emphasis*』traditional Chinese,
”*emphasis*” ’*emphasis*’ »*emphasis*» ›*emphasis*› Swedish, Finnish,
„*emphasis*” ‚*emphasis*’ Polish,
„*emphasis*” »*emphasis*« ’*emphasis*’ Hungarian,
""",
u"""\
Quotes around inline markup:
\'
emphasis
\' "
emphasis
" Straight,
\u2018
emphasis
\u2019 \u201c
emphasis
\u201d English, ...,
\xab\u202f
emphasis
\u202f\xbb \u2039\u202f
emphasis
\u202f\u203a \xab\xa0
emphasis
\xa0\xbb \u2039\xa0
emphasis
\xa0\u203a
\xab\u2005
emphasis
\u2005\xbb \u2039\u2005
emphasis
\u2005\u203a French,
\u201e
emphasis
\u201c \u201a
emphasis
\u2018 \xbb
emphasis
\xab \u203a
emphasis
\u2039 German, Czech, ...,
\u201e
emphasis
\u201d \xab
emphasis
\xbb Romanian,
\u201c
emphasis
\u201e \u2018
emphasis
\u201a Greek,
\u300c
emphasis
\u300d \u300e
emphasis
\u300ftraditional Chinese,
\u201d
emphasis
\u201d \u2019
emphasis
\u2019 \xbb
emphasis
\xbb \u203a
emphasis
\u203a Swedish, Finnish,
\u201e
emphasis
\u201d \u201a
emphasis
\u2019 Polish,
\u201e
emphasis
\u201d \xbb
emphasis
\xab \u2019
emphasis
\u2019 Hungarian,
"""],
[r"""
Emphasized asterisk: *\**
Emphasized double asterisk: *\***
""",
"""\
Emphasized asterisk: \n\
*
Emphasized double asterisk: \n\
**
"""],
]
totest['strong'] = [
["""\
**strong**
""",
"""\
strong
"""],
[u"""\
l'**strong** and l\u2019**strong** with apostrophe
""",
u"""\
l'
strong
and l\u2019
strong
with apostrophe
"""],
[u"""\
quoted '**strong**', quoted "**strong**",
quoted \u2018**strong**\u2019, quoted \u201c**strong**\u201d,
quoted \xab**strong**\xbb
""",
u"""\
quoted '
strong
', quoted "
strong
",
quoted \u2018
strong
\u2019, quoted \u201c
strong
\u201d,
quoted \xab
strong
\xbb
"""],
[r"""
(**strong**) but not (**) or '(** ' or x**2 or \**kwargs or **
(however, '**kwargs' will trigger a warning and may be problematic)
""",
"""\
(
strong
) but not (**) or '(** ' or x**2 or **kwargs or **
(however, '
**
kwargs' will trigger a warning and may be problematic)
Inline strong start-string without end-string.
"""],
["""\
Strong asterisk: *****
Strong double asterisk: ******
""",
"""\
Strong asterisk: \n\
*
Strong double asterisk: \n\
**
"""],
["""\
**strong without closing asterisks
""",
"""\
**
strong without closing asterisks
Inline strong start-string without end-string.
"""],
]
totest['literal'] = [
["""\
``literal``
""",
"""\
literal
"""],
[r"""
``\literal``
""",
"""\
\\literal
"""],
[r"""
``lite\ral``
""",
"""\
lite\\ral
"""],
[r"""
``literal\``
""",
"""\
literal\\
"""],
[u"""\
l'``literal`` and l\u2019``literal`` with apostrophe
""",
u"""\
l'
literal
and l\u2019
literal
with apostrophe
"""],
[u"""\
quoted '``literal``', quoted "``literal``",
quoted \u2018``literal``\u2019, quoted \u201c``literal``\u201d,
quoted \xab``literal``\xbb
""",
u"""\
quoted '
literal
', quoted "
literal
",
quoted \u2018
literal
\u2019, quoted \u201c
literal
\u201d,
quoted \xab
literal
\xbb
"""],
[u"""\
``'literal'`` with quotes, ``"literal"`` with quotes,
``\u2018literal\u2019`` with quotes, ``\u201cliteral\u201d`` with quotes,
``\xabliteral\xbb`` with quotes
""",
u"""\
'literal'
with quotes, \n\
"literal"
with quotes,
\u2018literal\u2019
with quotes, \n\
\u201cliteral\u201d
with quotes,
\xabliteral\xbb
with quotes
"""],
[r"""
``literal ``TeX quotes'' & \backslash`` but not "``" or ``
(however, ``standalone TeX quotes'' will trigger a warning
and may be problematic)
""",
"""\
literal ``TeX quotes'' & \\backslash
but not "``" or ``
(however, \n\
``
standalone TeX quotes'' will trigger a warning
and may be problematic)
Inline literal start-string without end-string.
"""],
["""\
Find the ```interpreted text``` in this paragraph!
""",
"""\
Find the \n\
`interpreted text`
in this paragraph!
"""],
["""\
``literal without closing backquotes
""",
"""\
``
literal without closing backquotes
Inline literal start-string without end-string.
"""],
[r"""
Python ``list``\s use square bracket syntax.
""",
"""\
Python \n\
list
s use square bracket syntax.
"""],
]
totest['references'] = [
["""\
ref_
""",
"""\
ref
"""],
[u"""\
l'ref_ and l\u2019ref_ with apostrophe
""",
u"""\
l'
ref
and l\u2019
ref
with apostrophe
"""],
[u"""\
quoted 'ref_', quoted "ref_",
quoted \u2018ref_\u2019, quoted \u201cref_\u201d,
quoted \xabref_\xbb,
but not 'ref ref'_, "ref ref"_, \u2018ref ref\u2019_,
\u201cref ref\u201d_, or \xabref ref\xbb_
""",
u"""\
quoted '
ref
', quoted "
ref
",
quoted \u2018
ref
\u2019, quoted \u201c
ref
\u201d,
quoted \xab
ref
\xbb,
but not 'ref ref'_, "ref ref"_, \u2018ref ref\u2019_,
\u201cref ref\u201d_, or \xabref ref\xbb_
"""],
["""\
ref__
""",
"""\
ref
"""],
[u"""\
l'ref__ and l\u2019ref__ with apostrophe
""",
u"""\
l'
ref
and l\u2019
ref
with apostrophe
"""],
[u"""\
quoted 'ref__', quoted "ref__",
quoted \u2018ref__\u2019, quoted \u201cref__\u201d,
quoted \xabref__\xbb,
but not 'ref ref'__, "ref ref"__, \u2018ref ref\u2019__,
\u201cref ref\u201d__, or \xabref ref\xbb__
""",
u"""\
quoted '
ref
', quoted "
ref
",
quoted \u2018
ref
\u2019, quoted \u201c
ref
\u201d,
quoted \xab
ref
\xbb,
but not 'ref ref'__, "ref ref"__, \u2018ref ref\u2019__,
\u201cref ref\u201d__, or \xabref ref\xbb__
"""],
["""\
ref_, r_, r_e-f_, -ref_, and anonymousref__,
but not _ref_ or __attr__ or object.__attr__
""",
"""\
ref
, \n\
r
, \n\
r_e-f
, -
ref
, and \n\
anonymousref
,
but not _ref_ or __attr__ or object.__attr__
"""],
]
totest['phrase_references'] = [
["""\
`phrase reference`_
""",
"""\
phrase reference
"""],
[u"""\
l'`phrase reference`_ and l\u2019`phrase reference`_ with apostrophe
""",
u"""\
l'
phrase reference
and l\u2019
phrase reference
with apostrophe
"""],
[u"""\
quoted '`phrase reference`_', quoted "`phrase reference`_",
quoted \u2018`phrase reference`_\u2019,
quoted \u201c`phrase reference`_\u201d,
quoted \xab`phrase reference`_\xbb
""",
u"""\
quoted '
phrase reference
', quoted "
phrase reference
",
quoted \u2018
phrase reference
\u2019,
quoted \u201c
phrase reference
\u201d,
quoted \xab
phrase reference
\xbb
"""],
[u"""\
`'phrase reference'`_ with quotes, `"phrase reference"`_ with quotes,
`\u2018phrase reference\u2019`_ with quotes,
`\u201cphrase reference\u201d`_ with quotes,
`\xabphrase reference\xbb`_ with quotes
""",
u"""\
'phrase reference'
with quotes, \n\
"phrase reference"
with quotes,
\u2018phrase reference\u2019
with quotes,
\u201cphrase reference\u201d
with quotes,
\xabphrase reference\xbb
with quotes
"""],
["""\
`anonymous reference`__
""",
"""\
anonymous reference
"""],
[u"""\
l'`anonymous reference`__ and l\u2019`anonymous reference`__ with apostrophe
""",
u"""\
l'
anonymous reference
and l\u2019
anonymous reference
with apostrophe
"""],
[u"""\
quoted '`anonymous reference`__', quoted "`anonymous reference`__",
quoted \u2018`anonymous reference`__\u2019,
quoted \u201c`anonymous reference`__\u201d,
quoted \xab`anonymous reference`__\xbb
""",
u"""\
quoted '
anonymous reference
', quoted "
anonymous reference
",
quoted \u2018
anonymous reference
\u2019,
quoted \u201c
anonymous reference
\u201d,
quoted \xab
anonymous reference
\xbb
"""],
[u"""\
`'anonymous reference'`__ with quotes, `"anonymous reference"`__ with quotes,
`\u2018anonymous reference\u2019`__ with quotes,
`\u201canonymous reference\u201d`__ with quotes,
`\xabanonymous reference\xbb`__ with quotes
""",
u"""\
'anonymous reference'
with quotes, \n\
"anonymous reference"
with quotes,
\u2018anonymous reference\u2019
with quotes,
\u201canonymous reference\u201d
with quotes,
\xabanonymous reference\xbb
with quotes
"""],
["""\
`phrase reference
across lines`_
""",
"""\
phrase reference
across lines
"""],
["""\
`phrase\`_ reference`_
""",
"""\
phrase`_ reference
"""],
["""\
Invalid phrase reference:
:role:`phrase reference`_
""",
"""\
Invalid phrase reference:
:role:`phrase reference`_
Mismatch: both interpreted text role prefix and reference suffix.
"""],
["""\
Invalid phrase reference:
`phrase reference`:role:_
""",
"""\
Invalid phrase reference:
`phrase reference`:role:_
Mismatch: both interpreted text role suffix and reference suffix.
"""],
["""\
`phrase reference_ without closing backquote
""",
"""\
`
phrase \n\
reference
without closing backquote