mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2026-09-03 20:52:55 -05:00
Replace :file: and :samp: roles by class based implementation
This commit is contained in:
+30
-18
@@ -184,24 +184,6 @@ def get_verifier(verify, verify_re):
|
||||
'code</span>   <span class="pre">sample</span></code></p>'),
|
||||
r'\\sphinxcode{\\sphinxupquote{code sample}}',
|
||||
),
|
||||
(
|
||||
# correct interpretation of code with whitespace
|
||||
'verify_re',
|
||||
':samp:`code sample`',
|
||||
('<p><code class="(samp )?docutils literal notranslate"><span class="pre">'
|
||||
'code</span>   <span class="pre">sample</span></code></p>'),
|
||||
r'\\sphinxcode{\\sphinxupquote{code sample}}',
|
||||
),
|
||||
(
|
||||
# interpolation of braces in samp and file roles (HTML only)
|
||||
'verify',
|
||||
':samp:`a{b}c`',
|
||||
('<p><code class="samp docutils literal notranslate">'
|
||||
'<span class="pre">a</span>'
|
||||
'<em><span class="pre">b</span></em>'
|
||||
'<span class="pre">c</span></code></p>'),
|
||||
'\\sphinxcode{\\sphinxupquote{a\\sphinxstyleemphasis{b}c}}',
|
||||
),
|
||||
(
|
||||
# interpolation of arrows in menuselection
|
||||
'verify',
|
||||
@@ -314,6 +296,36 @@ def test_inline(get_verifier, type, rst, html_expected, latex_expected):
|
||||
verifier(rst, html_expected, latex_expected)
|
||||
|
||||
|
||||
def test_samp_role(parse):
|
||||
# no braces
|
||||
text = ':samp:`a{b}c`'
|
||||
doctree = parse(text)
|
||||
assert_node(doctree[0], [nodes.paragraph, nodes.literal, ("a",
|
||||
[nodes.emphasis, "b"],
|
||||
"c")])
|
||||
# nested braces
|
||||
text = ':samp:`a{{b}}c`'
|
||||
doctree = parse(text)
|
||||
assert_node(doctree[0], [nodes.paragraph, nodes.literal, ("a",
|
||||
[nodes.emphasis, "{b"],
|
||||
"}c")])
|
||||
|
||||
# half-opened braces
|
||||
text = ':samp:`a{bc`'
|
||||
doctree = parse(text)
|
||||
assert_node(doctree[0], [nodes.paragraph, nodes.literal, "a{bc"])
|
||||
|
||||
# escaped braces
|
||||
text = ':samp:`a\\\\{b}c`'
|
||||
doctree = parse(text)
|
||||
assert_node(doctree[0], [nodes.paragraph, nodes.literal, "a{b}c"])
|
||||
|
||||
# no braces (whitespaces are keeped as is)
|
||||
text = ':samp:`code sample`'
|
||||
doctree = parse(text)
|
||||
assert_node(doctree[0], [nodes.paragraph, nodes.literal, "code sample"])
|
||||
|
||||
|
||||
@pytest.mark.sphinx('dummy', testroot='prolog')
|
||||
def test_rst_prolog(app, status, warning):
|
||||
app.builder.build_all()
|
||||
|
||||
Reference in New Issue
Block a user