blatex 0.1.0.5 → 0.1.0.6
raw patch · 3 files changed
+15/−18 lines, 3 files
Files
- Files.hs +1/−1
- Main.hs +13/−16
- blatex.cabal +1/−1
Files.hs view
@@ -5,7 +5,7 @@ exampleTeXPost = unlines [ "\\documentclass{article}" , "\\author{Rushi Shah}"- , "\\date{January 2015}"+ , "\\date{1 January 2015}" , "\\title{Example Post}" , "\\begin{document}" , "\\maketitle"
Main.hs view
@@ -60,23 +60,20 @@ show (Post fn t a d _) = fn ++ " is a post called " ++ t ++ " written by " ++ (a) getPDF :: FilePath -> Maybe String-getPDF xs = if splitUp !! 1 == "pdf" then Just (splitUp !! 0) else Nothing+getPDF xs = if length splitUp == 2 + then + if splitUp !! 1 == "pdf" + then Just (splitUp !! 0) + else Nothing+ else Nothing where splitUp = splitOn "." xs -extractCommandArgs :: String -> LaTeX -> Maybe [TeXArg]-extractCommandArgs s (TeXSeq lt rt) = if isJust lst then lst else rst- where lst = extractCommandArgs s lt- rst = extractCommandArgs s rt-extractCommandArgs s (TeXComm name args)- | name == s = Just args- | otherwise = Nothing-extractCommandArgs _ _ = Nothing--extractFromArgs :: [TeXArg] -> Text-extractFromArgs ((FixArg (TeXRaw s)):xs) = s+extractFromArgs :: [[TeXArg]] -> Maybe Text+extractFromArgs (((FixArg (TeXRaw s)):_):_) = Just s+extractFromArgs _ = Nothing getCommandValue :: String -> LaTeX -> Maybe Text-getCommandValue s = (fmap extractFromArgs . extractCommandArgs s) +getCommandValue s = (extractFromArgs . lookForCommand s) --Converts either to maybe (for use by maybe applicative) --eToM :: Either a a -> Maybe a@@ -93,9 +90,9 @@ createPost _ (Left err) _ = Nothing createPost s (Right t) time = Post <$> pure s <*> title <*> author <*> date <*> pure t where - date = eToM (fmap (parseDate time) (fmap unpack (getCommandValue "date" t)))- author = fmap unpack (getCommandValue "author" t)- title = fmap unpack (getCommandValue "title" t)+ date = eToM (fmap (parseDate time) (unpack <$> (getCommandValue "date" t)))+ author = unpack <$> (getCommandValue "author" t)+ title = unpack <$> (getCommandValue "title" t) fileNameToPost :: String -> IO (Maybe Post) fileNameToPost fn = do
blatex.cabal view
@@ -2,7 +2,7 @@ -- documentation, see http://haskell.org/cabal/users-guide/ name: blatex-version: 0.1.0.5+version: 0.1.0.6 synopsis: Blog in LaTeX description: Static site generator that lets you write your blog in LaTeX and publish it to github pages. description: Markdown and HTML are the standard tools used to write your every day tech blog with. But they have pretty weak support for embedding mathematical formulas, and are not conducive to writing for an extended period of time. Plus, they aren't even Turing complete! So use BlaTeX to start blogging in LaTeX!