aboutsummaryrefslogtreecommitdiff
path: root/tools/specfilter.hs
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2016-01-08 12:15:31 -0800
committerJohn MacFarlane <jgm@berkeley.edu>2016-01-10 21:32:21 -0800
commit2413d436ed98866e9a70fbd4070a5da52dd97cd5 (patch)
tree0cacf842df8115e93e3de1ce9a1613cee13474be /tools/specfilter.hs
parent1357f2859ecb128636ea7a764b70407dca4e4015 (diff)
New format for spec tests, new lua formatter for specs.
The format for the spec examples has changed from . markdown . html . to ```````````````````````````````` example markdown . html ```````````````````````````````` One advantage of this is that `spec.txt` becomes a valid Markdown file. `tests/spec_test.py` has been changed to use the new format. The old `tools/makespec.py` has been replaced by a lua program, `tools/make_spec.lua`, which uses the `lcmark` rock (and indirectly libcmark). It can generate html, latex, and commonmark versions of the spec. Pandoc is no longer needed for the latex/PDF version. And, since the new program uses the cmark API and operates directly on the parse tree, we avoid certain bad results we got with the regex replacements done by the python script.
Diffstat (limited to 'tools/specfilter.hs')
-rwxr-xr-xtools/specfilter.hs39
1 files changed, 0 insertions, 39 deletions
diff --git a/tools/specfilter.hs b/tools/specfilter.hs
deleted file mode 100755
index 304e463..0000000
--- a/tools/specfilter.hs
+++ /dev/null
@@ -1,39 +0,0 @@
-#!/usr/bin/env runhaskell
-
-import Text.Pandoc.JSON
-import Text.Pandoc.Walk
-import Text.Pandoc.Generic
-
-main = toJSONFilter go
- where go :: Pandoc -> Pandoc
- go = bottomUp exampleDivs . bottomUp (concatMap anchors)
-
-exampleDivs :: Block -> Block
-exampleDivs (Div (ident, ["example"], kvs)
- [ d@(Div (_,["examplenum"],_) _),
- d1@(Div (_,["column"],_) _),
- d2@(Div (_,["column"],_) _)
- ]) = Div (ident, ["example"], kvs)
- [ rawtex "\\begin{minipage}[t]{\\textwidth}\n{\\scriptsize "
- , d
- , rawtex "}\\vspace{-0.4em}\n"
- , rawtex "\\begin{minipage}[t]{0.49\\textwidth}\n\\definecolor{shadecolor}{gray}{0.85}\n\\begin{snugshade}\\small\n"
- , walk addBreaks d1
- , rawtex "\\end{snugshade}\n\\end{minipage}\n\\hfill\n\\begin{minipage}[t]{0.49\\textwidth}\n\\definecolor{shadecolor}{gray}{0.95}\n\\begin{snugshade}\\small\n"
- , walk addBreaks d2
- , rawtex "\\end{snugshade}\n\\end{minipage}\n\\end{minipage}"
- ]
- where rawtex = RawBlock (Format "latex")
- addBreaks (CodeBlock attrs code) = CodeBlock attrs $ addBreaks' code
- addBreaks x = x
- addBreaks' code =
- if length code > 49
- then take 49 code ++ ('\n':addBreaks' (drop 49 code))
- else code
-exampleDivs x = x
-
-anchors :: Inline -> [Inline]
-anchors (Link text ('@':lab,_)) =
- [RawInline (Format "latex") ("\\hyperdef{}{" ++ lab ++ "}{\\label{" ++ lab ++ "}}"), Strong text]
-anchors (Span ("",["number"],[]) xs) = [] -- remove sect numbers
-anchors x = [x]