@@ -586,44 +586,6 @@ nlToSpace :: Char -> Char
586586nlToSpace '\n' = ' '
587587nlToSpace x = x
588588
589−keyval :: PandocMonad m => LP m (Text, Text)
590−keyval = try $ do
591− Tok _ Word key <- satisfyTok isWordTok
592− sp
593− val <- option mempty $ do
594− symbol '='
595− sp
596− (untokenize <$> braced) <|>
597− (mconcat <$> many1 (
598− (untokenize . snd <$> withRaw braced)
599− <|>
600− (untokenize <$> (many1
601− (satisfyTok
602− (\t -> case t of
603− Tok _ Symbol "]" -> False
604− Tok _ Symbol "," -> False
605− Tok _ Symbol "{" -> False
606− Tok _ Symbol "}" -> False
607− _ -> True))))))
608− optional (symbol ',')
609− sp
610− return (key, T.strip val)
611−
612−keyvals :: PandocMonad m => LP m [(Text, Text)]
613−keyvals = try $ symbol '[' >> manyTill keyval (symbol ']') <* sp
614−
615−accent :: PandocMonad m => Char -> Maybe Char -> LP m Inlines
616−accent combiningAccent fallBack = try $ do
617− ils <- tok
618− case toList ils of
619− (Str (T.uncons -> Just (x, xs)) : ys) -> return $ fromList $
620− -- try to normalize to the combined character:
621− Str (Normalize.normalize Normalize.NFC
622− (T.pack [x, combiningAccent]) <> xs) : ys
623− [Space] -> return $ str $ T.singleton $ fromMaybe combiningAccent fallBack
624− [] -> return $ str $ T.singleton $ fromMaybe combiningAccent fallBack
625− _ -> return ils
626−
627589mathDisplay :: Text -> Inlines
628590mathDisplay = displayMath . trimMath
629591
@@ -782,6 +744,7 @@ inlineCommand' = try $ do
782744 <|> ignore rawcommand
783745 lookupListDefault raw names inlineCommands
784746
747+
785748tok :: PandocMonad m => LP m Inlines
786749tok = try $ spaces >> grouped inline <|> inlineCommand' <|> singleChar'
787750 where singleChar' = do
@@ -1178,6 +1141,19 @@ inlineCommands = M.union inlineLanguageCommands $ M.fromList
11781141 , ("ifdim", ifdim)
11791142 ]
11801143
1144+accent :: PandocMonad m => Char -> Maybe Char -> LP m Inlines
1145+accent combiningAccent fallBack = try $ do
1146+ ils <- tok
1147+ case toList ils of
1148+ (Str (T.uncons -> Just (x, xs)) : ys) -> return $ fromList $
1149+ -- try to normalize to the combined character:
1150+ Str (Normalize.normalize Normalize.NFC
1151+ (T.pack [x, combiningAccent]) <> xs) : ys
1152+ [Space] -> return $ str $ T.singleton $ fromMaybe combiningAccent fallBack
1153+ [] -> return $ str $ T.singleton $ fromMaybe combiningAccent fallBack
1154+ _ -> return ils
1155+
1156+
11811157lettrine :: PandocMonad m => LP m Inlines
11821158lettrine = do
11831159 optional opt
@@ -1471,20 +1447,6 @@ inlines = mconcat <$> many inline
14711447
14721448-- block elements:
14731449
1474−begin_ :: PandocMonad m => Text -> LP m ()
1475−begin_ t = try (do
1476− controlSeq "begin"
1477− spaces
1478− txt <- untokenize <$> braced
1479− guard (t == txt)) <?> ("\\begin{" ++ T.unpack t ++ "}")
1480−
1481−end_ :: PandocMonad m => Text -> LP m ()
1482−end_ t = try (do
1483− controlSeq "end"
1484− spaces
1485− txt <- untokenize <$> braced
1486− guard $ t == txt) <?> ("\\end{" ++ T.unpack t ++ "}")
1487−
14881450preamble :: PandocMonad m => LP m Blocks
14891451preamble = mconcat <$> many preambleBlock
14901452 where preambleBlock = (mempty <$ spaces1)
@@ -1997,24 +1959,6 @@ rawVerbEnv name = do
19971959 report $ SkippedContent raw' pos
19981960 return mempty
19991961
2000−verbEnv :: PandocMonad m => Text -> LP m Text
2001−verbEnv name = withVerbatimMode $ do
2002− optional blankline
2003− res <- manyTill anyTok (end_ name)
2004− return $ stripTrailingNewline
2005− $ untokenize
2006− $ res
2007−
2008−-- Strip single final newline and any spaces following it.
2009−-- Input is unchanged if it doesn't end with newline +
2010−-- optional spaces.
2011−stripTrailingNewline :: Text -> Text
2012−stripTrailingNewline t =
2013− let (b, e) = T.breakOnEnd "\n" t
2014− in if T.all (== ' ') e
2015− then T.dropEnd 1 b
2016− else t
2017−
20181962fancyverbEnv :: PandocMonad m => Text -> LP m Blocks
20191963fancyverbEnv name = do
20201964 options <- option [] keyvals