From acf352331c43e44a5cbf63b4ff1502db056284af Mon Sep 17 00:00:00 2001 From: Jesse Rosenthal Date: Mon, 3 Oct 2016 18:29:25 -0400 Subject: Add a boolean flag to the setRTL function. At the toplevel we don't check to see if RTL is already set. --- src/Text/Pandoc/Writers/Docx.hs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'src/Text/Pandoc/Writers') diff --git a/src/Text/Pandoc/Writers/Docx.hs b/src/Text/Pandoc/Writers/Docx.hs index af3717b10..27bb4117b 100644 --- a/src/Text/Pandoc/Writers/Docx.hs +++ b/src/Text/Pandoc/Writers/Docx.hs @@ -797,7 +797,7 @@ blockToOpenXML opts (Div (ident,classes,kvs) bs) withParaPropM (pStyleM sty) $ blocksToOpenXML opts bs | Just "rtl" <- lookup "dir" kvs = do let kvs' = filter (("dir", "rtl")/=) kvs - setRTL $ blockToOpenXML opts (Div (ident,classes,kvs') bs) + setRTL False $ blockToOpenXML opts (Div (ident,classes,kvs') bs) | Just "ltr" <- lookup "dir" kvs = do let kvs' = filter (("dir", "ltr")/=) kvs setLTR $ blockToOpenXML opts (Div (ident,classes,kvs') bs) @@ -1042,7 +1042,7 @@ inlineToOpenXML opts (Span (ident,classes,kvs) ils) inlineToOpenXML opts (Span (ident,classes,kvs') ils) | Just "rtl" <- lookup "dir" kvs = do let kvs' = filter (("dir", "rtl")/=) kvs - setRTL $ inlineToOpenXML opts (Span (ident,classes,kvs') ils) + setRTL False $ inlineToOpenXML opts (Span (ident,classes,kvs') ils) | Just "ltr" <- lookup "dir" kvs = do let kvs' = filter (("dir", "ltr")/=) kvs setLTR $ inlineToOpenXML opts (Span (ident,classes,kvs') ils) @@ -1275,10 +1275,10 @@ fitToPage (x, y) pageWidth (pageWidth, floor $ ((fromIntegral pageWidth) / x) * y) | otherwise = (floor x, floor y) -setRTL :: WS a -> WS a -setRTL x = do +setRTL :: Bool -> WS a -> WS a +setRTL topLevel x = do isRTL <- asks envRTL - if isRTL + if isRTL && not topLevel then x else flip local x $ \env -> env { envRTL = True -- cgit v1.2.3