git.iko.soy/typeable/pandoc
on master help sign in
LaTeX reader: support `\MakeUppercase`, `\MakeLowercase'.

Also `\MakeTextUppercase`, `\MakeTextLowercase` from textcase and `\uppercase`, `\lowercase`. We don't mimic exactly the quirky semantic differences between these commands, but just uppercase/lowercase regular strings within them. We leave commands and code alone. Closes #4595.

commita9344bf308afa4d2197582aff8045de56e24c7aa authorJohn MacFarlane <jgm@berkeley.edu> dateWed 25 Apr 2018, 17:36 (9 years ago) parent16f36ee
1 file changed+17−1
src/Text/Pandoc/Readers/LaTeX.hs+17−1
src/Text/Pandoc/Readers/LaTeX.hs+17−1
@@ -48,7 +48,7 @@ import Control.Applicative (many, optional, (<|>))
4848import Control.Monad
4949import Control.Monad.Except (throwError)
5050import Control.Monad.Trans (lift)
51−import Data.Char (chr, isAlphaNum, isDigit, isLetter, ord, toLower)
51+import Data.Char (chr, isAlphaNum, isDigit, isLetter, ord, toLower, toUpper)
5252import Data.Default
5353import Data.List (intercalate, isPrefixOf)
5454import qualified Data.Map as M
@@ -1315,6 +1315,12 @@ inlineCommands = M.union inlineLanguageCommands $ M.fromList
13151315 , ("slshape", extractSpaces emph <$> inlines)
13161316 , ("scshape", extractSpaces smallcaps <$> inlines)
13171317 , ("bfseries", extractSpaces strong <$> inlines)
1318+ , ("MakeUppercase", makeUppercase <$> tok)
1319+ , ("MakeTextUppercase", makeUppercase <$> tok) -- textcase
1320+ , ("uppercase", makeUppercase <$> tok)
1321+ , ("MakeLowercase", makeLowercase <$> tok)
1322+ , ("MakeTextLowercase", makeLowercase <$> tok)
1323+ , ("lowercase", makeLowercase <$> tok)
13181324 , ("/", pure mempty) -- italic correction
13191325 , ("aa", lit "å")
13201326 , ("AA", lit "Å")
@@ -1515,6 +1521,16 @@ inlineCommands = M.union inlineLanguageCommands $ M.fromList
15151521 , ("foreignlanguage", foreignlanguage)
15161522 ]
15171523
1524+makeUppercase :: Inlines -> Inlines
1525+makeUppercase = fromList . walk (alterStr (map toUpper)) . toList
1526+
1527+makeLowercase :: Inlines -> Inlines
1528+makeLowercase = fromList . walk (alterStr (map toLower)) . toList
1529+
1530+alterStr :: (String -> String) -> Inline -> Inline
1531+alterStr f (Str xs) = Str (f xs)
1532+alterStr _ x = x
1533+
15181534foreignlanguage :: PandocMonad m => LP m Inlines
15191535foreignlanguage = do
15201536 babelLang <- T.unpack . untokenize <$> braced