-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Flatten camel case text in LaTeX files -- -- smallcaps is a pre-processor library for LaTeX files. The library -- comes with an executable that makes most functionality accessible -- through a command line interface. The pre-processor formats sequences -- of uppercase letters with TeX's \small macro or whatever you -- configure. Uppercase letters at the beginning of sentences are not -- formatted. Other formatting conditions can be configured by the user. -- -- The executable can be configured through its command line arguments as -- well as through TeX comments. In the default configuration, lesscase -- does not change the content of any macro argument or environment -- (different from document). More and less restrictive configuration -- profiles can be activated and adapted. Configurations can be stored -- and restored at any time, even while processing the input file. -- --
-- import Data.Default ( def ) -- import Text.SmallCaps ( smallcaps ) -- import Text.SmallCaps.Config ( defaultProfile ) -- main = smallcaps def defaultProfile ---- -- This is virtually all the code that is necessary to implement the -- executable lesscase. Have a look in the source of the -- executable twocase which only formats sequences of two or -- more uppercase letters. It is a good reference for understanding the -- API changes that took place between the revisions 0.5 and 0.6. @package smallcaps @version 0.6.0.3 -- | This modules specifies the data types TeX and -- TeXElement. module Text.SmallCaps.TeX type TeX = [TeXElement] data TeXElement Printable :: Text -> TeXElement Macro :: Text -> TeXElement Block :: TeX -> TeXElement BBlock :: TeX -> TeXElement Math :: TeX -> TeXElement Comment :: Text -> TeXElement isPrintable :: TeXElement -> Bool isMacro :: TeXElement -> Bool isBlock :: TeXElement -> Bool isBBlock :: TeXElement -> Bool isMath :: TeXElement -> Bool isComment :: TeXElement -> Bool isMacroLetter :: Char -> Bool isMacroSign :: Char -> Bool content :: TeXElement -> Text printable :: TeXElement -> Text body :: TeXElement -> TeX instance GHC.Show.Show Text.SmallCaps.TeX.TeXElement instance GHC.Classes.Eq Text.SmallCaps.TeX.TeXElement -- | This modules specifies parsers that consume Text and produce a -- TeXElement token stream. module Text.SmallCaps.TeXParser tex :: Parser TeX texElement :: Parser TeXElement printable :: Parser TeXElement comment :: Parser TeXElement commentChar :: Parser Char macro :: Parser TeXElement macroBegin :: Parser Char macroName :: Parser Text macroLabel :: Parser Text macroSign :: Parser Char block :: Parser TeXElement blockBegin :: Parser Char blockEnd :: Parser Char bblock :: Parser TeXElement bblockBegin :: Parser Char bblockEnd :: Parser Char math :: Parser TeXElement tt :: Parser Char -> Parser Text -- | This modules specifies the data types LaTeX and -- LaTeXElement. module Text.SmallCaps.LaTeX type LaTeX = [LaTeXElement] data LaTeXElement -- | (hopefully) printable text Printable :: Text -> LaTeXElement -- | macro name + following blocks Macro :: Text -> LaTeX -> LaTeXElement -- | environment name + content Environment :: Text -> LaTeX -> LaTeXElement -- | separate block Block :: LaTeX -> LaTeXElement -- | block between square brackets BBlock :: LaTeX -> LaTeXElement -- | inline math Math :: LaTeX -> LaTeXElement -- | comment starting with % Comment :: Text -> LaTeXElement isPrintable :: LaTeXElement -> Bool isMacro :: LaTeXElement -> Bool isEnvironment :: LaTeXElement -> Bool isBlock :: LaTeXElement -> Bool isBBlock :: LaTeXElement -> Bool isMath :: LaTeXElement -> Bool isComment :: LaTeXElement -> Bool name :: LaTeXElement -> Text content :: LaTeXElement -> Text printable :: LaTeXElement -> Text body :: LaTeXElement -> LaTeX unlatex :: LaTeX -> Text unlatexElement :: LaTeXElement -> Text cc :: [Text] -> Text instance GHC.Show.Show Text.SmallCaps.LaTeX.LaTeXElement instance GHC.Classes.Eq Text.SmallCaps.LaTeX.LaTeXElement -- | This modules specifies parsers that consume a TeXElement token -- stream and produce a LaTeXElement token stream. module Text.SmallCaps.TeXLaTeXParser type Parser = ParsecT TeX () (Writer [Text]) parse :: Parser [a] -> TeX -> ([a], [Text]) parse' :: Parser a -> TeX -> (Either ParseError a, [Text]) latex :: Parser LaTeX satisfy :: (TeXElement -> Bool) -> Parser TeXElement skipMacro :: Text -> Parser TeXElement translate :: TeXElement -> (LaTeXElement, [Text]) translateTell :: Monad m => TeXElement -> WriterT [Text] m LaTeXElement macroSatisfy :: (TeXElement -> Bool) -> Parser LaTeXElement macro :: Parser LaTeXElement macroTextArg :: Text -> Parser Text environment :: Parser LaTeXElement anyBlock :: Parser LaTeXElement anyBBlock :: Parser LaTeXElement macroArguments :: Parser LaTeX latexElement :: Parser LaTeXElement beginEnv :: Parser Text endEnv :: Parser Text isEndEnv :: TeXElement -> Bool updpos :: SourcePos -> t -> s -> SourcePos -- | This modules specifies parsers on LaTeXElement token streams. module Text.SmallCaps.LaTeXParser type Parser u = Parsec LaTeX u satisfy :: (LaTeXElement -> Bool) -> Parser u LaTeXElement anyPrintable :: Parser u LaTeXElement printable :: Text -> Parser u LaTeXElement anyMacro :: Parser u LaTeXElement macro :: Text -> Parser u LaTeXElement anyEnvironment :: Parser u LaTeXElement environment :: Text -> Parser u LaTeXElement anyBlock :: Parser u LaTeXElement anyBBlock :: Parser u LaTeXElement anyMath :: Parser u LaTeXElement anyComment :: Parser u LaTeXElement updpos :: SourcePos -> t -> s -> SourcePos -- | This module specifies the default configuration values for SmallCaps. module Text.SmallCaps.Config data ParserState ParserState :: Config -> Map FilePath (FilePath, LaTeX) -> Profile -> StopState -> Bool -> ParserState -- | configuration [config] :: ParserState -> Config -- | additional input files [inputs] :: ParserState -> Map FilePath (FilePath, LaTeX) -- | configuration preset list [profile] :: ParserState -> Profile -- | stop state [stop] :: ParserState -> StopState -- | skip on/off [ignore] :: ParserState -> Bool defaultProfile :: Map Text Config data Config Config :: [Char] -> (LaTeXElement -> Bool) -> (LaTeXElement -> Maybe Text) -> (LaTeXElement -> Bool) -> (LaTeXElement -> Bool) -> (LaTeXElement -> Bool) -> (StopState -> Text -> Text) -> (Text -> Bool) -> [PatternReplace] -> Bool -> Config -- | signs recognised as periods [periodChars] :: Config -> [Char] -- | search blockmacroenvironment for caps [search] :: Config -> LaTeXElement -> Bool -- | open an isolated state for a blockmacroenvironment; returns -- config name [isolate] :: Config -> LaTeXElement -> Maybe Text -- | skip searching for the rest of the block etc. [skip] :: Config -> LaTeXElement -> Bool -- | undo skip, e.g., at normalsize when skipping small [unskip] :: Config -> LaTeXElement -> Bool -- | end of sentence, start with new one [eos] :: Config -> LaTeXElement -> Bool -- | formatting for small caps [replace] :: Config -> StopState -> Text -> Text -- | filter for small caps candidates (e.g., for assuring a certain minimum -- length) [replaceFilter] :: Config -> Text -> Bool -- | search for patterns in printables and replace them (no further -- processing) [exceptions] :: Config -> [PatternReplace] -- | dynamic reconfiguration in LaTeX comments [inlineConfig] :: Config -> Bool defaultPeriodChars :: [Char] defaultSearch :: LaTeXElement -> Bool defaultIsolate :: LaTeXElement -> Maybe Text defaultSkip :: LaTeXElement -> Bool defaultUnskip :: LaTeXElement -> Bool defaultEos :: LaTeXElement -> Bool defaultReplace :: StopState -> Text -> Text defaultReplaceTemplate :: Text -> StopState -> Text -> Text defaultReplaceTemplate' :: Text -> StopState -> Text -> Text defaultNewSentence :: (Text -> Text) -> StopState -> Text -> Text defaultReplaceFilter :: Text -> Bool defaultExceptions :: [PatternReplace] -- | combinator for plugin construction (&&&) :: (LaTeXElement -> Bool) -> (LaTeXElement -> Bool) -> LaTeXElement -> Bool (|||) :: (LaTeXElement -> Bool) -> (LaTeXElement -> Bool) -> LaTeXElement -> Bool -- | clean configuration, all substitutions off clean :: Config -- | conservative configuration conservative :: Config -- | busy configuration busy :: Config -- | abstract/small font configuration small :: Config -- | footnote font configuration footnote :: Config whitelist :: [String] -> LaTeXElement -> Bool blacklist :: [String] -> LaTeXElement -> Bool after :: [String] -> LaTeXElement -> Bool isolateWith :: [(String, String)] -> LaTeXElement -> Maybe Text findConfigName :: Text -> [(String, String)] -> Maybe Text type Profile = Map Text Config type SubParser a = ParserState -> a -> Either String (a, ParserState) data StopState -- | within a sentence None :: StopState -- | one newline read NewLine :: StopState -- | stop character read Stop :: StopState -- | begin of a new sentence NewSentence :: StopState newSentence :: (Text -> Text) -> (Text -> Text) -> StopState -> Text -> Text data PatternReplace PatternReplace :: Text -> Text -> PatternReplace [pattern] :: PatternReplace -> Text [replacement] :: PatternReplace -> Text instance GHC.Classes.Eq Text.SmallCaps.Config.StopState instance GHC.Show.Show Text.SmallCaps.Config.StopState instance Data.Default.Class.Default Text.SmallCaps.Config.ParserState instance Data.Default.Class.Default Text.SmallCaps.Config.Config instance Data.Default.Class.Default Text.SmallCaps.Config.StopState -- | This module specifies inline configuration parsers. The parsers are -- also used for the arguments in the command line interface. module Text.SmallCaps.ConfigParser reconfigure :: ParserState -> Text -> Either (Text, Config) Config reconfiguration :: ParserState -> Parser (Either (Text, Config) Config) lex :: Parser a -> Parser a preamble :: Parser Text profileMain :: Map Text Config -> Parser Config profilePre :: Parser Text profileName :: Map Text Config -> Parser Config storeMain :: Config -> Parser (Text, Config) storePre :: Parser Text storeName :: Config -> Parser (Text, Config) periodMain :: Config -> Parser Config periodPre :: Parser Text periodSigns :: Config -> Parser Config replaceMain :: Config -> Parser Config replacePre :: Parser Text data Style NoArg :: Style InArg :: Style replaceStyleNoarg :: Parser Style replaceStyleInarg :: Parser Style replaceMacro :: Config -> Style -> Parser Config searchMain :: Config -> Parser Config searchPre :: Parser Text searchList :: Config -> Parser Config isolateMain :: Config -> Parser Config isolatePre :: Parser Text isolateList :: Config -> Parser Config skipMain :: Config -> Parser Config skipPre :: Parser Text skipList :: Config -> Parser Config unskipMain :: Config -> Parser Config unskipPre :: Parser Text unskipList :: Config -> Parser Config eosMain :: Config -> Parser Config eosPre :: Parser Text eosList :: Config -> Parser Config exceptMain :: Config -> Parser Config exceptPre :: Parser Text exceptTuple :: Config -> Parser Config list :: (LaTeXElement -> Bool) -> Parser (LaTeXElement -> Bool) list' :: (LaTeXElement -> Bool) -> Parser (LaTeXElement -> Bool) listBlack :: (LaTeXElement -> Bool) -> Parser (LaTeXElement -> Bool) listWhite :: (LaTeXElement -> Bool) -> Parser (LaTeXElement -> Bool) listConstAll :: Parser (a -> Bool) listConstAll' :: Parser (LaTeXElement -> Bool) listConstNone :: Parser (a -> Bool) listConstNone' :: Parser (LaTeXElement -> Bool) iList :: (LaTeXElement -> Maybe Text) -> Parser (LaTeXElement -> Maybe Text) iListBlack :: (LaTeXElement -> Maybe Text) -> Parser (LaTeXElement -> Maybe Text) iListWhite :: (LaTeXElement -> Maybe Text) -> Parser (LaTeXElement -> Maybe Text) iListConstAll :: Parser (LaTeXElement -> Maybe Text) iListConstNone :: Parser (LaTeXElement -> Maybe Text) listItems :: Parser [Text] listItem :: Parser Text listItemMacro :: Parser Text listItemEnvironment :: Parser Text listItemSeparator :: Parser Char isElement :: LaTeXElement -> [Text] -> Bool instance GHC.Classes.Eq Text.SmallCaps.ConfigParser.Style instance GHC.Show.Show Text.SmallCaps.ConfigParser.Style -- | This modules specifies parsers on printable Text. module Text.SmallCaps.PrintableParser type Parser = GenParser ParserState runPrintableWith :: SubParser Text printable :: Parser Text printableElement :: Parser Text excepts :: Parser Text lowers :: Parser Text uppers :: Parser Text period :: Parser Text space :: Parser Text newline :: Parser Text misc :: Parser Text pass :: Parser b -> a -> Parser a reset :: Parser () set :: Parser () inc :: Parser () sticky :: Parser () -- | This module specifies the parsers that change uppercase letters in -- smaller uppercase letters. It calls the functions from -- Text.SmallCaps.PrintableParser. module Text.SmallCaps.DocumentParser type Parser = Parser ParserState runDocument :: Config -> Profile -> LaTeX -> Either String LaTeX runDocument' :: Map FilePath (FilePath, LaTeX) -> Config -> Profile -> LaTeX -> Either String (LaTeX, Map FilePath (FilePath, LaTeX)) runDocumentWith :: SubParser LaTeX runSubDocument :: SubParser a -> a -> Parser a isolateSubDocument :: Config -> SubParser a -> a -> Parser a decideSub :: LaTeXElement -> SubParser a -> a -> Parser a document :: Parser LaTeX documentElement :: Parser LaTeXElement printable :: Parser LaTeXElement macro :: Parser LaTeXElement environment :: Parser LaTeXElement block :: Parser LaTeXElement bblock :: Parser LaTeXElement math :: Parser LaTeXElement comment :: Parser LaTeXElement implySkip :: LaTeXElement -> Parser () implyInput :: LaTeXElement -> Parser () implyEos :: LaTeXElement -> Parser () resetNewLine :: Parser () -- | The main program as library. module Text.SmallCaps version :: Version smallcapsNoRecursion :: Config -> Profile -> Text -> Either String Text parseLaTeX :: Text -> Either String (LaTeX, [Text]) smallcaps :: Config -> Profile -> IO () smallcapsHandle :: Handle -> Handle -> Config -> Profile -> IO () smallcapsPipe :: Config -> Profile -> IO () smallcapsFile :: FilePath -> FilePath -> Config -> Profile -> IO () smallcapsRecursiveFile :: FilePath -> FilePath -> Config -> Profile -> IO () recursiveContents :: FilePath -> Map FilePath (FilePath, LaTeX) -> [FilePath] -> IO (Map FilePath (FilePath, LaTeX)) prefixed :: FilePath -> FilePath -> Text -> IO () texPath :: FilePath -> FilePath getPrefix :: [Flag] -> String data Flag ProgVer :: Flag Help :: Flag Prefix :: String -> Flag Recursive :: Flag Profile :: String -> Flag Periods :: String -> Flag BMacro :: String -> Flag AMacro :: String -> Flag Search :: String -> Flag Isolate :: String -> Flag Skip :: String -> Flag Unskip :: String -> Flag Eos :: String -> Flag NoInline :: Flag runFlags :: Config -> Profile -> [Flag] -> [String] -> IO () reconf :: Config -> [Flag] -> Config options :: [OptDescr Flag] opts :: [String] -> IO ([Flag], [String]) usage :: IO () putVersion :: IO () instance GHC.Show.Show Text.SmallCaps.Flag instance GHC.Classes.Eq Text.SmallCaps.Flag