@@ -377,6 +377,7 @@ shouldEscapeString s = do
377377 "::" `isInfixOf` s ||
378378 "~~" `isInfixOf` s ||
379379 "[[" `isInfixOf` s ||
380+ ">>>" `isInfixOf` s ||
380381 ("]" `isInfixOf` s && insideLink) ||
381382 containsNotes '[' ']' s ||
382383 containsNotes '{' '}' s
@@ -412,7 +413,7 @@ removeKeyValues :: Inline -> Inline
412413removeKeyValues (Code (i, cls, _) xs) = Code (i, cls, []) xs
413414-- Do not remove attributes from Link
414415-- Do not remove attributes, such as "width", from Image
415−removeKeyValues (Span (i, cls, _) xs) = Span (i, cls, []) xs
416+-- Do not remove attributes, such as "dir", from Span
416417removeKeyValues x = x
417418
418419normalizeInlineList :: [Inline] -> [Inline]
@@ -682,14 +683,17 @@ inlineToMuse (Note contents) = do
682683 n <- gets stNoteNum
683684 let ref = show $ n + length notes
684685 return $ "[" <> text ref <> "]"
685−inlineToMuse (Span (anchor,names,_) inlines) = do
686+inlineToMuse (Span (anchor,names,kvs) inlines) = do
686687 contents <- inlineListToMuse inlines
688+ let (contents', hasDir) = case lookup "dir" kvs of
689+ Just "rtl" -> ("<<<" <> contents <> ">>>", True)
690+ Just "ltr" -> (">>>" <> contents <> "<<<", True)
691+ _ -> (contents, False)
687692 let anchorDoc = if null anchor
688693 then mempty
689694 else text ('#':anchor) <> space
690695 modify $ \st -> st { stUseTags = False }
691696 return $ anchorDoc <> (if null inlines && not (null anchor)
692697 then mempty
693− else (if null names
694− then "<class>"
695− else "<class name=\"" <> text (head names) <> "\">") <> contents <> "</class>")
698+ else (if null names then (if hasDir then contents' else "<class>" <> contents' <> "</class>")
699+ else "<class name=\"" <> text (head names) <> "\">" <> contents' <> "</class>"))