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.
This commit is contained in:
parent
16f36eee43
commit
a9344bf308
1 changed files with 17 additions and 1 deletions
|
@ -48,7 +48,7 @@ import Control.Applicative (many, optional, (<|>))
|
|||
import Control.Monad
|
||||
import Control.Monad.Except (throwError)
|
||||
import Control.Monad.Trans (lift)
|
||||
import Data.Char (chr, isAlphaNum, isDigit, isLetter, ord, toLower)
|
||||
import Data.Char (chr, isAlphaNum, isDigit, isLetter, ord, toLower, toUpper)
|
||||
import Data.Default
|
||||
import Data.List (intercalate, isPrefixOf)
|
||||
import qualified Data.Map as M
|
||||
|
@ -1315,6 +1315,12 @@ inlineCommands = M.union inlineLanguageCommands $ M.fromList
|
|||
, ("slshape", extractSpaces emph <$> inlines)
|
||||
, ("scshape", extractSpaces smallcaps <$> inlines)
|
||||
, ("bfseries", extractSpaces strong <$> inlines)
|
||||
, ("MakeUppercase", makeUppercase <$> tok)
|
||||
, ("MakeTextUppercase", makeUppercase <$> tok) -- textcase
|
||||
, ("uppercase", makeUppercase <$> tok)
|
||||
, ("MakeLowercase", makeLowercase <$> tok)
|
||||
, ("MakeTextLowercase", makeLowercase <$> tok)
|
||||
, ("lowercase", makeLowercase <$> tok)
|
||||
, ("/", pure mempty) -- italic correction
|
||||
, ("aa", lit "å")
|
||||
, ("AA", lit "Å")
|
||||
|
@ -1515,6 +1521,16 @@ inlineCommands = M.union inlineLanguageCommands $ M.fromList
|
|||
, ("foreignlanguage", foreignlanguage)
|
||||
]
|
||||
|
||||
makeUppercase :: Inlines -> Inlines
|
||||
makeUppercase = fromList . walk (alterStr (map toUpper)) . toList
|
||||
|
||||
makeLowercase :: Inlines -> Inlines
|
||||
makeLowercase = fromList . walk (alterStr (map toLower)) . toList
|
||||
|
||||
alterStr :: (String -> String) -> Inline -> Inline
|
||||
alterStr f (Str xs) = Str (f xs)
|
||||
alterStr _ x = x
|
||||
|
||||
foreignlanguage :: PandocMonad m => LP m Inlines
|
||||
foreignlanguage = do
|
||||
babelLang <- T.unpack . untokenize <$> braced
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue