@@ -40,7 +40,7 @@ import Text.Pandoc.Options
4040import Text.Pandoc.Parsing hiding (blankline, blanklines, char, space)
4141import Data.Maybe (fromMaybe)
4242import Data.List ( group, stripPrefix, find, intersperse, transpose, sortBy )
43−import Data.Char ( isSpace, isPunctuation )
43+import Data.Char ( isSpace, isPunctuation, ord, chr )
4444import Data.Ord ( comparing )
4545import Text.Pandoc.Pretty
4646import Control.Monad.State
@@ -775,14 +775,25 @@ inlineToMarkdown opts (Superscript lst) = do
775775 then "^" <> contents <> "^"
776776 else if isEnabled Ext_raw_html opts
777777 then "<sup>" <> contents <> "</sup>"
778− else contents
778+ else case (render Nothing contents) of
779+ ds | all (\d -> d >= '0' && d <= '9') ds
780+ -> text (map toSuperscript ds)
781+ _ -> contents
782+ where toSuperscript '1' = '\x00B9'
783+ toSuperscript '2' = '\x00B2'
784+ toSuperscript '3' = '\x00B3'
785+ toSuperscript c = chr (0x2070 + (ord c - 48))
779786inlineToMarkdown opts (Subscript lst) = do
780787 contents <- inlineListToMarkdown opts $ walk escapeSpaces lst
781788 return $ if isEnabled Ext_subscript opts
782789 then "~" <> contents <> "~"
783790 else if isEnabled Ext_raw_html opts
784791 then "<sub>" <> contents <> "</sub>"
785− else contents
792+ else case (render Nothing contents) of
793+ ds | all (\d -> d >= '0' && d <= '9') ds
794+ -> text (map toSubscript ds)
795+ _ -> contents
796+ where toSubscript c = chr (0x2080 + (ord c - 48))
786797inlineToMarkdown opts (SmallCaps lst) = do
787798 plain <- gets stPlain
788799 if not plain &&