From 1d60b9bb3ac3c13becf930165cc06395a7c5ce69 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20P=C3=A9pin?= Date: Wed, 13 Apr 2016 21:26:11 +0200 Subject: [PATCH] Fix issues discussed in #11 --- Makefile | 4 ++-- filters/asciimath | 2 +- filters/nice-frac.hs | 26 -------------------------- filters/usual-fun.hs | 33 --------------------------------- notes.md | 9 +++++++-- 5 files changed, 10 insertions(+), 64 deletions(-) delete mode 100644 filters/nice-frac.hs delete mode 100644 filters/usual-fun.hs diff --git a/Makefile b/Makefile index be5f167..f369c0e 100644 --- a/Makefile +++ b/Makefile @@ -4,7 +4,7 @@ ASCIIMATH=filters/asciimath/pandoc-asciimath HS_FILTERS_NAMES = PY_FILTERS_NAMES = pandoc-svg.py -EXT_FILTERS = $(ASCIIMATH) +EXT_FILTERS = pandoc-crossref $(ASCIIMATH) HS_FILTERS = $(addprefix filters/, $(HS_FILTERS_NAMES)) PY_FILTERS = $(addprefix filters/, $(PY_FILTERS_NAMES)) @@ -21,7 +21,7 @@ $(HS_FILTERS): ghc --make $@.hs -o $@ $(ASCIIMATH): - (cd filters/asciimath; make) + (cd filters/asciimath; make filter-only) clean: rm -f $(OUT) diff --git a/filters/asciimath b/filters/asciimath index d68cf88..1848358 160000 --- a/filters/asciimath +++ b/filters/asciimath @@ -1 +1 @@ -Subproject commit d68cf88317451fc4ae04244802a0992afe91b6b7 +Subproject commit 18483581cecdbffe97810eb0e7292c030fcbf4d9 diff --git a/filters/nice-frac.hs b/filters/nice-frac.hs deleted file mode 100644 index a4732a4..0000000 --- a/filters/nice-frac.hs +++ /dev/null @@ -1,26 +0,0 @@ --- nice-frac.hs - -import Text.Pandoc.JSON -import Text.Regex - --- Usefull regex elements -space :: String -space = "[ \\t\\n\\r]*" -num :: String -num = "([0-9]+)" - --- Replace fractions like "(42 / 1)" by "\frac{42}{1}" -fracReg :: Regex -fracReg = mkRegex $ - "\\(" ++ space ++ num ++ space ++ "/" ++ space ++ num ++ space ++ "\\)" -frac :: String -> String -frac s = subRegex fracReg s "\\\\frac{\\1}{\\2}" - --- Apply the substitution to all Latex parts on the AST -niceFrac :: Inline -> Inline -niceFrac (Math t s) = Math t (frac s) -niceFrac x = x - -main :: IO () -main = toJSONFilter niceFrac - diff --git a/filters/usual-fun.hs b/filters/usual-fun.hs deleted file mode 100644 index 00fb098..0000000 --- a/filters/usual-fun.hs +++ /dev/null @@ -1,33 +0,0 @@ --- usual-fun.hs - -import Text.Pandoc.JSON -import Text.Regex -import Data.List (intercalate) - --- Association list for usual functions -usual :: String -usual = intercalate "|" [ - "cos", "sin", "tan", "cotan", - "arccos", "arcsin", "arctan", - "exp", "log"] - --- Remove the '\' before usual functions' names if present -rmBSReg :: Regex -rmBSReg = mkRegex $ "(\\\\)(" ++ usual ++ ")\\>" -rmBS :: String -> String -rmBS s = subRegex rmBSReg s "\\2" - --- Add a '\' before usual functions' names -addBSReg :: Regex -addBSReg = mkRegex $ "\\<(" ++ usual ++ ")\\>" -addBS :: String -> String -addBS s = subRegex addBSReg s "\\\\\\0" - --- Apply the substitution to all Latex parts on the AST -niceFrac :: Inline -> Inline -niceFrac (Math t s) = Math t (addBS . rmBS $ s) -niceFrac x = x - -main :: IO () -main = toJSONFilter niceFrac - diff --git a/notes.md b/notes.md index 0953d9d..6f87ad4 100644 --- a/notes.md +++ b/notes.md @@ -1,7 +1,7 @@ --- # Metadata title: Example -author: Martin Pépin +author: Kerl13 & Phyks date: \today # Pandoc-crossref options cref: True @@ -12,5 +12,10 @@ chapters: True # AsciiMath example -Soit $n in NN$, alors on a +The following asciimath code + + sum_(k=1)^n k^3 = ((n(n+1))/2)^2 + +will be rendered the following way + $$ sum_(k=1)^n k^3 = ((n(n+1))/2)^2 $$