diff options
author | Alexander Krotov <ilabdsf@gmail.com> | 2019-07-13 20:54:26 +0300 |
---|---|---|
committer | Alexander Krotov <ilabdsf@gmail.com> | 2019-07-14 18:22:52 +0300 |
commit | 0713cb65bc6fcea0c950d1afcdfdce412a8b56d4 (patch) | |
tree | 2b611ce16095dcf84db75c75eda22e1762ba71ef /src/Text/Pandoc/Writers | |
parent | f6c92c7523a4070f13fbf193ef80ad7ac63f6693 (diff) | |
download | pandoc-0713cb65bc6fcea0c950d1afcdfdce412a8b56d4.tar.gz |
Muse: add RTL support
Closes #5551
Diffstat (limited to 'src/Text/Pandoc/Writers')
-rw-r--r-- | src/Text/Pandoc/Writers/Muse.hs | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/src/Text/Pandoc/Writers/Muse.hs b/src/Text/Pandoc/Writers/Muse.hs index c03fd0c1a..ec03d6292 100644 --- a/src/Text/Pandoc/Writers/Muse.hs +++ b/src/Text/Pandoc/Writers/Muse.hs @@ -377,6 +377,7 @@ shouldEscapeString s = do "::" `isInfixOf` s || "~~" `isInfixOf` s || "[[" `isInfixOf` s || + ">>>" `isInfixOf` s || ("]" `isInfixOf` s && insideLink) || containsNotes '[' ']' s || containsNotes '{' '}' s @@ -412,7 +413,7 @@ removeKeyValues :: Inline -> Inline removeKeyValues (Code (i, cls, _) xs) = Code (i, cls, []) xs -- Do not remove attributes from Link -- Do not remove attributes, such as "width", from Image -removeKeyValues (Span (i, cls, _) xs) = Span (i, cls, []) xs +-- Do not remove attributes, such as "dir", from Span removeKeyValues x = x normalizeInlineList :: [Inline] -> [Inline] @@ -682,14 +683,17 @@ inlineToMuse (Note contents) = do n <- gets stNoteNum let ref = show $ n + length notes return $ "[" <> text ref <> "]" -inlineToMuse (Span (anchor,names,_) inlines) = do +inlineToMuse (Span (anchor,names,kvs) inlines) = do contents <- inlineListToMuse inlines + let (contents', hasDir) = case lookup "dir" kvs of + Just "rtl" -> ("<<<" <> contents <> ">>>", True) + Just "ltr" -> (">>>" <> contents <> "<<<", True) + _ -> (contents, False) let anchorDoc = if null anchor then mempty else text ('#':anchor) <> space modify $ \st -> st { stUseTags = False } return $ anchorDoc <> (if null inlines && not (null anchor) then mempty - else (if null names - then "<class>" - else "<class name=\"" <> text (head names) <> "\">") <> contents <> "</class>") + else (if null names then (if hasDir then contents' else "<class>" <> contents' <> "</class>") + else "<class name=\"" <> text (head names) <> "\">" <> contents' <> "</class>")) |