Skip to content

Commit 7b03425

Browse files
committed
Merge 'float' and 'sideways' (they are mutually exclusive)
1 parent d8edfe2 commit 7b03425

File tree

4 files changed

+15
-10
lines changed

4 files changed

+15
-10
lines changed

CHANGES.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ New Features:
88

99
* Support for sideways figures and tables; these are placed on a separate page,
1010
rotated 90 degrees. This is useful for figures/tables that do not fit within
11-
the page width.
11+
the page width. See the *float* style attribute.
1212
* The GroupedFlowables *same_page* style property forces all of a
1313
GroupedFlowables' content to be placed on the same page (if possible).
1414
* Support for OpenType fonts with non-BMP Unicode characters (PR #308 by James

src/rinoh/data/stylesheets/sphinx.rts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -645,7 +645,7 @@ horizontal_align=CENTER
645645
; sideways figures and tables
646646
[sideways float : Float(has_class='sideways')]
647647
base = NEXT_MATCH
648-
sideways = true
648+
float = sideways
649649

650650
[figure]
651651
space_above=10pt

src/rinoh/flowable.py

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -845,11 +845,16 @@ def render(self, container, descender, state, **kwargs):
845845
raise
846846

847847

848+
class FloatLocation(OptionSet):
849+
850+
values = (None, 'here', 'sideways')
851+
852+
848853
class FloatStyle(FlowableStyle):
849-
float = Attribute(Bool, False, 'Float the flowable to the top or bottom '
850-
'of the page')
851-
sideways = Attribute(Bool, False, 'Render the flowable onto a separate '
852-
'page, rotated 90 degrees')
854+
float = Attribute(FloatLocation, None, 'Float the flowable to the top or '
855+
'bottom of the current page, to a '
856+
'dedicated page, or sideways to a '
857+
'dedicated page')
853858

854859

855860
class Float(Flowable):
@@ -870,14 +875,14 @@ class Float(Flowable):
870875
def flow(self, container, last_descender, state=None, **kwargs):
871876
document = container.document
872877
id = self.get_id(document)
873-
if self.get_style('sideways', container):
878+
float = self.get_style('float', container)
879+
if float == FloatLocation.SIDEWAYS:
874880
if id not in document.registered_sideways_floats:
875881
document.add_sideways_float(self)
876882
state = CompletedFlowableState()
877883
self.page_break(container, state)
878884
return 0, 0, last_descender
879-
elif (self.get_style('float', container)
880-
and id not in document.floats):
885+
elif (float == FloatLocation.HERE and id not in document.floats):
881886
super().flow(container.float_space, None)
882887
document.floats.add(id)
883888
if not container.page.check_overflow():

tests_regression/rst/table_sideways.rts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,5 @@ base = sphinx_base14
44

55
[sideways-break float : Float(has_class='sideways-break')]
66
base = NEXT_MATCH
7-
sideways = true
7+
float = sideways
88
page_break = any

0 commit comments

Comments
 (0)