{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE OverloadedStrings #-}
module Text.Pandoc.Readers.LaTeX.SIunitx
( siunitxCommands )
where
import Text.Pandoc.Builder
( space,
subscript,
superscript,
emph,
str,
fromList,
text,
Many(Many, unMany),
Inline(Superscript, Str),
Inlines )
import Text.Pandoc.Readers.LaTeX.Parsing
( anyControlSeq,
braced,
bracketed,
controlSeq,
grouped,
isWordTok,
keyvals,
satisfyTok,
skipopts,
spaces1,
symbol,
untokenize,
LP )
import Text.Pandoc.TeX
( Tok(Tok), TokType(Word, CtrlSeq) )
import Text.Pandoc.Class.PandocMonad ( PandocMonad )
import Text.Pandoc.Parsing
( many1,
eof,
string,
satisfy,
skipMany,
option,
many,
char,
try,
skipMany1,
runParser,
Parsec )
import Control.Applicative ((<|>))
import Control.Monad (void)
import qualified Data.Map as M
import Data.Char (isDigit)
import Data.Text (Text)
import qualified Data.Text as T
import Data.List (intersperse)
import qualified Data.Sequence as Seq
import Text.Pandoc.Walk (walk)
siunitxCommands :: PandocMonad m
=> LP m Inlines -> M.Map Text (LP m Inlines)
siunitxCommands :: forall (m :: * -> *).
PandocMonad m =>
LP m (Many Inline) -> Map Text (LP m (Many Inline))
siunitxCommands LP m (Many Inline)
tok = [(Text, LP m (Many Inline))] -> Map Text (LP m (Many Inline))
forall k a. Ord k => [(k, a)] -> Map k a
M.fromList
[ (Text
"si", LP m (Many Inline) -> LP m (Many Inline)
forall (m :: * -> *).
PandocMonad m =>
LP m (Many Inline) -> LP m (Many Inline)
dosi LP m (Many Inline)
tok)
, (Text
"unit", LP m (Many Inline) -> LP m (Many Inline)
forall (m :: * -> *).
PandocMonad m =>
LP m (Many Inline) -> LP m (Many Inline)
dosi LP m (Many Inline)
tok)
, (Text
"SI", LP m (Many Inline) -> LP m (Many Inline)
forall (m :: * -> *).
PandocMonad m =>
LP m (Many Inline) -> LP m (Many Inline)
doSI LP m (Many Inline)
tok)
, (Text
"qty", LP m (Many Inline) -> LP m (Many Inline)
forall (m :: * -> *).
PandocMonad m =>
LP m (Many Inline) -> LP m (Many Inline)
doSI LP m (Many Inline)
tok)
, (Text
"SIrange", Bool -> LP m (Many Inline) -> LP m (Many Inline)
forall (m :: * -> *).
PandocMonad m =>
Bool -> LP m (Many Inline) -> LP m (Many Inline)
doSIrange Bool
True LP m (Many Inline)
tok)
, (Text
"qtyrange", Bool -> LP m (Many Inline) -> LP m (Many Inline)
forall (m :: * -> *).
PandocMonad m =>
Bool -> LP m (Many Inline) -> LP m (Many Inline)
doSIrange Bool
True LP m (Many Inline)
tok)
, (Text
"SIlist", LP m (Many Inline) -> LP m (Many Inline)
forall (m :: * -> *).
PandocMonad m =>
LP m (Many Inline) -> LP m (Many Inline)
doSIlist LP m (Many Inline)
tok)
, (Text
"qtylist", LP m (Many Inline) -> LP m (Many Inline)
forall (m :: * -> *).
PandocMonad m =>
LP m (Many Inline) -> LP m (Many Inline)
doSIlist LP m (Many Inline)
tok)
, (Text
"numrange", Bool -> LP m (Many Inline) -> LP m (Many Inline)
forall (m :: * -> *).
PandocMonad m =>
Bool -> LP m (Many Inline) -> LP m (Many Inline)
doSIrange Bool
False LP m (Many Inline)
tok)
, (Text
"numlist", LP m (Many Inline)
forall (m :: * -> *). PandocMonad m => LP m (Many Inline)
doSInumlist)
, (Text
"num", LP m (Many Inline)
forall (m :: * -> *). PandocMonad m => LP m (Many Inline)
doSInum)
, (Text
"ang", LP m (Many Inline)
forall (m :: * -> *). PandocMonad m => LP m (Many Inline)
doSIang)
]
dosi :: PandocMonad m => LP m Inlines -> LP m Inlines
dosi :: forall (m :: * -> *).
PandocMonad m =>
LP m (Many Inline) -> LP m (Many Inline)
dosi LP m (Many Inline)
tok = do
options <- [(Text, Text)]
-> ParsecT TokStream LaTeXState m [(Text, Text)]
-> ParsecT TokStream LaTeXState m [(Text, Text)]
forall s (m :: * -> *) t a u.
Stream s m t =>
a -> ParsecT s u m a -> ParsecT s u m a
option [] ParsecT TokStream LaTeXState m [(Text, Text)]
forall (m :: * -> *). PandocMonad m => LP m [(Text, Text)]
keyvals
grouped (siUnit options tok) <|> siUnit options tok
doSI :: PandocMonad m => LP m Inlines -> LP m Inlines
doSI :: forall (m :: * -> *).
PandocMonad m =>
LP m (Many Inline) -> LP m (Many Inline)
doSI LP m (Many Inline)
tok = do
LP m ()
forall (m :: * -> *). PandocMonad m => LP m ()
skipopts
value <- LP m (Many Inline)
forall (m :: * -> *). PandocMonad m => LP m (Many Inline)
doSInum
valueprefix <- option "" $ bracketed tok
unit <- dosi tok
return . mconcat $ [valueprefix,
emptyOr160 valueprefix,
value,
emptyOr160 unit,
unit]
doSInum :: PandocMonad m => LP m Inlines
doSInum :: forall (m :: * -> *). PandocMonad m => LP m (Many Inline)
doSInum = LP m ()
forall (m :: * -> *). PandocMonad m => LP m ()
skipopts LP m ()
-> ParsecT TokStream LaTeXState m (Many Inline)
-> ParsecT TokStream LaTeXState m (Many Inline)
forall a b.
ParsecT TokStream LaTeXState m a
-> ParsecT TokStream LaTeXState m b
-> ParsecT TokStream LaTeXState m b
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> (Text -> Many Inline
tonum (Text -> Many Inline) -> ([Tok] -> Text) -> [Tok] -> Many Inline
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [Tok] -> Text
untokenize ([Tok] -> Many Inline)
-> ParsecT TokStream LaTeXState m [Tok]
-> ParsecT TokStream LaTeXState m (Many Inline)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ParsecT TokStream LaTeXState m [Tok]
forall (m :: * -> *). PandocMonad m => LP m [Tok]
braced)
tonum :: Text -> Inlines
tonum :: Text -> Many Inline
tonum Text
value =
case Parsec Text () (Many Inline)
-> () -> String -> Text -> Either ParseError (Many Inline)
forall s t u a.
Stream s Identity t =>
Parsec s u a -> u -> String -> s -> Either ParseError a
runParser Parsec Text () (Many Inline)
parseNum () String
"" Text
value of
Left ParseError
_ -> Text -> Many Inline
text Text
value
Right Many Inline
num -> Many Inline
num
doSInumlist :: PandocMonad m => LP m Inlines
doSInumlist :: forall (m :: * -> *). PandocMonad m => LP m (Many Inline)
doSInumlist = do
LP m ()
forall (m :: * -> *). PandocMonad m => LP m ()
skipopts
xs <- (Text -> Many Inline) -> [Text] -> [Many Inline]
forall a b. (a -> b) -> [a] -> [b]
map Text -> Many Inline
tonum ([Text] -> [Many Inline])
-> ([Tok] -> [Text]) -> [Tok] -> [Many Inline]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. HasCallStack => Text -> Text -> [Text]
Text -> Text -> [Text]
T.splitOn Text
";" (Text -> [Text]) -> ([Tok] -> Text) -> [Tok] -> [Text]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [Tok] -> Text
untokenize ([Tok] -> [Many Inline])
-> ParsecT TokStream LaTeXState m [Tok]
-> ParsecT TokStream LaTeXState m [Many Inline]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ParsecT TokStream LaTeXState m [Tok]
forall (m :: * -> *). PandocMonad m => LP m [Tok]
braced
case xs of
[] -> Many Inline -> ParsecT TokStream LaTeXState m (Many Inline)
forall a. a -> ParsecT TokStream LaTeXState m a
forall (m :: * -> *) a. Monad m => a -> m a
return Many Inline
forall a. Monoid a => a
mempty
[Many Inline
x] -> Many Inline -> ParsecT TokStream LaTeXState m (Many Inline)
forall a. a -> ParsecT TokStream LaTeXState m a
forall (m :: * -> *) a. Monad m => a -> m a
return Many Inline
x
[Many Inline]
_ -> Many Inline -> ParsecT TokStream LaTeXState m (Many Inline)
forall a. a -> ParsecT TokStream LaTeXState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (Many Inline -> ParsecT TokStream LaTeXState m (Many Inline))
-> Many Inline -> ParsecT TokStream LaTeXState m (Many Inline)
forall a b. (a -> b) -> a -> b
$
[Many Inline] -> Many Inline
forall a. Monoid a => [a] -> a
mconcat (Many Inline -> [Many Inline] -> [Many Inline]
forall a. a -> [a] -> [a]
intersperse (Text -> Many Inline
str Text
"," Many Inline -> Many Inline -> Many Inline
forall a. Semigroup a => a -> a -> a
<> Many Inline
space) ([Many Inline] -> [Many Inline]
forall a. HasCallStack => [a] -> [a]
init [Many Inline]
xs)) Many Inline -> Many Inline -> Many Inline
forall a. Semigroup a => a -> a -> a
<>
Text -> Many Inline
text Text
", & " Many Inline -> Many Inline -> Many Inline
forall a. Semigroup a => a -> a -> a
<> [Many Inline] -> Many Inline
forall a. HasCallStack => [a] -> a
last [Many Inline]
xs
doSIlist :: PandocMonad m => LP m Inlines -> LP m Inlines
doSIlist :: forall (m :: * -> *).
PandocMonad m =>
LP m (Many Inline) -> LP m (Many Inline)
doSIlist LP m (Many Inline)
tok = do
options <- [(Text, Text)]
-> ParsecT TokStream LaTeXState m [(Text, Text)]
-> ParsecT TokStream LaTeXState m [(Text, Text)]
forall s (m :: * -> *) t a u.
Stream s m t =>
a -> ParsecT s u m a -> ParsecT s u m a
option [] ParsecT TokStream LaTeXState m [(Text, Text)]
forall (m :: * -> *). PandocMonad m => LP m [(Text, Text)]
keyvals
nums <- map tonum . T.splitOn ";" . untokenize <$> braced
unit <- grouped (siUnit options tok) <|> siUnit options tok
let xs = (Many Inline -> Many Inline) -> [Many Inline] -> [Many Inline]
forall a b. (a -> b) -> [a] -> [b]
map (Many Inline -> Many Inline -> Many Inline
forall a. Semigroup a => a -> a -> a
<> (Text -> Many Inline
str Text
"\xa0" Many Inline -> Many Inline -> Many Inline
forall a. Semigroup a => a -> a -> a
<> Many Inline
unit)) [Many Inline]
nums
case xs of
[] -> Many Inline -> LP m (Many Inline)
forall a. a -> ParsecT TokStream LaTeXState m a
forall (m :: * -> *) a. Monad m => a -> m a
return Many Inline
forall a. Monoid a => a
mempty
[Many Inline
x] -> Many Inline -> LP m (Many Inline)
forall a. a -> ParsecT TokStream LaTeXState m a
forall (m :: * -> *) a. Monad m => a -> m a
return Many Inline
x
[Many Inline]
_ -> Many Inline -> LP m (Many Inline)
forall a. a -> ParsecT TokStream LaTeXState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (Many Inline -> LP m (Many Inline))
-> Many Inline -> LP m (Many Inline)
forall a b. (a -> b) -> a -> b
$
[Many Inline] -> Many Inline
forall a. Monoid a => [a] -> a
mconcat (Many Inline -> [Many Inline] -> [Many Inline]
forall a. a -> [a] -> [a]
intersperse (Text -> Many Inline
str Text
"," Many Inline -> Many Inline -> Many Inline
forall a. Semigroup a => a -> a -> a
<> Many Inline
space) ([Many Inline] -> [Many Inline]
forall a. HasCallStack => [a] -> [a]
init [Many Inline]
xs)) Many Inline -> Many Inline -> Many Inline
forall a. Semigroup a => a -> a -> a
<>
Text -> Many Inline
text Text
", & " Many Inline -> Many Inline -> Many Inline
forall a. Semigroup a => a -> a -> a
<> [Many Inline] -> Many Inline
forall a. HasCallStack => [a] -> a
last [Many Inline]
xs
parseNum :: Parsec Text () Inlines
parseNum :: Parsec Text () (Many Inline)
parseNum = ([Many Inline] -> Many Inline
forall a. Monoid a => [a] -> a
mconcat ([Many Inline] -> Many Inline)
-> ParsecT Text () Identity [Many Inline]
-> Parsec Text () (Many Inline)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Parsec Text () (Many Inline)
-> ParsecT Text () Identity [Many Inline]
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m [a]
many Parsec Text () (Many Inline)
parseNumPart) Parsec Text () (Many Inline)
-> ParsecT Text () Identity () -> Parsec Text () (Many Inline)
forall a b.
ParsecT Text () Identity a
-> ParsecT Text () Identity b -> ParsecT Text () Identity a
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
<* ParsecT Text () Identity ()
forall s (m :: * -> *) t u.
(Stream s m t, Show t) =>
ParsecT s u m ()
eof
minus :: Text
minus :: Text
minus = Text
"\x2212"
hyphenToMinus :: Inline -> Inline
hyphenToMinus :: Inline -> Inline
hyphenToMinus (Str Text
t) = Text -> Inline
Str (HasCallStack => Text -> Text -> Text -> Text
Text -> Text -> Text -> Text
T.replace Text
"-" Text
minus Text
t)
hyphenToMinus Inline
x = Inline
x
parseNumPart :: Parsec Text () Inlines
parseNumPart :: Parsec Text () (Many Inline)
parseNumPart =
Parsec Text () (Many Inline)
parseDecimalNum Parsec Text () (Many Inline)
-> Parsec Text () (Many Inline) -> Parsec Text () (Many Inline)
forall a.
ParsecT Text () Identity a
-> ParsecT Text () Identity a -> ParsecT Text () Identity a
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|>
Parsec Text () (Many Inline)
parseComma Parsec Text () (Many Inline)
-> Parsec Text () (Many Inline) -> Parsec Text () (Many Inline)
forall a.
ParsecT Text () Identity a
-> ParsecT Text () Identity a -> ParsecT Text () Identity a
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|>
Parsec Text () (Many Inline)
parsePlusMinus Parsec Text () (Many Inline)
-> Parsec Text () (Many Inline) -> Parsec Text () (Many Inline)
forall a.
ParsecT Text () Identity a
-> ParsecT Text () Identity a -> ParsecT Text () Identity a
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|>
Parsec Text () (Many Inline)
parsePM Parsec Text () (Many Inline)
-> Parsec Text () (Many Inline) -> Parsec Text () (Many Inline)
forall a.
ParsecT Text () Identity a
-> ParsecT Text () Identity a -> ParsecT Text () Identity a
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|>
Parsec Text () (Many Inline)
parseI Parsec Text () (Many Inline)
-> Parsec Text () (Many Inline) -> Parsec Text () (Many Inline)
forall a.
ParsecT Text () Identity a
-> ParsecT Text () Identity a -> ParsecT Text () Identity a
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|>
Parsec Text () (Many Inline)
parseExp Parsec Text () (Many Inline)
-> Parsec Text () (Many Inline) -> Parsec Text () (Many Inline)
forall a.
ParsecT Text () Identity a
-> ParsecT Text () Identity a -> ParsecT Text () Identity a
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|>
Parsec Text () (Many Inline)
parseX Parsec Text () (Many Inline)
-> Parsec Text () (Many Inline) -> Parsec Text () (Many Inline)
forall a.
ParsecT Text () Identity a
-> ParsecT Text () Identity a -> ParsecT Text () Identity a
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|>
Parsec Text () (Many Inline)
parseSpace
where
parseDecimalNum, parsePlusMinus, parsePM,
parseComma, parseI, parseX,
parseExp, parseSpace :: Parsec Text () Inlines
parseDecimalNum :: Parsec Text () (Many Inline)
parseDecimalNum = Parsec Text () (Many Inline) -> Parsec Text () (Many Inline)
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try (Parsec Text () (Many Inline) -> Parsec Text () (Many Inline))
-> Parsec Text () (Many Inline) -> Parsec Text () (Many Inline)
forall a b. (a -> b) -> a -> b
$ do
pref <- Text
-> ParsecT Text () Identity Text -> ParsecT Text () Identity Text
forall s (m :: * -> *) t a u.
Stream s m t =>
a -> ParsecT s u m a -> ParsecT s u m a
option Text
forall a. Monoid a => a
mempty (ParsecT Text () Identity Text -> ParsecT Text () Identity Text)
-> ParsecT Text () Identity Text -> ParsecT Text () Identity Text
forall a b. (a -> b) -> a -> b
$ (Text
forall a. Monoid a => a
mempty Text
-> ParsecT Text () Identity Char -> ParsecT Text () Identity Text
forall a b.
a -> ParsecT Text () Identity b -> ParsecT Text () Identity a
forall (f :: * -> *) a b. Functor f => a -> f b -> f a
<$ Char -> ParsecT Text () Identity Char
forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
Char -> ParsecT s u m Char
char Char
'+') ParsecT Text () Identity Text
-> ParsecT Text () Identity Text -> ParsecT Text () Identity Text
forall a.
ParsecT Text () Identity a
-> ParsecT Text () Identity a -> ParsecT Text () Identity a
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> (Text
minus Text
-> ParsecT Text () Identity Char -> ParsecT Text () Identity Text
forall a b.
a -> ParsecT Text () Identity b -> ParsecT Text () Identity a
forall (f :: * -> *) a b. Functor f => a -> f b -> f a
<$ Char -> ParsecT Text () Identity Char
forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
Char -> ParsecT s u m Char
char Char
'-')
basenum' <- many1 (satisfy (\Char
c -> Char -> Bool
isDigit Char
c Bool -> Bool -> Bool
|| Char
c Char -> Char -> Bool
forall a. Eq a => a -> a -> Bool
== Char
'.'))
let basenum = Text
pref Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> String -> Text
T.pack
(case String
basenum' of
Char
'.':String
_ -> Char
'0'Char -> String -> String
forall a. a -> [a] -> [a]
:String
basenum'
String
_ -> String
basenum')
uncertainty <- option mempty $ T.pack <$> parseParens
if T.null uncertainty
then return $ str basenum
else return $ str $ basenum <> "\xa0\xb1\xa0" <>
let (_,ys) = T.break (=='.') basenum
in case (T.length ys - 1, T.length uncertainty) of
(Int
0,Int
_) -> Text
uncertainty
(Int
x,Int
y)
| Int
x Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
> Int
y -> Text
"0." Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Int -> Text -> Text
T.replicate (Int
x Int -> Int -> Int
forall a. Num a => a -> a -> a
- Int
y) Text
"0" Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<>
(Char -> Bool) -> Text -> Text
T.dropWhileEnd (Char -> Char -> Bool
forall a. Eq a => a -> a -> Bool
==Char
'0') Text
uncertainty
| Bool
otherwise -> Int -> Text -> Text
T.take (Int
y Int -> Int -> Int
forall a. Num a => a -> a -> a
- Int
x) Text
uncertainty Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<>
case (Char -> Bool) -> Text -> Text
T.dropWhileEnd (Char -> Char -> Bool
forall a. Eq a => a -> a -> Bool
==Char
'0')
(Int -> Text -> Text
T.drop (Int
y Int -> Int -> Int
forall a. Num a => a -> a -> a
- Int
x) Text
uncertainty) of
Text
t | Text -> Bool
T.null Text
t -> Text
forall a. Monoid a => a
mempty
| Bool
otherwise -> Text
"." Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
t
parseComma :: Parsec Text () (Many Inline)
parseComma = Text -> Many Inline
str Text
"." Many Inline
-> ParsecT Text () Identity Char -> Parsec Text () (Many Inline)
forall a b.
a -> ParsecT Text () Identity b -> ParsecT Text () Identity a
forall (f :: * -> *) a b. Functor f => a -> f b -> f a
<$ Char -> ParsecT Text () Identity Char
forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
Char -> ParsecT s u m Char
char Char
','
parsePlusMinus :: Parsec Text () (Many Inline)
parsePlusMinus = Text -> Many Inline
str Text
"\xa0\xb1\xa0" Many Inline
-> ParsecT Text () Identity String -> Parsec Text () (Many Inline)
forall a b.
a -> ParsecT Text () Identity b -> ParsecT Text () Identity a
forall (f :: * -> *) a b. Functor f => a -> f b -> f a
<$ ParsecT Text () Identity String -> ParsecT Text () Identity String
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try (String -> ParsecT Text () Identity String
forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
String -> ParsecT s u m String
string String
"+-")
parsePM :: Parsec Text () (Many Inline)
parsePM = Text -> Many Inline
str Text
"\xa0\xb1\xa0" Many Inline
-> ParsecT Text () Identity String -> Parsec Text () (Many Inline)
forall a b.
a -> ParsecT Text () Identity b -> ParsecT Text () Identity a
forall (f :: * -> *) a b. Functor f => a -> f b -> f a
<$ ParsecT Text () Identity String -> ParsecT Text () Identity String
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try (String -> ParsecT Text () Identity String
forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
String -> ParsecT s u m String
string String
"\\pm")
parseParens :: ParsecT Text u Identity String
parseParens =
Char -> ParsecT Text u Identity Char
forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
Char -> ParsecT s u m Char
char Char
'(' ParsecT Text u Identity Char
-> ParsecT Text u Identity String -> ParsecT Text u Identity String
forall a b.
ParsecT Text u Identity a
-> ParsecT Text u Identity b -> ParsecT Text u Identity b
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> ParsecT Text u Identity Char -> ParsecT Text u Identity String
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m [a]
many1 ((Char -> Bool) -> ParsecT Text u Identity Char
forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
(Char -> Bool) -> ParsecT s u m Char
satisfy (\Char
c -> Char -> Bool
isDigit Char
c Bool -> Bool -> Bool
|| Char
c Char -> Char -> Bool
forall a. Eq a => a -> a -> Bool
== Char
'.')) ParsecT Text u Identity String
-> ParsecT Text u Identity Char -> ParsecT Text u Identity String
forall a b.
ParsecT Text u Identity a
-> ParsecT Text u Identity b -> ParsecT Text u Identity a
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
<* Char -> ParsecT Text u Identity Char
forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
Char -> ParsecT s u m Char
char Char
')'
parseI :: Parsec Text () (Many Inline)
parseI = Text -> Many Inline
str Text
"i" Many Inline
-> ParsecT Text () Identity Char -> Parsec Text () (Many Inline)
forall a b.
a -> ParsecT Text () Identity b -> ParsecT Text () Identity a
forall (f :: * -> *) a b. Functor f => a -> f b -> f a
<$ Char -> ParsecT Text () Identity Char
forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
Char -> ParsecT s u m Char
char Char
'i'
parseX :: Parsec Text () (Many Inline)
parseX = Text -> Many Inline
str Text
"\xa0\xd7\xa0" Many Inline
-> ParsecT Text () Identity Char -> Parsec Text () (Many Inline)
forall a b.
a -> ParsecT Text () Identity b -> ParsecT Text () Identity a
forall (f :: * -> *) a b. Functor f => a -> f b -> f a
<$ Char -> ParsecT Text () Identity Char
forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
Char -> ParsecT s u m Char
char Char
'x'
parseExp :: Parsec Text () (Many Inline)
parseExp = (\Many Inline
n -> Text -> Many Inline
str (Text
"\xa0\xd7\xa0" Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
"10") Many Inline -> Many Inline -> Many Inline
forall a. Semigroup a => a -> a -> a
<> Many Inline -> Many Inline
superscript Many Inline
n)
(Many Inline -> Many Inline)
-> Parsec Text () (Many Inline) -> Parsec Text () (Many Inline)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (Char -> ParsecT Text () Identity Char
forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
Char -> ParsecT s u m Char
char Char
'e' ParsecT Text () Identity Char
-> Parsec Text () (Many Inline) -> Parsec Text () (Many Inline)
forall a b.
ParsecT Text () Identity a
-> ParsecT Text () Identity b -> ParsecT Text () Identity b
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> Parsec Text () (Many Inline)
parseDecimalNum)
parseSpace :: Parsec Text () (Many Inline)
parseSpace = Many Inline
forall a. Monoid a => a
mempty Many Inline
-> ParsecT Text () Identity () -> Parsec Text () (Many Inline)
forall a b.
a -> ParsecT Text () Identity b -> ParsecT Text () Identity a
forall (f :: * -> *) a b. Functor f => a -> f b -> f a
<$ ParsecT Text () Identity Char -> ParsecT Text () Identity ()
forall s (m :: * -> *) t u a.
Stream s m t =>
ParsecT s u m a -> ParsecT s u m ()
skipMany1 (Char -> ParsecT Text () Identity Char
forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
Char -> ParsecT s u m Char
char Char
' ')
doSIang :: PandocMonad m => LP m Inlines
doSIang :: forall (m :: * -> *). PandocMonad m => LP m (Many Inline)
doSIang = do
LP m ()
forall (m :: * -> *). PandocMonad m => LP m ()
skipopts
ps <- HasCallStack => Text -> Text -> [Text]
Text -> Text -> [Text]
T.splitOn Text
";" (Text -> [Text]) -> ([Tok] -> Text) -> [Tok] -> [Text]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [Tok] -> Text
untokenize ([Tok] -> [Text])
-> ParsecT TokStream LaTeXState m [Tok]
-> ParsecT TokStream LaTeXState m [Text]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ParsecT TokStream LaTeXState m [Tok]
forall (m :: * -> *). PandocMonad m => LP m [Tok]
braced
let dropPlus Text
t = case Text -> Maybe (Char, Text)
T.uncons Text
t of
Just (Char
'+',Text
t') -> Text
t'
Maybe (Char, Text)
_ -> Text
t
case ps ++ repeat "" of
(Text
d:Text
m:Text
s:[Text]
_) -> Many Inline -> ParsecT TokStream LaTeXState m (Many Inline)
forall a. a -> ParsecT TokStream LaTeXState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (Many Inline -> ParsecT TokStream LaTeXState m (Many Inline))
-> Many Inline -> ParsecT TokStream LaTeXState m (Many Inline)
forall a b. (a -> b) -> a -> b
$
(if Text -> Bool
T.null Text
d then Many Inline
forall a. Monoid a => a
mempty else Text -> Many Inline
str (Text -> Text
dropPlus Text
d) Many Inline -> Many Inline -> Many Inline
forall a. Semigroup a => a -> a -> a
<> Text -> Many Inline
str Text
"\xb0") Many Inline -> Many Inline -> Many Inline
forall a. Semigroup a => a -> a -> a
<>
(if Text -> Bool
T.null Text
m then Many Inline
forall a. Monoid a => a
mempty else Text -> Many Inline
str (Text -> Text
dropPlus Text
m) Many Inline -> Many Inline -> Many Inline
forall a. Semigroup a => a -> a -> a
<> Text -> Many Inline
str Text
"\x2032") Many Inline -> Many Inline -> Many Inline
forall a. Semigroup a => a -> a -> a
<>
(if Text -> Bool
T.null Text
s then Many Inline
forall a. Monoid a => a
mempty else Text -> Many Inline
str (Text -> Text
dropPlus Text
s) Many Inline -> Many Inline -> Many Inline
forall a. Semigroup a => a -> a -> a
<> Text -> Many Inline
str Text
"\x2033")
[Text]
_ -> Many Inline -> ParsecT TokStream LaTeXState m (Many Inline)
forall a. a -> ParsecT TokStream LaTeXState m a
forall (m :: * -> *) a. Monad m => a -> m a
return Many Inline
forall a. Monoid a => a
mempty
doSIrange :: PandocMonad m => Bool -> LP m Inlines -> LP m Inlines
doSIrange :: forall (m :: * -> *).
PandocMonad m =>
Bool -> LP m (Many Inline) -> LP m (Many Inline)
doSIrange Bool
includeUnits LP m (Many Inline)
tok = do
LP m ()
forall (m :: * -> *). PandocMonad m => LP m ()
skipopts
startvalue <- LP m (Many Inline)
forall (m :: * -> *). PandocMonad m => LP m (Many Inline)
doSInum
startvalueprefix <- option "" $ bracketed tok
stopvalue <- doSInum
stopvalueprefix <- option "" $ bracketed tok
unit <- if includeUnits
then dosi tok
else return mempty
return . mconcat $ [startvalueprefix,
emptyOr160 startvalueprefix,
startvalue,
emptyOr160 unit,
unit,
"\8211",
stopvalueprefix,
emptyOr160 stopvalueprefix,
stopvalue,
emptyOr160 unit,
unit]
emptyOr160 :: Inlines -> Inlines
emptyOr160 :: Many Inline -> Many Inline
emptyOr160 Many Inline
x = if Many Inline
x Many Inline -> Many Inline -> Bool
forall a. Eq a => a -> a -> Bool
== Many Inline
forall a. Monoid a => a
mempty then Many Inline
x else Text -> Many Inline
str Text
"\160"
siUnit :: forall m. PandocMonad m => [(Text,Text)] -> LP m Inlines -> LP m Inlines
siUnit :: forall (m :: * -> *).
PandocMonad m =>
[(Text, Text)] -> LP m (Many Inline) -> LP m (Many Inline)
siUnit [(Text, Text)]
options LP m (Many Inline)
tok = [Many Inline] -> Many Inline
forall a. Monoid a => [a] -> a
mconcat ([Many Inline] -> Many Inline)
-> ([Many Inline] -> [Many Inline]) -> [Many Inline] -> Many Inline
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Many Inline -> [Many Inline] -> [Many Inline]
forall a. a -> [a] -> [a]
intersperse (Text -> Many Inline
str Text
"\xa0") ([Many Inline] -> Many Inline)
-> ParsecT TokStream LaTeXState m [Many Inline]
-> LP m (Many Inline)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> LP m (Many Inline) -> ParsecT TokStream LaTeXState m [Many Inline]
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m [a]
many1 LP m (Many Inline)
siUnitPart
where
siUnitPart :: LP m Inlines
siUnitPart :: LP m (Many Inline)
siUnitPart = LP m (Many Inline) -> LP m (Many Inline)
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try (LP m (Many Inline) -> LP m (Many Inline))
-> LP m (Many Inline) -> LP m (Many Inline)
forall a b. (a -> b) -> a -> b
$ do
ParsecT TokStream LaTeXState m ()
-> ParsecT TokStream LaTeXState m ()
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m ()
skipMany (ParsecT TokStream LaTeXState m Tok
-> ParsecT TokStream LaTeXState m ()
forall (f :: * -> *) a. Functor f => f a -> f ()
void (Char -> ParsecT TokStream LaTeXState m Tok
forall (m :: * -> *). PandocMonad m => Char -> LP m Tok
symbol Char
'.') ParsecT TokStream LaTeXState m ()
-> ParsecT TokStream LaTeXState m ()
-> ParsecT TokStream LaTeXState m ()
forall a.
ParsecT TokStream LaTeXState m a
-> ParsecT TokStream LaTeXState m a
-> ParsecT TokStream LaTeXState m a
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> ParsecT TokStream LaTeXState m Tok
-> ParsecT TokStream LaTeXState m ()
forall (f :: * -> *) a. Functor f => f a -> f ()
void (Char -> ParsecT TokStream LaTeXState m Tok
forall (m :: * -> *). PandocMonad m => Char -> LP m Tok
symbol Char
'~') ParsecT TokStream LaTeXState m ()
-> ParsecT TokStream LaTeXState m ()
-> ParsecT TokStream LaTeXState m ()
forall a.
ParsecT TokStream LaTeXState m a
-> ParsecT TokStream LaTeXState m a
-> ParsecT TokStream LaTeXState m a
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> ParsecT TokStream LaTeXState m ()
forall (m :: * -> *). PandocMonad m => LP m ()
spaces1)
x <- ((LP m (Many Inline -> Many Inline)
siPrefix LP m (Many Inline -> Many Inline)
-> LP m (Many Inline) -> LP m (Many Inline)
forall a b.
ParsecT TokStream LaTeXState m (a -> b)
-> ParsecT TokStream LaTeXState m a
-> ParsecT TokStream LaTeXState m b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> LP m (Many Inline)
siBase)
LP m (Many Inline) -> LP m (Many Inline) -> LP m (Many Inline)
forall a.
ParsecT TokStream LaTeXState m a
-> ParsecT TokStream LaTeXState m a
-> ParsecT TokStream LaTeXState m a
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> (do u <- LP m (Many Inline)
siBase LP m (Many Inline) -> LP m (Many Inline) -> LP m (Many Inline)
forall a.
ParsecT TokStream LaTeXState m a
-> ParsecT TokStream LaTeXState m a
-> ParsecT TokStream LaTeXState m a
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> LP m (Many Inline)
tok
option u $ siSuffix <*> pure u))
option x (siInfix x)
siInfix :: Inlines -> LP m Inlines
siInfix :: Many Inline -> LP m (Many Inline)
siInfix Many Inline
u1 = LP m (Many Inline) -> LP m (Many Inline)
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try (LP m (Many Inline) -> LP m (Many Inline))
-> LP m (Many Inline) -> LP m (Many Inline)
forall a b. (a -> b) -> a -> b
$
(do _ <- Text -> ParsecT TokStream LaTeXState m Tok
forall (m :: * -> *). PandocMonad m => Text -> LP m Tok
controlSeq Text
"per"
u2 <- siUnitPart
let useSlash = Text -> [(Text, Text)] -> Maybe Text
forall a b. Eq a => a -> [(a, b)] -> Maybe b
lookup Text
"per-mode" [(Text, Text)]
options Maybe Text -> Maybe Text -> Bool
forall a. Eq a => a -> a -> Bool
== Text -> Maybe Text
forall a. a -> Maybe a
Just Text
"symbol"
if useSlash
then return (u1 <> str "/" <> u2)
else return (u1 <> str "\xa0" <> negateExponent u2))
LP m (Many Inline) -> LP m (Many Inline) -> LP m (Many Inline)
forall a.
ParsecT TokStream LaTeXState m a
-> ParsecT TokStream LaTeXState m a
-> ParsecT TokStream LaTeXState m a
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> (do _ <- Char -> ParsecT TokStream LaTeXState m Tok
forall (m :: * -> *). PandocMonad m => Char -> LP m Tok
symbol Char
'/'
u2 <- siUnitPart
return (u1 <> str "/" <> u2))
siPrefix :: LP m (Inlines -> Inlines)
siPrefix :: LP m (Many Inline -> Many Inline)
siPrefix =
(do _ <- Text -> ParsecT TokStream LaTeXState m Tok
forall (m :: * -> *). PandocMonad m => Text -> LP m Tok
controlSeq Text
"square"
skipopts
return (<> superscript "2"))
LP m (Many Inline -> Many Inline)
-> LP m (Many Inline -> Many Inline)
-> LP m (Many Inline -> Many Inline)
forall a.
ParsecT TokStream LaTeXState m a
-> ParsecT TokStream LaTeXState m a
-> ParsecT TokStream LaTeXState m a
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> (do _ <- Text -> ParsecT TokStream LaTeXState m Tok
forall (m :: * -> *). PandocMonad m => Text -> LP m Tok
controlSeq Text
"cubic"
skipopts
return (<> superscript "3"))
LP m (Many Inline -> Many Inline)
-> LP m (Many Inline -> Many Inline)
-> LP m (Many Inline -> Many Inline)
forall a.
ParsecT TokStream LaTeXState m a
-> ParsecT TokStream LaTeXState m a
-> ParsecT TokStream LaTeXState m a
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> (do _ <- Text -> ParsecT TokStream LaTeXState m Tok
forall (m :: * -> *). PandocMonad m => Text -> LP m Tok
controlSeq Text
"raisetothe"
skipopts
n <- walk hyphenToMinus <$> tok
return (<> superscript n))
siSuffix :: LP m (Inlines -> Inlines)
siSuffix :: LP m (Many Inline -> Many Inline)
siSuffix =
(do _ <- Text -> ParsecT TokStream LaTeXState m Tok
forall (m :: * -> *). PandocMonad m => Text -> LP m Tok
controlSeq Text
"squared"
skipopts
return (<> superscript "2"))
LP m (Many Inline -> Many Inline)
-> LP m (Many Inline -> Many Inline)
-> LP m (Many Inline -> Many Inline)
forall a.
ParsecT TokStream LaTeXState m a
-> ParsecT TokStream LaTeXState m a
-> ParsecT TokStream LaTeXState m a
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> (do _ <- Text -> ParsecT TokStream LaTeXState m Tok
forall (m :: * -> *). PandocMonad m => Text -> LP m Tok
controlSeq Text
"cubed"
skipopts
return (<> superscript "3"))
LP m (Many Inline -> Many Inline)
-> LP m (Many Inline -> Many Inline)
-> LP m (Many Inline -> Many Inline)
forall a.
ParsecT TokStream LaTeXState m a
-> ParsecT TokStream LaTeXState m a
-> ParsecT TokStream LaTeXState m a
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> (do _ <- Text -> ParsecT TokStream LaTeXState m Tok
forall (m :: * -> *). PandocMonad m => Text -> LP m Tok
controlSeq Text
"tothe"
skipopts
n <- walk hyphenToMinus <$> tok
return (<> superscript n))
LP m (Many Inline -> Many Inline)
-> LP m (Many Inline -> Many Inline)
-> LP m (Many Inline -> Many Inline)
forall a.
ParsecT TokStream LaTeXState m a
-> ParsecT TokStream LaTeXState m a
-> ParsecT TokStream LaTeXState m a
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> (Char -> ParsecT TokStream LaTeXState m Tok
forall (m :: * -> *). PandocMonad m => Char -> LP m Tok
symbol Char
'^' ParsecT TokStream LaTeXState m Tok
-> LP m (Many Inline -> Many Inline)
-> LP m (Many Inline -> Many Inline)
forall a b.
ParsecT TokStream LaTeXState m a
-> ParsecT TokStream LaTeXState m b
-> ParsecT TokStream LaTeXState m b
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> (do n <- (Inline -> Inline) -> Many Inline -> Many Inline
forall a b. Walkable a b => (a -> a) -> b -> b
walk Inline -> Inline
hyphenToMinus (Many Inline -> Many Inline)
-> LP m (Many Inline) -> LP m (Many Inline)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> LP m (Many Inline)
tok
return (<> superscript n)))
LP m (Many Inline -> Many Inline)
-> LP m (Many Inline -> Many Inline)
-> LP m (Many Inline -> Many Inline)
forall a.
ParsecT TokStream LaTeXState m a
-> ParsecT TokStream LaTeXState m a
-> ParsecT TokStream LaTeXState m a
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> (Char -> ParsecT TokStream LaTeXState m Tok
forall (m :: * -> *). PandocMonad m => Char -> LP m Tok
symbol Char
'_' ParsecT TokStream LaTeXState m Tok
-> LP m (Many Inline -> Many Inline)
-> LP m (Many Inline -> Many Inline)
forall a b.
ParsecT TokStream LaTeXState m a
-> ParsecT TokStream LaTeXState m b
-> ParsecT TokStream LaTeXState m b
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> (do n <- (Inline -> Inline) -> Many Inline -> Many Inline
forall a b. Walkable a b => (a -> a) -> b -> b
walk Inline -> Inline
hyphenToMinus (Many Inline -> Many Inline)
-> LP m (Many Inline) -> LP m (Many Inline)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> LP m (Many Inline)
tok
return (<> subscript n)))
negateExponent :: Inlines -> Inlines
negateExponent :: Many Inline -> Many Inline
negateExponent Many Inline
ils =
case Seq Inline -> ViewR Inline
forall a. Seq a -> ViewR a
Seq.viewr (Many Inline -> Seq Inline
forall a. Many a -> Seq a
unMany Many Inline
ils) of
Seq Inline
xs Seq.:> Superscript [Inline]
ss -> (Seq Inline -> Many Inline
forall a. Seq a -> Many a
Many Seq Inline
xs) Many Inline -> Many Inline -> Many Inline
forall a. Semigroup a => a -> a -> a
<>
Many Inline -> Many Inline
superscript (Text -> Many Inline
str Text
minus Many Inline -> Many Inline -> Many Inline
forall a. Semigroup a => a -> a -> a
<> [Inline] -> Many Inline
forall a. [a] -> Many a
fromList [Inline]
ss)
ViewR Inline
_ -> Many Inline
ils Many Inline -> Many Inline -> Many Inline
forall a. Semigroup a => a -> a -> a
<> Many Inline -> Many Inline
superscript (Text -> Many Inline
str (Text
minus Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
"1"))
siBase :: LP m Inlines
siBase :: LP m (Many Inline)
siBase =
((LP m (Many Inline) -> LP m (Many Inline)
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try
(do Tok _ (CtrlSeq name) _ <- ParsecT TokStream LaTeXState m Tok
forall (m :: * -> *). PandocMonad m => LP m Tok
anyControlSeq
case M.lookup name siUnitModifierMap of
Just Many Inline
il -> (Many Inline
il Many Inline -> Many Inline -> Many Inline
forall a. Semigroup a => a -> a -> a
<>) (Many Inline -> Many Inline)
-> LP m (Many Inline) -> LP m (Many Inline)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> LP m (Many Inline)
siBase
Maybe (Many Inline)
Nothing ->
case Text -> Map Text (Many Inline) -> Maybe (Many Inline)
forall k a. Ord k => k -> Map k a -> Maybe a
M.lookup Text
name Map Text (Many Inline)
siUnitMap of
Just Many Inline
il -> Many Inline -> LP m (Many Inline)
forall a. a -> ParsecT TokStream LaTeXState m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure Many Inline
il
Maybe (Many Inline)
Nothing -> String -> LP m (Many Inline)
forall a.
HasCallStack =>
String -> ParsecT TokStream LaTeXState m a
forall (m :: * -> *) a.
(MonadFail m, HasCallStack) =>
String -> m a
fail String
"not a unit command"))
LP m (Many Inline) -> LP m (Many Inline) -> LP m (Many Inline)
forall a.
ParsecT TokStream LaTeXState m a
-> ParsecT TokStream LaTeXState m a
-> ParsecT TokStream LaTeXState m a
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> (do Tok _ Word t <- (Tok -> Bool) -> ParsecT TokStream LaTeXState m Tok
forall (m :: * -> *). PandocMonad m => (Tok -> Bool) -> LP m Tok
satisfyTok Tok -> Bool
isWordTok
return $ str t)
)
siUnitModifierMap :: M.Map Text Inlines
siUnitModifierMap :: Map Text (Many Inline)
siUnitModifierMap = [(Text, Many Inline)] -> Map Text (Many Inline)
forall k a. Ord k => [(k, a)] -> Map k a
M.fromList
[ (Text
"atto", Text -> Many Inline
str Text
"a")
, (Text
"centi", Text -> Many Inline
str Text
"c")
, (Text
"deca", Text -> Many Inline
str Text
"d")
, (Text
"deci", Text -> Many Inline
str Text
"d")
, (Text
"deka", Text -> Many Inline
str Text
"d")
, (Text
"exa", Text -> Many Inline
str Text
"E")
, (Text
"femto", Text -> Many Inline
str Text
"f")
, (Text
"giga", Text -> Many Inline
str Text
"G")
, (Text
"hecto", Text -> Many Inline
str Text
"h")
, (Text
"kilo", Text -> Many Inline
str Text
"k")
, (Text
"mega", Text -> Many Inline
str Text
"M")
, (Text
"micro", Text -> Many Inline
str Text
"μ")
, (Text
"milli", Text -> Many Inline
str Text
"m")
, (Text
"nano", Text -> Many Inline
str Text
"n")
, (Text
"peta", Text -> Many Inline
str Text
"P")
, (Text
"pico", Text -> Many Inline
str Text
"p")
, (Text
"tera", Text -> Many Inline
str Text
"T")
, (Text
"yocto", Text -> Many Inline
str Text
"y")
, (Text
"yotta", Text -> Many Inline
str Text
"Y")
, (Text
"zepto", Text -> Many Inline
str Text
"z")
, (Text
"zetta", Text -> Many Inline
str Text
"Z")
]
siUnitMap :: M.Map Text Inlines
siUnitMap :: Map Text (Many Inline)
siUnitMap = [(Text, Many Inline)] -> Map Text (Many Inline)
forall k a. Ord k => [(k, a)] -> Map k a
M.fromList
[ (Text
"fg", Text -> Many Inline
str Text
"fg")
, (Text
"pg", Text -> Many Inline
str Text
"pg")
, (Text
"ng", Text -> Many Inline
str Text
"ng")
, (Text
"ug", Text -> Many Inline
str Text
"μg")
, (Text
"mg", Text -> Many Inline
str Text
"mg")
, (Text
"g", Text -> Many Inline
str Text
"g")
, (Text
"kg", Text -> Many Inline
str Text
"kg")
, (Text
"amu", Text -> Many Inline
str Text
"u")
, (Text
"pm", Text -> Many Inline
str Text
"pm")
, (Text
"nm", Text -> Many Inline
str Text
"nm")
, (Text
"um", Text -> Many Inline
str Text
"μm")
, (Text
"mm", Text -> Many Inline
str Text
"mm")
, (Text
"cm", Text -> Many Inline
str Text
"cm")
, (Text
"dm", Text -> Many Inline
str Text
"dm")
, (Text
"m", Text -> Many Inline
str Text
"m")
, (Text
"km", Text -> Many Inline
str Text
"km")
, (Text
"as", Text -> Many Inline
str Text
"as")
, (Text
"fs", Text -> Many Inline
str Text
"fs")
, (Text
"ps", Text -> Many Inline
str Text
"ps")
, (Text
"ns", Text -> Many Inline
str Text
"ns")
, (Text
"us", Text -> Many Inline
str Text
"μs")
, (Text
"ms", Text -> Many Inline
str Text
"ms")
, (Text
"s", Text -> Many Inline
str Text
"s")
, (Text
"fmol", Text -> Many Inline
str Text
"fmol")
, (Text
"pmol", Text -> Many Inline
str Text
"pmol")
, (Text
"nmol", Text -> Many Inline
str Text
"nmol")
, (Text
"umol", Text -> Many Inline
str Text
"μmol")
, (Text
"mmol", Text -> Many Inline
str Text
"mmol")
, (Text
"mol", Text -> Many Inline
str Text
"mol")
, (Text
"kmol", Text -> Many Inline
str Text
"kmol")
, (Text
"pA", Text -> Many Inline
str Text
"pA")
, (Text
"nA", Text -> Many Inline
str Text
"nA")
, (Text
"uA", Text -> Many Inline
str Text
"μA")
, (Text
"mA", Text -> Many Inline
str Text
"mA")
, (Text
"A", Text -> Many Inline
str Text
"A")
, (Text
"kA", Text -> Many Inline
str Text
"kA")
, (Text
"ul", Text -> Many Inline
str Text
"μl")
, (Text
"ml", Text -> Many Inline
str Text
"ml")
, (Text
"l", Text -> Many Inline
str Text
"l")
, (Text
"hl", Text -> Many Inline
str Text
"hl")
, (Text
"uL", Text -> Many Inline
str Text
"μL")
, (Text
"mL", Text -> Many Inline
str Text
"mL")
, (Text
"L", Text -> Many Inline
str Text
"L")
, (Text
"hL", Text -> Many Inline
str Text
"hL")
, (Text
"mHz", Text -> Many Inline
str Text
"mHz")
, (Text
"Hz", Text -> Many Inline
str Text
"Hz")
, (Text
"kHz", Text -> Many Inline
str Text
"kHz")
, (Text
"MHz", Text -> Many Inline
str Text
"MHz")
, (Text
"GHz", Text -> Many Inline
str Text
"GHz")
, (Text
"THz", Text -> Many Inline
str Text
"THz")
, (Text
"mN", Text -> Many Inline
str Text
"mN")
, (Text
"N", Text -> Many Inline
str Text
"N")
, (Text
"kN", Text -> Many Inline
str Text
"kN")
, (Text
"MN", Text -> Many Inline
str Text
"MN")
, (Text
"Pa", Text -> Many Inline
str Text
"Pa")
, (Text
"kPa", Text -> Many Inline
str Text
"kPa")
, (Text
"MPa", Text -> Many Inline
str Text
"MPa")
, (Text
"GPa", Text -> Many Inline
str Text
"GPa")
, (Text
"mohm", Text -> Many Inline
str Text
"mΩ")
, (Text
"kohm", Text -> Many Inline
str Text
"kΩ")
, (Text
"Mohm", Text -> Many Inline
str Text
"MΩ")
, (Text
"pV", Text -> Many Inline
str Text
"pV")
, (Text
"nV", Text -> Many Inline
str Text
"nV")
, (Text
"uV", Text -> Many Inline
str Text
"μV")
, (Text
"mV", Text -> Many Inline
str Text
"mV")
, (Text
"V", Text -> Many Inline
str Text
"V")
, (Text
"kV", Text -> Many Inline
str Text
"kV")
, (Text
"W", Text -> Many Inline
str Text
"W")
, (Text
"uW", Text -> Many Inline
str Text
"μW")
, (Text
"mW", Text -> Many Inline
str Text
"mW")
, (Text
"kW", Text -> Many Inline
str Text
"kW")
, (Text
"MW", Text -> Many Inline
str Text
"MW")
, (Text
"GW", Text -> Many Inline
str Text
"GW")
, (Text
"J", Text -> Many Inline
str Text
"J")
, (Text
"uJ", Text -> Many Inline
str Text
"μJ")
, (Text
"mJ", Text -> Many Inline
str Text
"mJ")
, (Text
"kJ", Text -> Many Inline
str Text
"kJ")
, (Text
"eV", Text -> Many Inline
str Text
"eV")
, (Text
"meV", Text -> Many Inline
str Text
"meV")
, (Text
"keV", Text -> Many Inline
str Text
"keV")
, (Text
"MeV", Text -> Many Inline
str Text
"MeV")
, (Text
"GeV", Text -> Many Inline
str Text
"GeV")
, (Text
"TeV", Text -> Many Inline
str Text
"TeV")
, (Text
"kWh", Text -> Many Inline
str Text
"kWh")
, (Text
"F", Text -> Many Inline
str Text
"F")
, (Text
"fF", Text -> Many Inline
str Text
"fF")
, (Text
"pF", Text -> Many Inline
str Text
"pF")
, (Text
"K", Text -> Many Inline
str Text
"K")
, (Text
"dB", Text -> Many Inline
str Text
"dB")
, (Text
"ampere", Text -> Many Inline
str Text
"A")
, (Text
"angstrom", Text -> Many Inline
str Text
"Å")
, (Text
"arcmin", Text -> Many Inline
str Text
"′")
, (Text
"arcminute", Text -> Many Inline
str Text
"′")
, (Text
"arcsecond", Text -> Many Inline
str Text
"″")
, (Text
"astronomicalunit", Text -> Many Inline
str Text
"au")
, (Text
"atomicmassunit", Text -> Many Inline
str Text
"u")
, (Text
"bar", Text -> Many Inline
str Text
"bar")
, (Text
"barn", Text -> Many Inline
str Text
"b")
, (Text
"becquerel", Text -> Many Inline
str Text
"Bq")
, (Text
"bel", Text -> Many Inline
str Text
"B")
, (Text
"bohr", Many Inline -> Many Inline
emph (Text -> Many Inline
str Text
"a") Many Inline -> Many Inline -> Many Inline
forall a. Semigroup a => a -> a -> a
<> Many Inline -> Many Inline
subscript (Text -> Many Inline
str Text
"0"))
, (Text
"candela", Text -> Many Inline
str Text
"cd")
, (Text
"celsius", Text -> Many Inline
str Text
"°C")
, (Text
"clight", Many Inline -> Many Inline
emph (Text -> Many Inline
str Text
"c") Many Inline -> Many Inline -> Many Inline
forall a. Semigroup a => a -> a -> a
<> Many Inline -> Many Inline
subscript (Text -> Many Inline
str Text
"0"))
, (Text
"coulomb", Text -> Many Inline
str Text
"C")
, (Text
"dalton", Text -> Many Inline
str Text
"Da")
, (Text
"day", Text -> Many Inline
str Text
"d")
, (Text
"decibel", Text -> Many Inline
str Text
"db")
, (Text
"degreeCelsius",Text -> Many Inline
str Text
"°C")
, (Text
"degree", Text -> Many Inline
str Text
"°")
, (Text
"electronmass", Many Inline -> Many Inline
emph (Text -> Many Inline
str Text
"m") Many Inline -> Many Inline -> Many Inline
forall a. Semigroup a => a -> a -> a
<> Many Inline -> Many Inline
subscript (Text -> Many Inline
str Text
"e"))
, (Text
"electronvolt", Text -> Many Inline
str Text
"eV")
, (Text
"elementarycharge", Many Inline -> Many Inline
emph (Text -> Many Inline
str Text
"e"))
, (Text
"farad", Text -> Many Inline
str Text
"F")
, (Text
"gram", Text -> Many Inline
str Text
"g")
, (Text
"gray", Text -> Many Inline
str Text
"Gy")
, (Text
"hartree", Many Inline -> Many Inline
emph (Text -> Many Inline
str Text
"E") Many Inline -> Many Inline -> Many Inline
forall a. Semigroup a => a -> a -> a
<> Many Inline -> Many Inline
subscript (Text -> Many Inline
str Text
"h"))
, (Text
"hectare", Text -> Many Inline
str Text
"ha")
, (Text
"henry", Text -> Many Inline
str Text
"H")
, (Text
"hertz", Text -> Many Inline
str Text
"Hz")
, (Text
"hour", Text -> Many Inline
str Text
"h")
, (Text
"joule", Text -> Many Inline
str Text
"J")
, (Text
"katal", Text -> Many Inline
str Text
"kat")
, (Text
"kelvin", Text -> Many Inline
str Text
"K")
, (Text
"kilogram", Text -> Many Inline
str Text
"kg")
, (Text
"knot", Text -> Many Inline
str Text
"kn")
, (Text
"liter", Text -> Many Inline
str Text
"L")
, (Text
"litre", Text -> Many Inline
str Text
"l")
, (Text
"lumen", Text -> Many Inline
str Text
"lm")
, (Text
"lux", Text -> Many Inline
str Text
"lx")
, (Text
"meter", Text -> Many Inline
str Text
"m")
, (Text
"metre", Text -> Many Inline
str Text
"m")
, (Text
"minute", Text -> Many Inline
str Text
"min")
, (Text
"mmHg", Text -> Many Inline
str Text
"mmHg")
, (Text
"mole", Text -> Many Inline
str Text
"mol")
, (Text
"nauticalmile", Text -> Many Inline
str Text
"M")
, (Text
"neper", Text -> Many Inline
str Text
"Np")
, (Text
"newton", Text -> Many Inline
str Text
"N")
, (Text
"ohm", Text -> Many Inline
str Text
"Ω")
, (Text
"Pa", Text -> Many Inline
str Text
"Pa")
, (Text
"pascal", Text -> Many Inline
str Text
"Pa")
, (Text
"percent", Text -> Many Inline
str Text
"%")
, (Text
"planckbar", Many Inline -> Many Inline
emph (Text -> Many Inline
str Text
"\x210f"))
, (Text
"radian", Text -> Many Inline
str Text
"rad")
, (Text
"second", Text -> Many Inline
str Text
"s")
, (Text
"siemens", Text -> Many Inline
str Text
"S")
, (Text
"sievert", Text -> Many Inline
str Text
"Sv")
, (Text
"steradian", Text -> Many Inline
str Text
"sr")
, (Text
"tesla", Text -> Many Inline
str Text
"T")
, (Text
"tonne", Text -> Many Inline
str Text
"t")
, (Text
"volt", Text -> Many Inline
str Text
"V")
, (Text
"watt", Text -> Many Inline
str Text
"W")
, (Text
"weber", Text -> Many Inline
str Text
"Wb")
]