{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE ViewPatterns #-}
module Text.TeXMath.Writers.Pandoc (writePandoc)
where
import Text.Pandoc.Definition
import qualified Data.Text as T
import Text.TeXMath.Unicode.ToUnicode
import Text.TeXMath.Types
import Text.TeXMath.Shared (getSpaceChars)
writePandoc :: DisplayType
-> [Exp]
-> Maybe [Inline]
writePandoc :: DisplayType -> [Exp] -> Maybe [Inline]
writePandoc _ exps :: [Exp]
exps = TextType -> [Exp] -> Maybe [Inline]
expsToInlines TextType
TextNormal [Exp]
exps
expsToInlines :: TextType -> [Exp] -> Maybe [Inline]
expsToInlines :: TextType -> [Exp] -> Maybe [Inline]
expsToInlines tt :: TextType
tt xs :: [Exp]
xs = do
[[Inline]]
res <- (Exp -> Maybe [Inline]) -> [Exp] -> Maybe [[Inline]]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
mapM (TextType -> Exp -> Maybe [Inline]
expToInlines TextType
tt) ([Exp] -> [Exp]
addSpaces [Exp]
xs)
[Inline] -> Maybe [Inline]
forall (m :: * -> *) a. Monad m => a -> m a
return ([[Inline]] -> [Inline]
forall (t :: * -> *) a. Foldable t => t [a] -> [a]
concat [[Inline]]
res)
addSpaces :: [Exp] -> [Exp]
addSpaces :: [Exp] -> [Exp]
addSpaces (ESymbol t1 :: TeXSymbolType
t1 s1 :: Text
s1 : ESpace r :: Rational
r : xs :: [Exp]
xs)
= TeXSymbolType -> Text -> Exp
ESymbol TeXSymbolType
t1 Text
s1 Exp -> [Exp] -> [Exp]
forall a. a -> [a] -> [a]
: Rational -> Exp
ESpace Rational
r Exp -> [Exp] -> [Exp]
forall a. a -> [a] -> [a]
: [Exp] -> [Exp]
addSpaces [Exp]
xs
addSpaces (ESymbol t1 :: TeXSymbolType
t1 s1 :: Text
s1 : xs :: [Exp]
xs)
| TeXSymbolType
t1 TeXSymbolType -> [TeXSymbolType] -> Bool
forall (t :: * -> *) a. (Foldable t, Eq a) => a -> t a -> Bool
`notElem` [TeXSymbolType
Bin, TeXSymbolType
Op, TeXSymbolType
Rel, TeXSymbolType
Open, TeXSymbolType
Pun]
= TeXSymbolType -> Text -> Exp
ESymbol TeXSymbolType
t1 Text
s1 Exp -> [Exp] -> [Exp]
forall a. a -> [a] -> [a]
: [Exp] -> [Exp]
addSpaces [Exp]
xs
addSpaces (ESymbol t1 :: TeXSymbolType
t1 s1 :: Text
s1 : ESymbol Pun s2 :: Text
s2 : xs :: [Exp]
xs)
= TeXSymbolType -> Text -> Exp
ESymbol TeXSymbolType
t1 Text
s1 Exp -> [Exp] -> [Exp]
forall a. a -> [a] -> [a]
: TeXSymbolType -> Text -> Exp
ESymbol TeXSymbolType
Pun Text
s2 Exp -> [Exp] -> [Exp]
forall a. a -> [a] -> [a]
: [Exp] -> [Exp]
addSpaces [Exp]
xs
addSpaces (ESymbol t2 :: TeXSymbolType
t2 s2 :: Text
s2 : xs :: [Exp]
xs)
| Bool -> Bool
not ([Exp] -> Bool
forall (t :: * -> *) a. Foldable t => t a -> Bool
null [Exp]
xs)
= TeXSymbolType -> Exp -> [Exp]
addSpace TeXSymbolType
t2 (TeXSymbolType -> Text -> Exp
ESymbol TeXSymbolType
t2 Text
s2) [Exp] -> [Exp] -> [Exp]
forall a. [a] -> [a] -> [a]
++ [Exp] -> [Exp]
addSpaces [Exp]
xs
addSpaces (EMathOperator s :: Text
s : xs :: [Exp]
xs) =
Text -> Exp
EMathOperator Text
s Exp -> [Exp] -> [Exp]
forall a. a -> [a] -> [a]
: Exp
thinspace Exp -> [Exp] -> [Exp]
forall a. a -> [a] -> [a]
: [Exp] -> [Exp]
addSpaces [Exp]
xs
addSpaces (x :: Exp
x:xs :: [Exp]
xs) = Exp
x Exp -> [Exp] -> [Exp]
forall a. a -> [a] -> [a]
: [Exp] -> [Exp]
addSpaces [Exp]
xs
addSpaces [] = []
addSpace :: TeXSymbolType -> Exp -> [Exp]
addSpace :: TeXSymbolType -> Exp -> [Exp]
addSpace t :: TeXSymbolType
t x :: Exp
x =
case TeXSymbolType
t of
Bin -> [Exp
medspace, Exp
x, Exp
medspace]
Rel -> [Exp
widespace, Exp
x, Exp
widespace]
Pun -> [Exp
x, Exp
thinspace]
_ -> [Exp
x]
thinspace, medspace, widespace :: Exp
thinspace :: Exp
thinspace = TextType -> Text -> Exp
EText TextType
TextNormal "\x2006"
medspace :: Exp
medspace = TextType -> Text -> Exp
EText TextType
TextNormal "\x2005"
widespace :: Exp
widespace = TextType -> Text -> Exp
EText TextType
TextNormal "\x2004"
renderStr :: TextType -> T.Text -> [Inline]
renderStr :: TextType -> Text -> [Inline]
renderStr _ "" = []
renderStr tt :: TextType
tt s :: Text
s =
case TextType
tt of
TextNormal -> [Text -> Inline
Str Text
s]
TextBold -> [[Inline] -> Inline
Strong [Text -> Inline
Str Text
s]]
TextItalic -> [[Inline] -> Inline
Emph [Text -> Inline
Str Text
s]]
TextMonospace -> [Attr -> Text -> Inline
Code Attr
nullAttr Text
s]
TextSansSerif -> [Text -> Inline
Str Text
s]
TextDoubleStruck -> [Text -> Inline
Str (Text -> Inline) -> Text -> Inline
forall a b. (a -> b) -> a -> b
$ TextType -> Text -> Text
toUnicode TextType
tt Text
s]
TextScript -> [Text -> Inline
Str (Text -> Inline) -> Text -> Inline
forall a b. (a -> b) -> a -> b
$ TextType -> Text -> Text
toUnicode TextType
tt Text
s]
TextFraktur -> [Text -> Inline
Str (Text -> Inline) -> Text -> Inline
forall a b. (a -> b) -> a -> b
$ TextType -> Text -> Text
toUnicode TextType
tt Text
s]
TextBoldItalic -> [[Inline] -> Inline
Strong [[Inline] -> Inline
Emph [Text -> Inline
Str Text
s]]]
TextSansSerifBold -> [[Inline] -> Inline
Strong [Text -> Inline
Str Text
s]]
TextBoldScript -> [[Inline] -> Inline
Strong [Text -> Inline
Str (Text -> Inline) -> Text -> Inline
forall a b. (a -> b) -> a -> b
$ TextType -> Text -> Text
toUnicode TextType
tt Text
s]]
TextBoldFraktur -> [[Inline] -> Inline
Strong [Text -> Inline
Str (Text -> Inline) -> Text -> Inline
forall a b. (a -> b) -> a -> b
$ TextType -> Text -> Text
toUnicode TextType
tt Text
s]]
TextSansSerifItalic -> [[Inline] -> Inline
Emph [Text -> Inline
Str Text
s]]
TextSansSerifBoldItalic -> [[Inline] -> Inline
Strong [[Inline] -> Inline
Emph [Text -> Inline
Str Text
s]]]
expToInlines :: TextType -> Exp -> Maybe [Inline]
expToInlines :: TextType -> Exp -> Maybe [Inline]
expToInlines tt :: TextType
tt (ENumber s :: Text
s) = [Inline] -> Maybe [Inline]
forall a. a -> Maybe a
Just ([Inline] -> Maybe [Inline]) -> [Inline] -> Maybe [Inline]
forall a b. (a -> b) -> a -> b
$ TextType -> Text -> [Inline]
renderStr TextType
tt Text
s
expToInlines TextNormal (EIdentifier s :: Text
s) = [Inline] -> Maybe [Inline]
forall a. a -> Maybe a
Just ([Inline] -> Maybe [Inline]) -> [Inline] -> Maybe [Inline]
forall a b. (a -> b) -> a -> b
$ TextType -> Text -> [Inline]
renderStr TextType
TextItalic Text
s
expToInlines tt :: TextType
tt (EIdentifier s :: Text
s) = [Inline] -> Maybe [Inline]
forall a. a -> Maybe a
Just ([Inline] -> Maybe [Inline]) -> [Inline] -> Maybe [Inline]
forall a b. (a -> b) -> a -> b
$ TextType -> Text -> [Inline]
renderStr TextType
tt Text
s
expToInlines tt :: TextType
tt (EMathOperator s :: Text
s) = [Inline] -> Maybe [Inline]
forall a. a -> Maybe a
Just ([Inline] -> Maybe [Inline]) -> [Inline] -> Maybe [Inline]
forall a b. (a -> b) -> a -> b
$ TextType -> Text -> [Inline]
renderStr TextType
tt Text
s
expToInlines tt :: TextType
tt (ESymbol _ s :: Text
s) = [Inline] -> Maybe [Inline]
forall a. a -> Maybe a
Just ([Inline] -> Maybe [Inline]) -> [Inline] -> Maybe [Inline]
forall a b. (a -> b) -> a -> b
$ TextType -> Text -> [Inline]
renderStr TextType
tt Text
s
expToInlines tt :: TextType
tt (EDelimited start :: Text
start end :: Text
end xs :: [InEDelimited]
xs) = do
[[Inline]]
xs' <- (InEDelimited -> Maybe [Inline])
-> [InEDelimited] -> Maybe [[Inline]]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
mapM ((Text -> Maybe [Inline])
-> (Exp -> Maybe [Inline]) -> InEDelimited -> Maybe [Inline]
forall a c b. (a -> c) -> (b -> c) -> Either a b -> c
either ([Inline] -> Maybe [Inline]
forall (m :: * -> *) a. Monad m => a -> m a
return ([Inline] -> Maybe [Inline])
-> (Text -> [Inline]) -> Text -> Maybe [Inline]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TextType -> Text -> [Inline]
renderStr TextType
tt) (TextType -> Exp -> Maybe [Inline]
expToInlines TextType
tt)) [InEDelimited]
xs
[Inline] -> Maybe [Inline]
forall (m :: * -> *) a. Monad m => a -> m a
return ([Inline] -> Maybe [Inline]) -> [Inline] -> Maybe [Inline]
forall a b. (a -> b) -> a -> b
$ TextType -> Text -> [Inline]
renderStr TextType
tt Text
start [Inline] -> [Inline] -> [Inline]
forall a. [a] -> [a] -> [a]
++ [[Inline]] -> [Inline]
forall (t :: * -> *) a. Foldable t => t [a] -> [a]
concat [[Inline]]
xs' [Inline] -> [Inline] -> [Inline]
forall a. [a] -> [a] -> [a]
++ TextType -> Text -> [Inline]
renderStr TextType
tt Text
end
expToInlines tt :: TextType
tt (EGrouped xs :: [Exp]
xs) = TextType -> [Exp] -> Maybe [Inline]
expsToInlines TextType
tt [Exp]
xs
expToInlines _ (EStyled tt' :: TextType
tt' xs :: [Exp]
xs) = TextType -> [Exp] -> Maybe [Inline]
expsToInlines TextType
tt' [Exp]
xs
expToInlines _ (ESpace n :: Rational
n) = [Inline] -> Maybe [Inline]
forall a. a -> Maybe a
Just [Text -> Inline
Str (Text -> Inline) -> Text -> Inline
forall a b. (a -> b) -> a -> b
$ Rational -> Text
getSpaceChars Rational
n]
expToInlines _ (ESqrt _) = Maybe [Inline]
forall a. Maybe a
Nothing
expToInlines _ (ERoot _ _) = Maybe [Inline]
forall a. Maybe a
Nothing
expToInlines _ (EFraction _ _ _) = Maybe [Inline]
forall a. Maybe a
Nothing
expToInlines tt :: TextType
tt (ESub x :: Exp
x y :: Exp
y) = do
[Inline]
x' <- TextType -> Exp -> Maybe [Inline]
expToInlines TextType
tt Exp
x
[Inline]
y' <- TextType -> Exp -> Maybe [Inline]
expToInlines TextType
tt Exp
y
[Inline] -> Maybe [Inline]
forall (m :: * -> *) a. Monad m => a -> m a
return ([Inline] -> Maybe [Inline]) -> [Inline] -> Maybe [Inline]
forall a b. (a -> b) -> a -> b
$ [Inline]
x' [Inline] -> [Inline] -> [Inline]
forall a. [a] -> [a] -> [a]
++ [[Inline] -> Inline
Subscript [Inline]
y']
expToInlines tt :: TextType
tt (ESuper x :: Exp
x y :: Exp
y) = do
[Inline]
x' <- TextType -> Exp -> Maybe [Inline]
expToInlines TextType
tt Exp
x
[Inline]
y' <- TextType -> Exp -> Maybe [Inline]
expToInlines TextType
tt Exp
y
[Inline] -> Maybe [Inline]
forall (m :: * -> *) a. Monad m => a -> m a
return ([Inline] -> Maybe [Inline]) -> [Inline] -> Maybe [Inline]
forall a b. (a -> b) -> a -> b
$ [Inline]
x' [Inline] -> [Inline] -> [Inline]
forall a. [a] -> [a] -> [a]
++ [[Inline] -> Inline
Superscript [Inline]
y']
expToInlines tt :: TextType
tt (ESubsup x :: Exp
x y :: Exp
y z :: Exp
z) = do
[Inline]
x' <- TextType -> Exp -> Maybe [Inline]
expToInlines TextType
tt Exp
x
[Inline]
y' <- TextType -> Exp -> Maybe [Inline]
expToInlines TextType
tt Exp
y
[Inline]
z' <- TextType -> Exp -> Maybe [Inline]
expToInlines TextType
tt Exp
z
[Inline] -> Maybe [Inline]
forall (m :: * -> *) a. Monad m => a -> m a
return ([Inline] -> Maybe [Inline]) -> [Inline] -> Maybe [Inline]
forall a b. (a -> b) -> a -> b
$ [Inline]
x' [Inline] -> [Inline] -> [Inline]
forall a. [a] -> [a] -> [a]
++ [[Inline] -> Inline
Subscript [Inline]
y'] [Inline] -> [Inline] -> [Inline]
forall a. [a] -> [a] -> [a]
++ [[Inline] -> Inline
Superscript [Inline]
z']
expToInlines _ (EText tt' :: TextType
tt' x :: Text
x) = [Inline] -> Maybe [Inline]
forall a. a -> Maybe a
Just ([Inline] -> Maybe [Inline]) -> [Inline] -> Maybe [Inline]
forall a b. (a -> b) -> a -> b
$ TextType -> Text -> [Inline]
renderStr TextType
tt' Text
x
expToInlines tt :: TextType
tt (EOver b :: Bool
b (EGrouped [EIdentifier (Text -> String
T.unpack -> [c :: Char
c])]) (ESymbol Accent (Text -> String
T.unpack -> [accent :: Char
accent]))) = TextType -> Exp -> Maybe [Inline]
expToInlines TextType
tt (Bool -> Exp -> Exp -> Exp
EOver Bool
b (Text -> Exp
EIdentifier (Text -> Exp) -> Text -> Exp
forall a b. (a -> b) -> a -> b
$ Char -> Text
T.singleton Char
c) (TeXSymbolType -> Text -> Exp
ESymbol TeXSymbolType
Accent (Text -> Exp) -> Text -> Exp
forall a b. (a -> b) -> a -> b
$ Char -> Text
T.singleton Char
accent))
expToInlines tt :: TextType
tt (EOver _ (EIdentifier (Text -> String
T.unpack -> [c :: Char
c])) (ESymbol Accent (Text -> String
T.unpack -> [accent :: Char
accent]))) =
case Char
accent of
'\x203E' -> [Inline] -> Maybe [Inline]
forall a. a -> Maybe a
Just ([Inline] -> Maybe [Inline]) -> [Inline] -> Maybe [Inline]
forall a b. (a -> b) -> a -> b
$ TextType -> Text -> [Inline]
renderStr TextType
tt' (Text -> [Inline]) -> Text -> [Inline]
forall a b. (a -> b) -> a -> b
$ String -> Text
T.pack [Char
c,'\x0304']
'\x0304' -> [Inline] -> Maybe [Inline]
forall a. a -> Maybe a
Just ([Inline] -> Maybe [Inline]) -> [Inline] -> Maybe [Inline]
forall a b. (a -> b) -> a -> b
$ TextType -> Text -> [Inline]
renderStr TextType
tt' (Text -> [Inline]) -> Text -> [Inline]
forall a b. (a -> b) -> a -> b
$ String -> Text
T.pack [Char
c,'\x0304']
'\x00B4' -> [Inline] -> Maybe [Inline]
forall a. a -> Maybe a
Just ([Inline] -> Maybe [Inline]) -> [Inline] -> Maybe [Inline]
forall a b. (a -> b) -> a -> b
$ TextType -> Text -> [Inline]
renderStr TextType
tt' (Text -> [Inline]) -> Text -> [Inline]
forall a b. (a -> b) -> a -> b
$ String -> Text
T.pack [Char
c,'\x0301']
'\x0301' -> [Inline] -> Maybe [Inline]
forall a. a -> Maybe a
Just ([Inline] -> Maybe [Inline]) -> [Inline] -> Maybe [Inline]
forall a b. (a -> b) -> a -> b
$ TextType -> Text -> [Inline]
renderStr TextType
tt' (Text -> [Inline]) -> Text -> [Inline]
forall a b. (a -> b) -> a -> b
$ String -> Text
T.pack [Char
c,'\x0301']
'\x0060' -> [Inline] -> Maybe [Inline]
forall a. a -> Maybe a
Just ([Inline] -> Maybe [Inline]) -> [Inline] -> Maybe [Inline]
forall a b. (a -> b) -> a -> b
$ TextType -> Text -> [Inline]
renderStr TextType
tt' (Text -> [Inline]) -> Text -> [Inline]
forall a b. (a -> b) -> a -> b
$ String -> Text
T.pack [Char
c,'\x0300']
'\x0300' -> [Inline] -> Maybe [Inline]
forall a. a -> Maybe a
Just ([Inline] -> Maybe [Inline]) -> [Inline] -> Maybe [Inline]
forall a b. (a -> b) -> a -> b
$ TextType -> Text -> [Inline]
renderStr TextType
tt' (Text -> [Inline]) -> Text -> [Inline]
forall a b. (a -> b) -> a -> b
$ String -> Text
T.pack [Char
c,'\x0300']
'\x02D8' -> [Inline] -> Maybe [Inline]
forall a. a -> Maybe a
Just ([Inline] -> Maybe [Inline]) -> [Inline] -> Maybe [Inline]
forall a b. (a -> b) -> a -> b
$ TextType -> Text -> [Inline]
renderStr TextType
tt' (Text -> [Inline]) -> Text -> [Inline]
forall a b. (a -> b) -> a -> b
$ String -> Text
T.pack [Char
c,'\x0306']
'\x0306' -> [Inline] -> Maybe [Inline]
forall a. a -> Maybe a
Just ([Inline] -> Maybe [Inline]) -> [Inline] -> Maybe [Inline]
forall a b. (a -> b) -> a -> b
$ TextType -> Text -> [Inline]
renderStr TextType
tt' (Text -> [Inline]) -> Text -> [Inline]
forall a b. (a -> b) -> a -> b
$ String -> Text
T.pack [Char
c,'\x0306']
'\x02C7' -> [Inline] -> Maybe [Inline]
forall a. a -> Maybe a
Just ([Inline] -> Maybe [Inline]) -> [Inline] -> Maybe [Inline]
forall a b. (a -> b) -> a -> b
$ TextType -> Text -> [Inline]
renderStr TextType
tt' (Text -> [Inline]) -> Text -> [Inline]
forall a b. (a -> b) -> a -> b
$ String -> Text
T.pack [Char
c,'\x030C']
'\x030C' -> [Inline] -> Maybe [Inline]
forall a. a -> Maybe a
Just ([Inline] -> Maybe [Inline]) -> [Inline] -> Maybe [Inline]
forall a b. (a -> b) -> a -> b
$ TextType -> Text -> [Inline]
renderStr TextType
tt' (Text -> [Inline]) -> Text -> [Inline]
forall a b. (a -> b) -> a -> b
$ String -> Text
T.pack [Char
c,'\x030C']
'.' -> [Inline] -> Maybe [Inline]
forall a. a -> Maybe a
Just ([Inline] -> Maybe [Inline]) -> [Inline] -> Maybe [Inline]
forall a b. (a -> b) -> a -> b
$ TextType -> Text -> [Inline]
renderStr TextType
tt' (Text -> [Inline]) -> Text -> [Inline]
forall a b. (a -> b) -> a -> b
$ String -> Text
T.pack [Char
c,'\x0307']
'\x0307' -> [Inline] -> Maybe [Inline]
forall a. a -> Maybe a
Just ([Inline] -> Maybe [Inline]) -> [Inline] -> Maybe [Inline]
forall a b. (a -> b) -> a -> b
$ TextType -> Text -> [Inline]
renderStr TextType
tt' (Text -> [Inline]) -> Text -> [Inline]
forall a b. (a -> b) -> a -> b
$ String -> Text
T.pack [Char
c,'\x0307']
'\x00B0' -> [Inline] -> Maybe [Inline]
forall a. a -> Maybe a
Just ([Inline] -> Maybe [Inline]) -> [Inline] -> Maybe [Inline]
forall a b. (a -> b) -> a -> b
$ TextType -> Text -> [Inline]
renderStr TextType
tt' (Text -> [Inline]) -> Text -> [Inline]
forall a b. (a -> b) -> a -> b
$ String -> Text
T.pack [Char
c,'\x030A']
'\x030A' -> [Inline] -> Maybe [Inline]
forall a. a -> Maybe a
Just ([Inline] -> Maybe [Inline]) -> [Inline] -> Maybe [Inline]
forall a b. (a -> b) -> a -> b
$ TextType -> Text -> [Inline]
renderStr TextType
tt' (Text -> [Inline]) -> Text -> [Inline]
forall a b. (a -> b) -> a -> b
$ String -> Text
T.pack [Char
c,'\x030A']
'\x20D7' -> [Inline] -> Maybe [Inline]
forall a. a -> Maybe a
Just ([Inline] -> Maybe [Inline]) -> [Inline] -> Maybe [Inline]
forall a b. (a -> b) -> a -> b
$ TextType -> Text -> [Inline]
renderStr TextType
tt' (Text -> [Inline]) -> Text -> [Inline]
forall a b. (a -> b) -> a -> b
$ String -> Text
T.pack [Char
c,'\x20D7']
'\x20D6' -> [Inline] -> Maybe [Inline]
forall a. a -> Maybe a
Just ([Inline] -> Maybe [Inline]) -> [Inline] -> Maybe [Inline]
forall a b. (a -> b) -> a -> b
$ TextType -> Text -> [Inline]
renderStr TextType
tt' (Text -> [Inline]) -> Text -> [Inline]
forall a b. (a -> b) -> a -> b
$ String -> Text
T.pack [Char
c,'\x20D6']
'\x005E' -> [Inline] -> Maybe [Inline]
forall a. a -> Maybe a
Just ([Inline] -> Maybe [Inline]) -> [Inline] -> Maybe [Inline]
forall a b. (a -> b) -> a -> b
$ TextType -> Text -> [Inline]
renderStr TextType
tt' (Text -> [Inline]) -> Text -> [Inline]
forall a b. (a -> b) -> a -> b
$ String -> Text
T.pack [Char
c,'\x0302']
'\x0302' -> [Inline] -> Maybe [Inline]
forall a. a -> Maybe a
Just ([Inline] -> Maybe [Inline]) -> [Inline] -> Maybe [Inline]
forall a b. (a -> b) -> a -> b
$ TextType -> Text -> [Inline]
renderStr TextType
tt' (Text -> [Inline]) -> Text -> [Inline]
forall a b. (a -> b) -> a -> b
$ String -> Text
T.pack [Char
c,'\x0302']
'~' -> [Inline] -> Maybe [Inline]
forall a. a -> Maybe a
Just ([Inline] -> Maybe [Inline]) -> [Inline] -> Maybe [Inline]
forall a b. (a -> b) -> a -> b
$ TextType -> Text -> [Inline]
renderStr TextType
tt' (Text -> [Inline]) -> Text -> [Inline]
forall a b. (a -> b) -> a -> b
$ String -> Text
T.pack [Char
c,'\x0303']
'\x0303' -> [Inline] -> Maybe [Inline]
forall a. a -> Maybe a
Just ([Inline] -> Maybe [Inline]) -> [Inline] -> Maybe [Inline]
forall a b. (a -> b) -> a -> b
$ TextType -> Text -> [Inline]
renderStr TextType
tt' (Text -> [Inline]) -> Text -> [Inline]
forall a b. (a -> b) -> a -> b
$ String -> Text
T.pack [Char
c,'\x0303']
_ -> Maybe [Inline]
forall a. Maybe a
Nothing
where tt' :: TextType
tt' = if TextType
tt TextType -> TextType -> Bool
forall a. Eq a => a -> a -> Bool
== TextType
TextNormal then TextType
TextItalic else TextType
tt
expToInlines tt :: TextType
tt (EScaled _ e :: Exp
e) = TextType -> Exp -> Maybe [Inline]
expToInlines TextType
tt Exp
e
expToInlines tt :: TextType
tt (EUnder convertible :: Bool
convertible b :: Exp
b e :: Exp
e)
| Bool
convertible = TextType -> Exp -> Maybe [Inline]
expToInlines TextType
tt (Exp -> Exp -> Exp
ESub Exp
b Exp
e)
| Bool
otherwise = Maybe [Inline]
forall a. Maybe a
Nothing
expToInlines tt :: TextType
tt (EOver convertible :: Bool
convertible b :: Exp
b e :: Exp
e)
| Bool
convertible = TextType -> Exp -> Maybe [Inline]
expToInlines TextType
tt (Exp -> Exp -> Exp
ESuper Exp
b Exp
e)
| Bool
otherwise = Maybe [Inline]
forall a. Maybe a
Nothing
expToInlines _ (EUnderover _ _ _ _) = Maybe [Inline]
forall a. Maybe a
Nothing
expToInlines _ (EPhantom _) = Maybe [Inline]
forall a. Maybe a
Nothing
expToInlines _ (EBoxed _) = Maybe [Inline]
forall a. Maybe a
Nothing
expToInlines _ (EArray _ _) = Maybe [Inline]
forall a. Maybe a
Nothing