Permalink
Browse files

* Removed faulty command from the listing

* Cleaned up some code
  • Loading branch information...
spockz committed Oct 15, 2011
1 parent 745ea70 commit 5df0b52d5277af7d570c558a94a9a9c484127d8a
Showing with 14 additions and 11 deletions.
  1. +0 −1 src/Base/CLI.hs
  2. +14 −10 src/LiterateHighlighter.hs
View
@@ -34,7 +34,6 @@ newCommands = unlines [
"\\newcommand{\\lhsCHprelude}[1]{\\color{prelude}{{#1}}}",
"\\newcommand{\\lhsCHkeyword}[1]{\\color{keyword}{{#1}}}",
"\\newcommand{\\lhsCHconstructor}[1]{\\color{constructor}{{#1}}}",
- "\\newcommand{\\lhsCHlitNumber}[1]{\\color{numeral}{{#1}}}",
"\\newcommand{\\lhsCHtype}[1]{\\color{datatype}{{#1}}}",
"\\newcommand{\\lhsCHsyntax}[1]{\\color{syntax}{{#1}}}",
"\\newcommand{\\lhsCHclass}[1]{\\color{class}{{#1}}}",
View
@@ -43,22 +43,26 @@ main = do args <- cmdArgsRun standard
else
printFormatting args
- where printFormat keyword seek rep = "%format " ++ seek ++ " = \" {\\lhsCH" ++ keyword ++ "{" ++ rep ++ "}}\""
+ where printFormat keyword (seek, rep) = "%format " ++ seek ++ " = \" {\\lhsCH" ++ keyword ++ "{" ++ rep ++ "}}\""
writeOutput output si mapping =
- mapM_ (\(keyword, f) -> mapM_ (\ (seek,rep) -> hPutStrLn output $ printFormat keyword seek rep)
+ mapM_ (\(keyword, f) -> mapM_ (hPutStrLn output . printFormat keyword)
(filter lhs2TeXSafe (f si))
)
mapping
- printFormatting args = do hOutput <- openFile (output args) WriteMode
- let writer = writeOutput hOutput
- hSetEncoding hOutput utf8
- mapM_ (\file -> runHaskell file
- >>= flip writer Literate.Haskell.mapping)
- (input args)
+ printFormatting args = do hOutput <- openUTF8File (output args)
+ let writer = flip $ writeOutput hOutput
+ files <- fmap (nub . concat)
+ (mapM discoverFiles (input args))
+
+ mapM_ ((writer Literate.Haskell.mapping =<<) . runHaskell)
+ files
hClose hOutput
goUTF8 = do hSetEncoding stdin utf8
hSetEncoding stdout utf8
- hSetEncoding stderr utf8
+ hSetEncoding stderr utf8
+ openUTF8File fp = do hOutput <- openFile fp WriteMode
+ hSetEncoding hOutput utf8
+ return hOutput
discoverFiles :: FilePath -> IO [FilePath]
discoverFiles fp = do contents <- fmap (\xs -> [base ++ x | Just x <- map runPInclude (lines xs)])
@@ -68,7 +72,7 @@ discoverFiles fp = do contents <- fmap (\xs -> [base ++ x | Just x <- map runPI
where files = undefined
base = takeDirectory fp ++ "/"
-
+runPInclude :: String -> Maybe String
runPInclude xs@('%':_) = runParse pInclude xs
runPInclude _ = Nothing

0 comments on commit 5df0b52

Please sign in to comment.