-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpandoc-cv.hs
60 lines (55 loc) · 1.88 KB
/
pandoc-cv.hs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
--------------------------------------------------------------------------------
{-# LANGUAGE OverloadedStrings #-}
--------------------------------------------------------------------------------
import Text.Pandoc.JSON
import Text.Pandoc
( writeLaTeX )
import Text.Pandoc.Options
( def )
import Utils
import Data.List
( intercalate
, elem )
--------------------------------------------------------------------------------
main :: IO ()
main = toJSONFilter cvList
cvList :: Maybe Format -> Block -> [Block]
cvList (Just "latex") (Div (_, cs, _) contents)
| "aside" `elem` cs
= [ latexBlock "\\begin{aside}" ]
++ contents
++ [ latexBlock $ unlines
[ "\\end{aside}"
, "\\hspace{0.5cm}"
, "\\begin{minipage}[t]{\\linewidth-0.5\\asidewidth}"
, "\\minipageopentrue"
, "\\vspace*{0.9\\baselineskip}"
]
]
cvList (Just "latex") (DefinitionList contents)
= [latexBlock "\\begin{entrylist}"]
++ map toEntry contents
++ [latexBlock "\\end{entrylist}"]
cvList (Just "latex") (RawBlock "html" "<!-- break -->")
= return
$ latexBlock $ unlines
[ "\\ifminipageopen"
, "\\end{minipage}"
, "\\fi"
, "\\minipageopenfalse"
]
cvList _ x = [x]
toEntry :: ([Inline], [[Block]]) -> Block
toEntry (date, definitions)
= latexBlock
$ "\\entry{"
++ intercalate
"}{"
(addBreaks (map (writeLaTeX def . Pandoc nullMeta)
(take 4 $ [Plain date] : definitions ++ repeat [Null]) ))
++ "}"
where
addBreaks
= zipWith (\ i e -> if i == 3 && not (null e) then "\\\\" ++ e else e)
[0..]
--------------------------------------------------------------------------------