Refactor to one environment per class.

Also rename sphinxcontainer to sphinxclass.
This commit is contained in:
David Ham 2021-05-04 16:32:17 +01:00
parent 1b03748f68
commit 8ba93dd21f
2 changed files with 10 additions and 8 deletions

View File

@ -3,10 +3,10 @@
% change this info string if making any custom modification
\ProvidesFile{sphinxlatexcontainers.sty}[2021/05/03 containers]
% The purpose of this file is to provide a dummy environment sphinxcontainer
% which will be inserted for every container directive. The container class
% The purpose of this file is to provide a dummy environment sphinxclass
% which will be inserted for each class in each container directive. The class
% name will be passed as the argument to the environment. User-defined
% formatting of directives can be achieved by renewing the definition of
% this environment, and branching on the value of the argument.
% formatting of directives can be achieved by renewing the definition of this
% environment, and branching on the value of the argument.
\newenvironment{sphinxcontainer}[1]{}{}
\newenvironment{sphinxclass}[1]{}{}

View File

@ -1976,11 +1976,13 @@ class LaTeXTranslator(SphinxTranslator):
def visit_container(self, node: Element) -> None:
classes = node.get('classes', [])
self.body.append(
'\n\\bgroup\\begin{sphinxcontainer}{%s}' % ' '.join(classes))
for c in classes:
self.body.append('\n\\bgroup\\begin{sphinxclass}{%s}' % c)
def depart_container(self, node: Element) -> None:
self.body.append('\n\\end{sphinxcontainer}\\egroup')
classes = node.get('classes', [])
for c in classes:
self.body.append('\n\\end{sphinxclass}\\egroup')
def visit_decoration(self, node: Element) -> None:
pass