diff options
Diffstat (limited to 'src/Hakyll/TeX')
| -rw-r--r-- | src/Hakyll/TeX/BibTeX.hs | 5 | ||||
| -rw-r--r-- | src/Hakyll/TeX/HaTeX.hs | 6 | ||||
| -rw-r--r-- | src/Hakyll/TeX/LaTeX.hs | 6 |
3 files changed, 10 insertions, 7 deletions
diff --git a/src/Hakyll/TeX/BibTeX.hs b/src/Hakyll/TeX/BibTeX.hs index b085dfa..434ca54 100644 --- a/src/Hakyll/TeX/BibTeX.hs +++ b/src/Hakyll/TeX/BibTeX.hs @@ -13,7 +13,8 @@ import Text.BibTeX.Entry qualified as B import Text.BibTeX.Format qualified as B import Text.BibTeX.Parse qualified as B import Text.Parsec qualified as P -import Text.Parsec.Error qualified as P + +import Hakyll.Parsec.Parsec type BibTeX = B.T @@ -28,7 +29,7 @@ instance Writable [B.T] where compileBibtex :: (StringConv s String) => Item s -> Compiler (Item [B.T]) -compileBibtex (Item i b) = either (throwError . fmap P.messageString . P.errorMessages) (pure . Item i) $ P.parse p (show i) (toSL b) +compileBibtex = compileParsec_ p . fmap toSL where p = B.skippingLeadingSpace $ B.file <* P.eof diff --git a/src/Hakyll/TeX/HaTeX.hs b/src/Hakyll/TeX/HaTeX.hs index 9b83c62..c71ad09 100644 --- a/src/Hakyll/TeX/HaTeX.hs +++ b/src/Hakyll/TeX/HaTeX.hs @@ -6,10 +6,12 @@ module Hakyll.TeX.HaTeX import Prolog import Hakyll +import Hakyll.Error +-- import Hakyll.Parsec.Parsec import Text.LaTeX.Base.Parser -compileHatex :: (StringConv s Text, Traversable t) => t s -> Compiler (t LaTeX) -compileHatex = traverse $ either (throwError . fmap messageString . errorMessages) pure . parseLaTeX . toSL +compileHatex :: (StringConv s Text, Traversable t, MonadError [String] m) => t s -> m (t LaTeX) +compileHatex = traverse $ liftErr . parseLaTeX . toSL hatexCompiler :: Compiler (Item LaTeX) hatexCompiler = getResourceLBS >>= compileHatex diff --git a/src/Hakyll/TeX/LaTeX.hs b/src/Hakyll/TeX/LaTeX.hs index 8f6d5cc..66f3ba5 100644 --- a/src/Hakyll/TeX/LaTeX.hs +++ b/src/Hakyll/TeX/LaTeX.hs @@ -8,11 +8,11 @@ import Prolog import Hakyll -rubberPipe :: [String] -> LazyByteString -> Compiler LazyByteString -rubberPipe = unixFilterLBS "rubber-pipe" +rubberPipe :: (StringConv s LazyByteString) => [String] -> s -> Compiler LazyByteString +rubberPipe args = unixFilterLBS "rubber-pipe" args . toSL compileLatexPdf :: (StringConv s LazyByteString, Traversable t) => t s -> Compiler (t LazyByteString) -compileLatexPdf = traverse $ rubberPipe [ "--pdf" ] . toSL +compileLatexPdf = traverse $ rubberPipe [ "--pdf" ] latexPdfCompiler :: Compiler (Item LazyByteString) latexPdfCompiler = getResourceLBS >>= compileLatexPdf |
