verkilo 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,107 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <!DOCTYPE html>
3
+ <html xmlns="http://www.w3.org/1999/xhtml" xmlns:epub="http://www.idpf.org/2007/ops"$if(lang)$ xml:lang="$lang$"$endif$>
4
+ <head>
5
+ <meta charset="utf-8" />
6
+ <meta name="generator" content="FRED Verkilo (pandoc)" />
7
+ <title>$pagetitle$</title>
8
+ <style type="text/css">
9
+ code{white-space: pre-wrap;}
10
+ span.smallcaps{font-variant: small-caps;}
11
+ span.underline{text-decoration: underline;}
12
+ div.column{display: inline-block; vertical-align: top; width: 50%;}
13
+ h1,h2,h3,h4{font-family: sans-serif;}
14
+ $if(quotes)$
15
+ q { quotes: "“" "”" "‘" "’"; }
16
+ $endif$
17
+ </style>
18
+ $if(highlighting-css)$
19
+ <style type="text/css">
20
+ $highlighting-css$
21
+ </style>
22
+ $endif$
23
+ $for(css)$
24
+ <link rel="stylesheet" type="text/css" href="$css$" />
25
+ $endfor$
26
+ $for(header-includes)$
27
+ $header-includes$
28
+ $endfor$
29
+ </head>
30
+ <body$if(coverpage)$ id="cover"$endif$$if(body-type)$ epub:type="$body-type$"$endif$>
31
+ $if(titlepage)$
32
+ <section epub:type="titlepage" class='frontmatter'>
33
+ $for(title)$
34
+ $if(title.type)$
35
+ <h1 class="$title.type$">$title.text$</h1>
36
+ $else$
37
+ <h1 class="title">$title$</h1>
38
+ $endif$
39
+ $endfor$
40
+ $if(subtitle)$
41
+ <p class="subtitle">$subtitle$</p>
42
+ $endif$
43
+ $for(author)$
44
+ <p class="author">$author$</p>
45
+ $endfor$
46
+ $for(creator)$
47
+ <p class="$creator.role$">$creator.text$</p>
48
+ $endfor$
49
+ $if(publisher)$
50
+ <p class="publisher">$publisher$</p>
51
+ $endif$
52
+ $if(date)$
53
+ <p class="date">$date$</p>
54
+ $endif$
55
+ $if(rights)$
56
+ <div class="rights">$rights$</div>
57
+ $endif$
58
+ $if(isbn)$
59
+ <ul class="credits">
60
+ $for(isbn)$
61
+ <li>$isbn$</li>
62
+ $endfor$
63
+ </ul>
64
+ $endif$
65
+ $if(reservation)$
66
+ <div class="reservation">$reservation$</div>
67
+ $endif$
68
+ $if(disclaimer)$
69
+ <div class="disclaimer">$disclaimer$</div>
70
+ $endif$
71
+
72
+ <ul class='credits'>
73
+ <li> Interior Design: Merovex Press </li>
74
+ $for(credits)$
75
+ <li>$credits$</li>
76
+ $endfor$
77
+ </ul>
78
+
79
+ $for(author)$
80
+ <p>
81
+ $author$
82
+ </p>
83
+ $endfor$
84
+
85
+ $if(website)$
86
+ <p>
87
+ Visit us at <a href="$website$">$website$</a>
88
+ </p>
89
+ $endif$
90
+
91
+ $if(country)$
92
+ <p>
93
+ $country$
94
+ </p>
95
+ $endif$
96
+ </section>
97
+ $else$
98
+ $for(include-before)$
99
+ $include-before$
100
+ $endfor$
101
+ $body$
102
+ $for(include-after)$
103
+ $include-after$
104
+ $endfor$
105
+ $endif$
106
+ </body>
107
+ </html>
@@ -0,0 +1,125 @@
1
+
2
+ \makeevenhead{myheadings}{\thepage}{\footnotesize\MakeUppercase\theauthor}{}
3
+ \makeoddhead{myheadings}{}{\footnotesize\MakeUppercase{$title$}}{\thepage}
4
+ % ===============================================
5
+ % Frontmatter
6
+ \newlength\drop
7
+ \thispagestyle{empty}
8
+ \begingroup
9
+ \setlength\drop{0.2\textheight}
10
+ % ------------------------------------------------
11
+ % r.1 - Half-Title - Recto
12
+ \thispagestyle{empty}
13
+ \begin{center}
14
+ \vspace*{\drop}
15
+ {\LARGE \textsf{\thetitle}}
16
+ \end{center}
17
+ \clearpage
18
+
19
+ % ------------------------------------------------
20
+ % r.2 - Series Title Page - Verso
21
+ \newpage
22
+ \thispagestyle{empty}
23
+
24
+ $if(other-titles)$
25
+ \begin{center}
26
+ \noindent{\Large Also by $author$}
27
+
28
+ $for(other-titles)$
29
+ \vspace{6mm}
30
+ \noindent{ \textbf{$other-titles.name$}}
31
+
32
+ ${if(other-titles.tag)}
33
+ \noindent{}${other-titles.tag}
34
+ ${endif}
35
+ \vspace{3mm}
36
+
37
+ $for(other-titles.books)$
38
+ \noindent{}\emph{${other-titles.books}}
39
+
40
+ $endfor$
41
+ $endfor$
42
+ \end{center}
43
+ $endif$
44
+ \clearpage
45
+
46
+ % ------------------------------------------------
47
+ % r.3 Titlepage - Recto
48
+ \thispagestyle{empty}
49
+ \begin{center}
50
+ \vspace*{\drop}
51
+ {\Huge \textsf{\thetitle}}
52
+
53
+ $if(subtitle)$
54
+ \vspace*{3mm}
55
+ {\LARGE\itshape $subtitle$}
56
+ $endif$
57
+
58
+ \vspace*{7mm}
59
+ \line(1,0){150}
60
+ \vspace*{7mm}
61
+
62
+ {\Large $author$}
63
+
64
+ \vspace*{2\drop}
65
+ $if(imprint)$
66
+ \includegraphics[width=26mm]{$imprint$}\\[0cm]
67
+ \vspace*{7mm}
68
+ $endif$
69
+ \end{center}
70
+ \clearpage
71
+ \thispagestyle{empty}
72
+ \newpage
73
+ \endgroup
74
+ % ------------------------------------------------
75
+ % r.4 Copyright Page
76
+ \thispagestyle{empty}
77
+ \vspace*{\fill}
78
+
79
+ \par\noindent\emph{\thetitle}\newline
80
+ \par\noindent\emph{$rights$}\newline
81
+
82
+ \footnotesize
83
+ $if(reservation)$\par\noindent $reservation$\newline$endif$
84
+
85
+ $for(isbn)$
86
+ \par\noindent ISBN $isbn$
87
+ $endfor$\newline
88
+
89
+ \footnotesize
90
+ $if(disclaimer)$\par\noindent $disclaimer$\newline$endif$
91
+
92
+ % Producer Acknowledgements
93
+ \par\noindent Interior Design: Merovex Press % Per license terms for use of template.
94
+ $for(credits)$
95
+ \par\noindent $credits$
96
+ $endfor$\newline
97
+
98
+ \par $for(author)$
99
+ \par\noindent $author$
100
+ $endfor$\newline
101
+
102
+ $if(website)$
103
+ \par\noindent Visit us at \url{$website$}\newline
104
+ $endif$
105
+
106
+ \par\noindent $country$
107
+ \newline
108
+
109
+ $if(printing)$
110
+ \par\noindent\textit{$printing$}
111
+ \newline
112
+ $endif$
113
+
114
+ $if(version)$
115
+ \par\noindent Version: $version$
116
+ $endif$
117
+ \vspace*{\fill}
118
+ \clearpage\normalsize
119
+ \pagenumbering{roman}
120
+ % -----------------------------------------------
121
+ % r.5 - Dedication
122
+ $if(thanks)$
123
+ $thanks$
124
+ \newpage
125
+ $endif$
@@ -0,0 +1,10 @@
1
+ % Dates
2
+ %-------
3
+ \usepackage{datetime}
4
+ \newdateformat{yearonly}{\THEYEAR}
5
+ \newdateformat{usmonthyear}{\monthname[\THEMONTH], \THEYEAR}
6
+ \newcommand{\monthyear}{%
7
+ \ifcase\month\or January\or February\or March\or April\or May\or June\or
8
+ July\or August\or September\or October\or November\or
9
+ December\fi\space\number\year
10
+ }
@@ -0,0 +1,88 @@
1
+ % ===============================================
2
+ % Bringing PlainFancyBreak from Memoir class.
3
+ \makeatletter
4
+ \newcommand{\plainfancybreak}{\@ifstar{\@spfbreak}{\@pfbreak}}
5
+ \newcommand{\@pfbreak}[3]{\par
6
+ \@tempdimc\pagegoal \advance\@tempdimc-\pagetotal
7
+ \ifdim #1>\@tempdimc \@fbreak{#3}\else \@pbreak{#2}\fi}
8
+ \newcommand{\@spfbreak}[3]{\par
9
+ \@tempdimc\pagegoal \advance\@tempdimc-\pagetotal
10
+ \ifdim #1>\@tempdimc \@sfbreak{#3}\else \@spbreak{#2}\fi}
11
+
12
+ \newcommand*{\pen@ltyabovepfbreak}{2}
13
+ \newcommand*{\pen@ltybelowpfbreak}{-4}
14
+
15
+ \newlength{\pfbreakskip}
16
+ \setlength{\pfbreakskip}{2\baselineskip}
17
+ $if(fancybreak)$
18
+ \newcommand{\pfbreakdisplay}{$fancybreak$}
19
+ $else$
20
+ \newcommand{\pfbreakdisplay}{* \quad * \quad*}
21
+ $endif$
22
+
23
+ \def\pfbre@kdispl@y{\vbox to 1\pfbreakskip{\vss
24
+ \hb@xt@ \columnwidth{\hss \pfbreakdisplay \hss}%
25
+ \vss}}
26
+
27
+ \edef\nopfbreakOutput{\the\output}
28
+ \def\pfbreakOutput{%
29
+ \ifnum\outputpenalty=\pen@ltyabovepfbreak
30
+ \nopfbreakOutput
31
+ \pfbre@kdispl@y
32
+ \nobreak
33
+ \vskip-\pfbreakskip
34
+ \else\ifnum\outputpenalty=\pen@ltybelowpfbreak
35
+ \unvbox 255\relax
36
+ \nobreak
37
+ \vskip-\pfbreakskip
38
+ \pfbre@kdispl@y
39
+ \break
40
+ \else
41
+ \nopfbreakOutput
42
+ \fi
43
+ \fi}
44
+ \output={\pfbreakOutput}
45
+
46
+ \newcommand{\pfbreak}{\@ifstar{\@spfbreakgap}{\@pfbreakgap}}
47
+ \newcommand{\@pfbreakgap}{%
48
+ \par {%
49
+ \skip@\lastskip
50
+ \nobreak
51
+ \vskip -\ifdim\prevdepth>\maxdepth \maxdepth
52
+ \else\ifdim\prevdepth>-1000pt\prevdepth
53
+ \else\ifinner 0pt
54
+ \else \pagedepth
55
+ \fi \fi \fi
56
+ \vskip -\skip@
57
+ \ifdim\skip@<\pfbreakskip
58
+ \advance\skip@ -1\skip@ \advance\skip@ 1\pfbreakskip
59
+ \fi
60
+ \penalty\pen@ltyabovepfbreak
61
+ \vskip\skip@
62
+ \penalty\pen@ltybelowpfbreak
63
+ }
64
+ \@afterindentfalse
65
+ \@afterheading
66
+ }
67
+ \newcommand{\@spfbreakgap}{%
68
+ \par {%
69
+ \skip@\lastskip
70
+ \nobreak
71
+ \vskip -\ifdim\prevdepth>\maxdepth \maxdepth
72
+ \else\ifdim\prevdepth>-1000pt\prevdepth
73
+ \else\ifinner 0pt
74
+ \else \pagedepth
75
+ \fi \fi \fi
76
+ \vskip -\skip@
77
+ \ifdim\skip@<\pfbreakskip
78
+ \advance\skip@ -1\skip@ \advance\skip@ 1\pfbreakskip
79
+ \fi
80
+ \penalty\pen@ltyabovepfbreak
81
+ \vskip\skip@
82
+ \penalty\pen@ltybelowpfbreak
83
+ }
84
+ \@afterindenttrue
85
+ \@afterheading
86
+ }
87
+ \makeatother
88
+ % /PlainFancyBreak
@@ -0,0 +1,19 @@
1
+ \usepackage{fontspec}
2
+ \usepackage{xunicode}
3
+ \usepackage{xltxtra}
4
+
5
+ $if(seriffont)$
6
+ \setmainfont{$seriffont$}
7
+ $else$
8
+ \setmainfont{Libre Baskerville}
9
+ $endif$
10
+ $if(sansfont)$
11
+ \setsansfont{$sansfont$}
12
+ $else$
13
+ \setsansfont{Libre Franklin}
14
+ $endif$
15
+ $if(monofont)$
16
+ \setmonofont{$monofont$}
17
+ $else$
18
+ \setmonofont{Inconsolata}
19
+ $endif$
@@ -0,0 +1 @@
1
+ \usepackage[explicit]{titlesec}
@@ -0,0 +1,132 @@
1
+ -- This gives us plain fancy break in LaTeX.
2
+ local hashrule = [[<w:p>
3
+ <w:pPr>
4
+ <w:pStyle w:val="HorizontalRule"/>
5
+ <w:ind w:firstLine="0"/>
6
+ <w:jc w:val="center"/>
7
+ </w:pPr>
8
+ <w:r>
9
+ <w:t>#</w:t>
10
+ </w:r>
11
+ </w:p>]]
12
+ function HorizontalRule (elem)
13
+ -- print("FORMAT: " .. FORMAT)
14
+ if FORMAT == 'latex' then
15
+ return pandoc.RawBlock('latex', '\\pfbreak')
16
+ end
17
+ if FORMAT == 'docx' then
18
+ return pandoc.RawBlock('openxml', hashrule)
19
+ end
20
+ end
21
+ -- function dump(o)
22
+ -- if type(o) == 'table' then
23
+ -- local s = '{ '
24
+ -- for k,v in pairs(o) do
25
+ -- if type(k) ~= 'number' then k = '"'..k..'"' end
26
+ -- s = s .. '['..k..'] = ' .. dump(v) .. ','
27
+ -- end
28
+ -- return s .. '}\n '
29
+ -- else
30
+ -- return tostring(o)
31
+ -- end
32
+ -- end
33
+ -- width, height in millimeters
34
+ -- Demy = {138, 216},
35
+ local trimsizes = {
36
+ Novella = {127, 203}, -- 5" x 8"
37
+ UKBFormat = {129, 198}, -- 5.06" x 7.81" Never Split the Difference
38
+ SmallTrade = {133, 203}, -- 5.25" x 8" A Song of Stone
39
+ Digest = {140, 215}, -- 5.5" x 8.5"
40
+ Trade = {152, 229}, -- 6" x 9"
41
+ Royal = {156, 234}, -- 6.14" x 9.21" A Short History of Parliament
42
+ Textbook = {178, 254}, -- 7" x 10"
43
+ Crown = {189, 246}, -- 7.44" x 9.69"
44
+ LargeTrade = {203, 254}, -- 8" x 10"
45
+ A4 = {210, 297}, -- 8.27" x 11.69"
46
+ Letter = {216, 279}, -- 8.5" x 11"
47
+ Square = {216, 216} -- 8.5" x 8.5"
48
+ }
49
+
50
+ -- counts words in a document
51
+ words = 0
52
+ char = 0
53
+ wordcount = {
54
+ Str = function(el)
55
+ -- we don't count a word if it's entirely punctuation:
56
+ if el.text:match("%P") then
57
+ words = words + 1
58
+ end
59
+ char = char + el.text:len()
60
+ end,
61
+
62
+ Code = function(el)
63
+ _,n = el.text:gsub("%S+","")
64
+ words = words + n
65
+ char = char + el.text:len()
66
+ end,
67
+
68
+ CodeBlock = function(el)
69
+ _,n = el.text:gsub("%S+","")
70
+ words = words + n
71
+ char = char + el.text:len()
72
+ end
73
+ }
74
+ local function addFancyPageBreak(meta)
75
+ if type(meta.fancybreak) ~= 'table' then return meta end
76
+ local header_includes
77
+ local fancybreak = ""
78
+ for key, value in pairs(meta.fancybreak) do fancybreak = fancybreak .. value.text end
79
+
80
+ fancybreak = string.format(
81
+ [[\renewcommand{\pfbreakdisplay}{%s}\renewcommand*{\fancybreak}{\pfbreakdisplay}]]
82
+ , fancybreak)
83
+
84
+ if meta['header-includes'] and meta['header-includes'].t == 'MetaList' then
85
+ header_includes = meta['header-includes']
86
+ else
87
+ header_includes = pandoc.MetaList{meta['header-includes']}
88
+ end
89
+ header_includes[#header_includes + 1] =
90
+ pandoc.MetaBlocks{pandoc.RawBlock('latex', fancybreak)}
91
+ meta['header-includes'] = header_includes
92
+ return meta
93
+ end
94
+ function addTrimsizeGeometry(meta)
95
+ local key = pandoc.utils.stringify(meta.trimsize)
96
+ if trimsizes[key] == nil then
97
+ print("Invalid Trimsize, using 'Trade'. You used '"..key.."'.")
98
+ key = "Trade"
99
+ end
100
+
101
+ local trimsize = trimsizes[key]
102
+ local bindingoffset = 4 + math.floor(pages/80) -- Offset in MM by page.
103
+ table.insert(trimsize, bindingoffset)
104
+
105
+ meta.geometry = string.format(
106
+ [[
107
+ paperwidth=%dmm,paperheight=%dmm,
108
+ includeheadfoot=true,vscale=0.925,headsep=3mm,vcentering,
109
+ bindingoffset=%dmm,hscale=0.8,twoside]],
110
+ table.unpack(trimsize)
111
+ )
112
+ return meta
113
+ end
114
+
115
+ function Pandoc(doc)
116
+ pandoc.walk_block(pandoc.Div(doc.blocks), wordcount)
117
+ wchar = math.ceil(char / 5) -- Using the English norm of 5 characters per word.
118
+ pages = math.ceil(wchar / 330) + 6
119
+ local meta = doc.meta
120
+ meta.wordcount = string.format("%d",wchar)
121
+ meta.pagecount = string.format("%d",pages)
122
+
123
+ if FORMAT == 'latex' then
124
+ meta = addFancyPageBreak(meta)
125
+ meta = addTrimsizeGeometry(meta)
126
+
127
+ if (meta.fontsize == nil) then meta.fontsize = "10pt" end
128
+ if (meta.pagestyle == nil) then meta.pagestyle = "myheadings" end
129
+ -- print("Words.."..wchar)
130
+ end
131
+ return pandoc.Pandoc(doc.blocks, meta)
132
+ end