mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Merge pull request #3605 from tk0miya/3594_support_block_level_raw_node_in_latex
Fix #3594: LaTeX: single raw directive has been considereed as block …
This commit is contained in:
commit
ebc376157c
1
CHANGES
1
CHANGES
@ -41,6 +41,7 @@ Incompatible changes
|
||||
``xcolor`` packages should be used by extensions of Sphinx latex writer.
|
||||
(refs #3550)
|
||||
* ``Builder.env`` is not filled at instantiation
|
||||
* #3594: LaTeX: single raw directive has been considereed as block level element
|
||||
|
||||
Features removed
|
||||
----------------
|
||||
|
@ -1991,8 +1991,12 @@ class LaTeXTranslator(nodes.NodeVisitor):
|
||||
|
||||
def visit_raw(self, node):
|
||||
# type: (nodes.Node) -> None
|
||||
if not self.is_inline(node):
|
||||
self.body.append('\n')
|
||||
if 'latex' in node.get('format', '').split():
|
||||
self.body.append(node.astext())
|
||||
if not self.is_inline(node):
|
||||
self.body.append('\n')
|
||||
raise nodes.SkipNode
|
||||
|
||||
def visit_reference(self, node):
|
||||
|
3
tests/roots/test-directives-raw/conf.py
Normal file
3
tests/roots/test-directives-raw/conf.py
Normal file
@ -0,0 +1,3 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
master_doc = 'index'
|
40
tests/roots/test-directives-raw/index.rst
Normal file
40
tests/roots/test-directives-raw/index.rst
Normal file
@ -0,0 +1,40 @@
|
||||
test-directives-raw
|
||||
===================
|
||||
|
||||
HTML
|
||||
----
|
||||
|
||||
standard
|
||||
^^^^^^^^
|
||||
|
||||
.. raw:: html
|
||||
|
||||
standalone raw directive (HTML)
|
||||
|
||||
with substitution
|
||||
^^^^^^^^^^^^^^^^^
|
||||
|
||||
HTML: abc |HTML_RAW| ghi
|
||||
|
||||
.. |HTML_RAW| raw:: html
|
||||
|
||||
def
|
||||
|
||||
LaTeX
|
||||
-----
|
||||
|
||||
standard
|
||||
^^^^^^^^
|
||||
|
||||
.. raw:: latex
|
||||
|
||||
standalone raw directive (LaTeX)
|
||||
|
||||
with substitution
|
||||
^^^^^^^^^^^^^^^^^
|
||||
|
||||
LaTeX: abc |LATEX_RAW| ghi
|
||||
|
||||
.. |LATEX_RAW| raw:: latex
|
||||
|
||||
def
|
@ -1180,3 +1180,17 @@ def test_html_inventory(app):
|
||||
'',
|
||||
'http://example.com/index.html',
|
||||
'The basic Sphinx documentation for testing')
|
||||
|
||||
|
||||
@pytest.mark.sphinx('html', testroot='directives-raw')
|
||||
def test_html_raw_directive(app, status, warning):
|
||||
app.builder.build_all()
|
||||
result = (app.outdir / 'index.html').text(encoding='utf8')
|
||||
|
||||
# standard case
|
||||
assert 'standalone raw directive (HTML)' in result
|
||||
assert 'standalone raw directive (LaTeX)' not in result
|
||||
|
||||
# with substitution
|
||||
assert '<p>HTML: abc def ghi</p>' in result
|
||||
assert '<p>LaTeX: abc ghi</p>' in result
|
||||
|
@ -1027,3 +1027,18 @@ def test_latex_table_complex_tables(app, status, warning):
|
||||
'\\sphinxtablestrut{6}&\\sphinxtablestrut{4}&\ncell3-5\n'
|
||||
'\\\\\n\\hline\n\\end{tabulary}\n'
|
||||
in table)
|
||||
|
||||
|
||||
@pytest.mark.sphinx('latex', testroot='directives-raw')
|
||||
def test_latex_raw_directive(app, status, warning):
|
||||
app.builder.build_all()
|
||||
result = (app.outdir / 'Python.tex').text(encoding='utf8')
|
||||
|
||||
# standard case
|
||||
assert 'standalone raw directive (HTML)' not in result
|
||||
assert ('\\label{\\detokenize{index:id1}}\n'
|
||||
'standalone raw directive (LaTeX)' in result)
|
||||
|
||||
# with substitution
|
||||
assert 'HTML: abc ghi' in result
|
||||
assert 'LaTeX: abc def ghi' in result
|
||||
|
Loading…
Reference in New Issue
Block a user