-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6332 from tk0miya/rest_renderer
Add ReSTRenderer; a helper for rendering reST text
- Loading branch information
Showing
4 changed files
with
121 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
""" | ||
test_util_template | ||
~~~~~~~~~~~~~~~~~~ | ||
Tests sphinx.util.template functions. | ||
:copyright: Copyright 2007-2019 by the Sphinx team, see AUTHORS. | ||
:license: BSD, see LICENSE for details. | ||
""" | ||
|
||
from sphinx.util.template import ReSTRenderer | ||
|
||
|
||
def test_ReSTRenderer_escape(): | ||
r = ReSTRenderer() | ||
template = '{{ "*hello*" | e }}' | ||
assert r.render_string(template, {}) == r'\*hello\*' | ||
|
||
|
||
def test_ReSTRenderer_heading(): | ||
r = ReSTRenderer() | ||
|
||
template = '{{ "hello" | heading }}' | ||
assert r.render_string(template, {}) == 'hello\n=====' | ||
|
||
template = '{{ "hello" | heading(1) }}' | ||
assert r.render_string(template, {}) == 'hello\n=====' | ||
|
||
template = '{{ "русский язык" | heading(2) }}' | ||
assert r.render_string(template, {}) == ('русский язык\n' | ||
'------------') | ||
|
||
# language: ja | ||
r.env.language = 'ja' | ||
template = '{{ "русский язык" | heading }}' | ||
assert r.render_string(template, {}) == ('русский язык\n' | ||
'=======================') |