- Commit
- 6d239e74bc5d61cfdaaab195adde2558afa32301
- Parent
- d948cb2b921ef0384015bbd432d8b7a7015fee11
- Author
- John MacFarlane <jgm@berkeley.edu>
- Date
Improved spec.pdf production.
Boldface definitions.
My personal build of CMark ✏️
Improved spec.pdf production.
Boldface definitions.
2 files changed, 10 insertions, 8 deletions
Status | File Name | N° Changes | Insertions | Deletions |
Modified | makespec.py | 5 | 4 | 1 |
Modified | specfilter.hs | 13 | 6 | 7 |
diff --git a/makespec.py b/makespec.py @@ -20,7 +20,10 @@ def pipe_through_prog(prog, text): def replaceAnchor(match): refs.append("[{0}]: #{1}".format(match.group(1), match.group(2))) - return '<a id="{1}" href="#{1}" class="definition">{0}</a>'.format(match.group(1), match.group(2)) + if specformat == "html": + return '<a id="{1}" href="#{1}" class="definition">{0}</a>'.format(match.group(1), match.group(2)) + else: + return match.group(0) stage = 0 example = 0
diff --git a/specfilter.hs b/specfilter.hs @@ -1,11 +1,11 @@ #!/usr/bin/env runhaskell import Text.Pandoc.JSON -import Text.Pandoc.Walk +import Text.Pandoc.Generic main = toJSONFilter go where go :: Pandoc -> Pandoc - go = walk exampleDivs . walk anchors + go = bottomUp exampleDivs . bottomUp (concatMap anchors) exampleDivs :: Block -> Block exampleDivs (Div (ident, ["example"], kvs) @@ -30,8 +30,7 @@ exampleDivs (Div (ident, ["example"], kvs) else code exampleDivs x = x -anchors :: Inline -> Inline -anchors (RawInline (Format "html") ('<':'a':' ':'i':'d':'=':'"':xs)) = - RawInline (Format "latex") ("\\hyperdef{}{" ++ lab ++ "}{\\label{" ++ lab ++ "}}") - where lab = takeWhile (/='"') xs -anchors x = x +anchors :: Inline -> [Inline] +anchors (Link text ('@':lab,_)) = + [RawInline (Format "latex") ("\\hyperdef{}{" ++ lab ++ "}{\\label{" ++ lab ++ "}}"), Strong text] +anchors x = [x]