@@ -377,6 +377,7 @@ shouldEscapeString s = do
377 "::" `isInfixOf` s ||
377 "::" `isInfixOf` s ||
378 "~~" `isInfixOf` s ||
378 "~~" `isInfixOf` s ||
379 "[[" `isInfixOf` s ||
379 "[[" `isInfixOf` s ||
380+ ">>>" `isInfixOf` s ||
380 ("]" `isInfixOf` s && insideLink) ||
381 ("]" `isInfixOf` s && insideLink) ||
381 containsNotes '[' ']' s ||
382 containsNotes '[' ']' s ||
382 containsNotes '{' '}' s
383 containsNotes '{' '}' s
@@ -412,7 +413,7 @@ removeKeyValues :: Inline -> Inline
412removeKeyValues (Code (i, cls, _) xs) = Code (i, cls, []) xs
413removeKeyValues (Code (i, cls, _) xs) = Code (i, cls, []) xs
413-- Do not remove attributes from Link
414-- Do not remove attributes from Link
414-- Do not remove attributes, such as "width", from Image
415-- 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
416removeKeyValues x = x
417removeKeyValues x = x
418normalizeInlineList :: [Inline] -> [Inline]
419normalizeInlineList :: [Inline] -> [Inline]
@@ -682,14 +683,17 @@ inlineToMuse (Note contents) = do
682 n <- gets stNoteNum
683 n <- gets stNoteNum
683 let ref = show $ n + length notes
684 let ref = show $ n + length notes
684 return $ "[" <> text ref <> "]"
685 return $ "[" <> text ref <> "]"
685−inlineToMuse (Span (anchor,names,_) inlines) = do
686+inlineToMuse (Span (anchor,names,kvs) inlines) = do
686 contents <- inlineListToMuse inlines
687 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)
687 let anchorDoc = if null anchor
692 let anchorDoc = if null anchor
688 then mempty
693 then mempty
689 else text ('#':anchor) <> space
694 else text ('#':anchor) <> space
690 modify $ \st -> st { stUseTags = False }
695 modify $ \st -> st { stUseTags = False }
691 return $ anchorDoc <> (if null inlines && not (null anchor)
696 return $ anchorDoc <> (if null inlines && not (null anchor)
692 then mempty
697 then mempty
693− else (if null names
698+ else (if null names then (if hasDir then contents' else "<class>" <> contents' <> "</class>")
695− else "<class name=\"" <> text (head names) <> "\">") <> contents <> "</class>")
699+ else "<class name=\"" <> text (head names) <> "\">" <> contents' <> "</class>"))