summaryrefslogtreecommitdiff
path: root/src/Site.hs
diff options
context:
space:
mode:
Diffstat (limited to 'src/Site.hs')
-rw-r--r--src/Site.hs7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/Site.hs b/src/Site.hs
index d3ac76d..03b6e16 100644
--- a/src/Site.hs
+++ b/src/Site.hs
@@ -170,7 +170,7 @@ getTex pattern makeId = do
170 getTex' :: FilePath -> Rules [String] 170 getTex' :: FilePath -> Rules [String]
171 getTex' path = preprocess . fmap concat $ (\x -> [query extractTex, query extractTex'] <*> pure x) `liftM` readPandoc' path 171 getTex' path = preprocess . fmap concat $ (\x -> [query extractTex, query extractTex'] <*> pure x) `liftM` readPandoc' path
172 extractTex :: Inline -> [String] 172 extractTex :: Inline -> [String]
173 extractTex (Math _ str) = ["\\(" ++ str ++ "\\)"] 173 extractTex (Math _ str) = [wrapMath str]
174 extractTex (RawInline "latex" str) = [str] 174 extractTex (RawInline "latex" str) = [str]
175 extractTex _ = [] 175 extractTex _ = []
176 extractTex' :: Block -> [String] 176 extractTex' :: Block -> [String]
@@ -181,6 +181,9 @@ getTex pattern makeId = do
181 mergeGroups' :: [([Identifier], String)] -> ([Identifier], String) 181 mergeGroups' :: [([Identifier], String)] -> ([Identifier], String)
182 mergeGroups' xs@((_, str):_) = (concatMap fst xs, str) 182 mergeGroups' xs@((_, str):_) = (concatMap fst xs, str)
183 183
184wrapMath :: String -> String
185wrapMath str = "\\(" ++ str ++ "\\)"
186
184readPandoc' :: FilePath -> IO Pandoc 187readPandoc' :: FilePath -> IO Pandoc
185readPandoc' path = readFile path >>= either fail return . result' 188readPandoc' path = readFile path >>= either fail return . result'
186 where 189 where
@@ -211,7 +214,7 @@ texTransform :: Pandoc -> Compiler Pandoc
211texTransform = walkM texTransformInline <=< walkM texTransformBlock 214texTransform = walkM texTransformInline <=< walkM texTransformBlock
212 where 215 where
213 texTransformInline :: Inline -> Compiler Inline 216 texTransformInline :: Inline -> Compiler Inline
214 texTransformInline (Math mathType tex) = (\html -> Span ("", [classOf mathType], []) [RawInline "html" html]) <$> texTransform' ("\\(" ++ tex ++ "\\)") 217 texTransformInline (Math mathType tex) = (\html -> Span ("", [classOf mathType], []) [RawInline "html" html]) <$> texTransform' (wrapMath tex)
215 texTransformInline (RawInline "latex" tex) = (\html -> Span ("", [], []) [RawInline "html" html]) <$> texTransform' tex 218 texTransformInline (RawInline "latex" tex) = (\html -> Span ("", [], []) [RawInline "html" html]) <$> texTransform' tex
216 texTransformInline x = return x 219 texTransformInline x = return x
217 texTransformBlock :: Block -> Compiler Block 220 texTransformBlock :: Block -> Compiler Block