Fix issues discussed in #11
This commit is contained in:
parent
5d0cd2d54e
commit
1d60b9bb3a
4
Makefile
4
Makefile
@ -4,7 +4,7 @@ ASCIIMATH=filters/asciimath/pandoc-asciimath
|
|||||||
|
|
||||||
HS_FILTERS_NAMES =
|
HS_FILTERS_NAMES =
|
||||||
PY_FILTERS_NAMES = pandoc-svg.py
|
PY_FILTERS_NAMES = pandoc-svg.py
|
||||||
EXT_FILTERS = $(ASCIIMATH)
|
EXT_FILTERS = pandoc-crossref $(ASCIIMATH)
|
||||||
|
|
||||||
HS_FILTERS = $(addprefix filters/, $(HS_FILTERS_NAMES))
|
HS_FILTERS = $(addprefix filters/, $(HS_FILTERS_NAMES))
|
||||||
PY_FILTERS = $(addprefix filters/, $(PY_FILTERS_NAMES))
|
PY_FILTERS = $(addprefix filters/, $(PY_FILTERS_NAMES))
|
||||||
@ -21,7 +21,7 @@ $(HS_FILTERS):
|
|||||||
ghc --make $@.hs -o $@
|
ghc --make $@.hs -o $@
|
||||||
|
|
||||||
$(ASCIIMATH):
|
$(ASCIIMATH):
|
||||||
(cd filters/asciimath; make)
|
(cd filters/asciimath; make filter-only)
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
rm -f $(OUT)
|
rm -f $(OUT)
|
||||||
|
@ -1 +1 @@
|
|||||||
Subproject commit d68cf88317451fc4ae04244802a0992afe91b6b7
|
Subproject commit 18483581cecdbffe97810eb0e7292c030fcbf4d9
|
@ -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
|
|
||||||
|
|
@ -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
|
|
||||||
|
|
9
notes.md
9
notes.md
@ -1,7 +1,7 @@
|
|||||||
---
|
---
|
||||||
# Metadata
|
# Metadata
|
||||||
title: Example
|
title: Example
|
||||||
author: Martin Pépin
|
author: Kerl13 & Phyks
|
||||||
date: \today
|
date: \today
|
||||||
# Pandoc-crossref options
|
# Pandoc-crossref options
|
||||||
cref: True
|
cref: True
|
||||||
@ -12,5 +12,10 @@ chapters: True
|
|||||||
|
|
||||||
# AsciiMath example
|
# 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 $$
|
$$ sum_(k=1)^n k^3 = ((n(n+1))/2)^2 $$
|
||||||
|
Loading…
Reference in New Issue
Block a user