Skip to content

Commit

Permalink
storage: handle no-alignment as default alignment
Browse files Browse the repository at this point in the history
Sphinx has been refactoring [1][2] its implementation to adjust the use
of the `default` alignment back to `None`, to follow with docutils.
Adjusting a series of lines which rely on the `default` assignment as a
hint for default alignment, where now an unset alignment applies the
default alignment as well.

[1]: sphinx-doc/sphinx#4550 (comment)
[2]: sphinx-doc/sphinx#8690

Signed-off-by: James Knight <james.d.knight@live.com>
  • Loading branch information
jdknight committed May 2, 2021
1 parent 4791db5 commit 50fd9ca
Showing 1 changed file with 12 additions and 15 deletions.
27 changes: 12 additions & 15 deletions sphinxcontrib/confluencebuilder/translator/storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -1260,14 +1260,12 @@ def visit_caption(self, node):
attribs['style'] = 'clear: both;'
self._figure_context.append('')

if 'align' in node.parent:
alignment = node.parent['align']

if alignment == 'default':
alignment = self._default_alignment
if alignment != 'left':
attribs['style'] = '{}text-align: {};'.format(
attribs['style'], alignment)
alignment = node.parent.get('align', 'default')
if alignment == 'default':
alignment = self._default_alignment
if alignment != 'left':
attribs['style'] = '{}text-align: {};'.format(
attribs['style'], alignment)

self.body.append(self._start_tag(node, 'p', **attribs))
self.add_fignumber(node.parent)
Expand Down Expand Up @@ -1336,7 +1334,7 @@ def visit_image(self, node):
elif isinstance(node.parent, nodes.figure) and 'align' in node.parent:
alignment = node.parent['align']

if alignment == 'default':
if not alignment or alignment == 'default':
alignment = self._default_alignment

if alignment:
Expand Down Expand Up @@ -1413,12 +1411,11 @@ def depart_image(self, node):

def visit_legend(self, node):
attribs = {}
if 'align' in node.parent:
alignment = node.parent['align']
if alignment == 'default':
alignment = self._default_alignment
if alignment != 'left':
attribs['style'] = 'text-align: {};'.format(alignment)
alignment = node.parent.get('align', 'default')
if alignment == 'default':
alignment = self._default_alignment
if alignment != 'left':
attribs['style'] = 'text-align: {};'.format(alignment)

self.body.append(self._start_tag(node, 'div', **attribs))
self.context.append(self._end_tag(node))
Expand Down

0 comments on commit 50fd9ca

Please sign in to comment.