@@ -187,6 +187,9 @@ pandocToLaTeX options (Pandoc meta blocks) = do
187 $ defField "polyglossia-otherlangs"
187 $ defField "polyglossia-otherlangs"
188 (maybe [] (map $ fst . toPolyglossia . splitBy (=='-')) $
188 (maybe [] (map $ fst . toPolyglossia . splitBy (=='-')) $
189 getField "otherlangs" context)
189 getField "otherlangs" context)
190+ $ defField "latex-dir-rtl" (case (getField "dir" context)::Maybe String of
190 $ context
193 $ context
191 return $ if writerStandalone options
194 return $ if writerStandalone options
192 then renderTemplate' template context'
195 then renderTemplate' template context'
@@ -323,14 +326,19 @@ isLineBreakOrSpace _ = False
323blockToLaTeX :: Block -- ^ Block to convert
326blockToLaTeX :: Block -- ^ Block to convert
324 -> State WriterState Doc
327 -> State WriterState Doc
325blockToLaTeX Null = return empty
328blockToLaTeX Null = return empty
326−blockToLaTeX (Div (identifier,classes,_) bs) = do
329+blockToLaTeX (Div (identifier,classes,kvs) bs) = do
327 beamer <- writerBeamer `fmap` gets stOptions
330 beamer <- writerBeamer `fmap` gets stOptions
328 ref <- toLabel identifier
331 ref <- toLabel identifier
329 let linkAnchor = if null identifier
332 let linkAnchor = if null identifier
330 then empty
333 then empty
331 else "\\hyperdef{}" <> braces (text ref) <>
334 else "\\hyperdef{}" <> braces (text ref) <>
332 braces ("\\label" <> braces (text ref))
335 braces ("\\label" <> braces (text ref))
333− contents <- blockListToLaTeX bs
336+ contents' <- blockListToLaTeX bs
337+ let align dir = inCmd "begin" dir $$ contents' $$ inCmd "end" dir
338+ let contents = case lookup "dir" kvs of
339+ Just "rtl" -> align "RTL"
340+ Just "ltr" -> align "LTR"
334 if beamer && "notes" `elem` classes -- speaker notes
342 if beamer && "notes" `elem` classes -- speaker notes
335 then return $ "\\note" <> braces contents
343 then return $ "\\note" <> braces contents
336 else return (linkAnchor $$ contents)
344 else return (linkAnchor $$ contents)
@@ -727,10 +735,12 @@ isQuoted _ = False
727-- | Convert inline element to LaTeX
735-- | Convert inline element to LaTeX
728inlineToLaTeX :: Inline -- ^ Inline to convert
736inlineToLaTeX :: Inline -- ^ Inline to convert
729 -> State WriterState Doc
737 -> State WriterState Doc
730−inlineToLaTeX (Span (id',classes,_) ils) = do
738+inlineToLaTeX (Span (id',classes,kvs) ils) = do
731 let noEmph = "csl-no-emph" `elem` classes
739 let noEmph = "csl-no-emph" `elem` classes
732 let noStrong = "csl-no-strong" `elem` classes
740 let noStrong = "csl-no-strong" `elem` classes
733 let noSmallCaps = "csl-no-smallcaps" `elem` classes
741 let noSmallCaps = "csl-no-smallcaps" `elem` classes
742+ let rtl = ("dir","rtl") `elem` kvs
743+ let ltr = ("dir","ltr") `elem` kvs
734 ref <- toLabel id'
744 ref <- toLabel id'
735 let linkAnchor = if null id'
745 let linkAnchor = if null id'
736 then empty
746 then empty
@@ -740,7 +750,9 @@ inlineToLaTeX (Span (id',classes,_) ils) = do
740 ((if noEmph then inCmd "textup" else id) .
750 ((if noEmph then inCmd "textup" else id) .
741 (if noStrong then inCmd "textnormal" else id) .
751 (if noStrong then inCmd "textnormal" else id) .
742 (if noSmallCaps then inCmd "textnormal" else id) .
752 (if noSmallCaps then inCmd "textnormal" else id) .
753+ (if rtl then inCmd "RL" else id) .
754+ (if ltr then inCmd "LR" else id) .
743− (if not (noEmph || noStrong || noSmallCaps)
755+ (if not (noEmph || noStrong || noSmallCaps || rtl || ltr)
744 then braces
756 then braces
745 else id)) `fmap` inlineListToLaTeX ils
757 else id)) `fmap` inlineListToLaTeX ils
746inlineToLaTeX (Emph lst) =
758inlineToLaTeX (Emph lst) =