aboutsummaryrefslogtreecommitdiff
path: root/src/Text/Pandoc/Readers
diff options
context:
space:
mode:
Diffstat (limited to 'src/Text/Pandoc/Readers')
-rw-r--r--src/Text/Pandoc/Readers/Odt/ContentReader.hs19
-rw-r--r--src/Text/Pandoc/Readers/Odt/StyleReader.hs27
2 files changed, 36 insertions, 10 deletions
diff --git a/src/Text/Pandoc/Readers/Odt/ContentReader.hs b/src/Text/Pandoc/Readers/Odt/ContentReader.hs
index 2672b01ef..0df86e2a5 100644
--- a/src/Text/Pandoc/Readers/Odt/ContentReader.hs
+++ b/src/Text/Pandoc/Readers/Odt/ContentReader.hs
@@ -381,9 +381,9 @@ getParaModifier :: Style -> ParaModifier
getParaModifier Style{..} | Just props <- paraProperties styleProperties
, isBlockQuote (indentation props)
(margin_left props)
- = blockQuote
+ = pageBreakMaybe (paraProperties styleProperties) blockQuote
| otherwise
- = id
+ = pageBreakMaybe (paraProperties styleProperties) id
where
isBlockQuote mIndent mMargin
| LengthValueMM indent <- mIndent
@@ -408,7 +408,19 @@ getParaModifier Style{..} | Just props <- paraProperties styleProperties
| otherwise
= False
-
+ pageBreakMaybe :: Maybe ParaProperties -> ParaModifier -> ParaModifier
+ pageBreakMaybe (Just props) modifier = insertPageBreak (page_break props) modifier
+ pageBreakMaybe Nothing modifier = modifier
+
+ insertPageBreak :: ParaBreak -> ParaModifier -> ParaModifier
+ insertPageBreak PageAfter modifier =
+ \x -> (fromList (toList (modifier x) ++ [Para (toList pageBreak)]))
+ insertPageBreak PageBefore modifier =
+ \x -> (fromList (Para (toList pageBreak) : toList (modifier x)))
+ insertPageBreak PageBoth modifier =
+ \x -> (fromList ((Para (toList pageBreak) : toList (modifier x)) ++ [Para (toList pageBreak)]))
+ insertPageBreak _ modifier =
+ modifier
--
constructPara :: OdtReaderSafe Blocks Blocks -> OdtReaderSafe Blocks Blocks
constructPara reader = proc blocks -> do
@@ -894,7 +906,6 @@ read_reference_ref = matchingElement NsText "reference-ref"
$ maybeInAnchorRef
<<< matchChildContent [] read_plain_text
-
----------------------
-- Entry point
----------------------
diff --git a/src/Text/Pandoc/Readers/Odt/StyleReader.hs b/src/Text/Pandoc/Readers/Odt/StyleReader.hs
index 26ba6df82..cd31f50a8 100644
--- a/src/Text/Pandoc/Readers/Odt/StyleReader.hs
+++ b/src/Text/Pandoc/Readers/Odt/StyleReader.hs
@@ -43,6 +43,7 @@ module Text.Pandoc.Readers.Odt.StyleReader
, TextProperties (..)
, ParaProperties (..)
, VerticalTextPosition (..)
+, ParaBreak (..)
, ListItemNumberFormat (..)
, ListLevel
, ListStyle (..)
@@ -273,6 +274,7 @@ instance Default TextProperties where
data ParaProperties = PropP { paraNumbering :: ParaNumbering
, indentation :: LengthOrPercent
, margin_left :: LengthOrPercent
+ , page_break :: ParaBreak
}
deriving ( Eq, Show )
@@ -280,6 +282,7 @@ instance Default ParaProperties where
def = PropP { paraNumbering = NumberingNone
, indentation = def
, margin_left = def
+ , page_break = AutoNone
}
----
@@ -314,6 +317,9 @@ instance Lookupable UnderlineMode where
data ParaNumbering = NumberingNone | NumberingKeep | NumberingRestart Int
deriving ( Eq, Show )
+data ParaBreak = AutoNone | PageBefore | PageAfter | PageBoth
+ deriving ( Eq, Show )
+
data LengthOrPercent = LengthValueMM Int | PercentValue Int
deriving ( Eq, Show )
@@ -533,16 +539,20 @@ readLineMode modeAttr styleAttr = proc x -> do
readParaProperties :: StyleReader _x ParaProperties
readParaProperties =
executeIn NsStyle "paragraph-properties" $ liftAsSuccess
- ( liftA3 PropP
+ ( liftA4 PropP
( liftA2 readNumbering
- ( isSet' NsText "number-lines" )
- ( readAttr' NsText "line-number" )
+ ( isSet' NsText "number-lines" )
+ ( readAttr' NsText "line-number" )
)
( liftA2 readIndentation
- ( isSetWithDefault NsStyle "auto-text-indent" False )
- ( getAttr NsXSL_FO "text-indent" )
+ ( isSetWithDefault NsStyle "auto-text-indent" False )
+ ( getAttr NsXSL_FO "text-indent" )
+ )
+ ( getAttr NsXSL_FO "margin-left" )
+ ( liftA2 readPageBreak
+ ( findAttrWithDefault NsXSL_FO "break-before" "auto" )
+ ( findAttrWithDefault NsXSL_FO "break-after" "auto" )
)
- ( getAttr NsXSL_FO "margin-left" )
)
where readNumbering (Just True) (Just n) = NumberingRestart n
readNumbering (Just True) _ = NumberingKeep
@@ -551,6 +561,11 @@ readParaProperties =
readIndentation False indent = indent
readIndentation True _ = def
+ readPageBreak "page" "page" = PageBoth
+ readPageBreak "page" _ = PageBefore
+ readPageBreak _ "page" = PageAfter
+ readPageBreak _ _ = AutoNone
+
----
-- List styles
----