Skip to content

Commit 43d000b

Browse files
committedJul 21, 2020
updated pandoc customization
1 parent 8c09c00 commit 43d000b

15 files changed

+227
-66
lines changed
 

Diff for: ‎_posts/2019-03-11-customizing-pandoc.md

+62-51
Large diffs are not rendered by default.

Diff for: ‎files/pandoc_pdf/cover.png

7 KB
Loading

Diff for: ‎files/pandoc_pdf/cover.tex

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
\includegraphics{cover.png}
2+
\thispagestyle{empty}

Diff for: ‎files/pandoc_pdf/epub.css

+108
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
/* This defines styles and classes used in the book */
2+
/* body { margin: 5%; text-align: justify; font-size: medium; }
3+
code { font-family: monospace; }
4+
h1 { text-align: left; }
5+
h2 { text-align: left; }
6+
h3 { text-align: left; } */
7+
h4 { text-align: left; }
8+
h5 { text-align: left; }
9+
h6 { text-align: left; }
10+
h1.title { }
11+
h2.author { }
12+
h3.date { }
13+
nav#toc ol,
14+
nav#landmarks ol { padding: 0; margin-left: 1em; }
15+
nav#toc ol li,
16+
nav#landmarks ol li { list-style-type: none; margin: 0; padding: 0; }
17+
a.footnote-ref { vertical-align: super; }
18+
em, em em em, em em em em em { font-style: italic;}
19+
em em, em em em em { font-style: normal; }
20+
/* code{ white-space: pre-wrap; } */
21+
span.smallcaps{ font-variant: small-caps; }
22+
span.underline{ text-decoration: underline; }
23+
q { quotes: "“" "”" "‘" "’"; }
24+
div.column{ display: inline-block; vertical-align: top; width: 50%; }
25+
div.hanging-indent{margin-left: 1.5em; text-indent: -1.5em;}
26+
27+
body {
28+
font-family: "DejaVu Serif", serif;
29+
margin: 5% 5% 20% 5%;
30+
text-align: justify;
31+
font-size: 0.75em;
32+
line-height: 1.5;
33+
}
34+
35+
h1 {
36+
text-align: left;
37+
font-size: 2em;
38+
}
39+
40+
h2 {
41+
text-align: left;
42+
}
43+
44+
h3 {
45+
text-align: left;
46+
}
47+
48+
h1.title {
49+
text-align: center;
50+
}
51+
52+
p.author {
53+
text-align: center;
54+
}
55+
56+
code {
57+
font-family: "DejaVu Sans Mono", monospace;
58+
background-color: #ebebeb;
59+
font-size: 100%;
60+
line-height: inherit;
61+
white-space: pre-wrap;
62+
}
63+
64+
pre {
65+
font-family: "DejaVu Sans Mono", monospace;
66+
padding: 1em;
67+
overflow: auto;
68+
font-size: 100%;
69+
line-height: inherit;
70+
border-radius: 0.25em;
71+
background-color: #ebebeb;
72+
white-space: pre-wrap;
73+
}
74+
75+
table {
76+
border-collapse: collapse;
77+
font-size: 100%;
78+
}
79+
80+
th, td {
81+
padding: 0.8em;
82+
}
83+
84+
table, th, td {
85+
border: 0.06em solid black;
86+
}
87+
88+
a {
89+
text-decoration: none;
90+
}
91+
92+
blockquote {
93+
border-style: solid solid solid solid;
94+
border-color: #a41434;
95+
border-width: medium;
96+
border-radius: 0.5em;
97+
padding-left: 1em;
98+
padding-right: 1em;
99+
background-color: #fcecf4;
100+
}
101+
102+
@media screen { /* Workaround for iBooks issue; see #6242 */
103+
.sourceCode {
104+
overflow: visible !important;
105+
white-space: pre-wrap !important;
106+
}
107+
}
108+

Diff for: ‎files/pandoc_pdf/info.svg

+10
Loading

Diff for: ‎files/pandoc_pdf/md2epub.sh

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#!/bin/bash
2+
3+
pandoc "$1" \
4+
-f gfm \
5+
--toc \
6+
--standalone \
7+
--top-level-division=chapter \
8+
--highlight-style pygments.theme \
9+
--css epub.css \
10+
--metadata=title:"My awesome book" \
11+
--metadata=author:"learnbyexample" \
12+
--metadata=lang:"en-US" \
13+
--metadata=cover-image:"cover.png" \
14+
-o "$2"
15+

Diff for: ‎files/pandoc_pdf/md2pdf_syn_bullet_prop_toc_cover.sh

+2-13
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
pandoc "$1" \
44
-f gfm \
55
--toc \
6+
--include-before-body cover.tex \
67
--include-in-header chapter_break.tex \
78
--include-in-header inline_code.tex \
89
--include-in-header bullet_style.tex \
@@ -15,17 +16,5 @@ pandoc "$1" \
1516
-V mainfont="DejaVu Serif" \
1617
-V monofont="DejaVu Sans Mono" \
1718
--pdf-engine=xelatex \
18-
-o temp.tex
19-
20-
fn="${2%.*}"
21-
22-
perl -0777 -pe \
23-
's/begin\{document\}\n\n\K(.*?^\}$)(.+?)\n/$2\n\\thispagestyle{empty}\n\n$1\n/ms' \
24-
temp.tex > "$fn".tex
25-
26-
xelatex "$fn".tex &> /dev/null
27-
xelatex "$fn".tex &> /dev/null
28-
29-
rm temp.tex "$fn".{tex,toc,aux,log}
30-
19+
-o "$2"
3120

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#!/bin/bash
2+
3+
pandoc "$1" \
4+
-f gfm \
5+
--toc \
6+
--include-before-body cover.tex \
7+
--include-in-header chapter_break.tex \
8+
--include-in-header inline_code.tex \
9+
--include-in-header bullet_style.tex \
10+
--include-in-header pdf_properties.tex \
11+
--include-in-header quote.tex \
12+
--highlight-style pygments.theme \
13+
-V toc-title='Table of contents' \
14+
-V linkcolor:blue \
15+
-V geometry:a4paper \
16+
-V geometry:margin=2cm \
17+
-V mainfont="DejaVu Serif" \
18+
-V monofont="DejaVu Sans Mono" \
19+
--pdf-engine=xelatex \
20+
-o "$2"
21+

Diff for: ‎files/pandoc_pdf/quote.tex

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
\usepackage{tcolorbox}
2+
\newtcolorbox{myquote}{colback=red!5!white, colframe=red!75!black}
3+
\renewenvironment{quote}{\begin{myquote}}{\end{myquote}}

Diff for: ‎files/pandoc_pdf/sample_5.epub

17.3 KB
Binary file not shown.

Diff for: ‎files/pandoc_pdf/sample_5.md

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
![cover image](cover.png)
2-
31
# Introduction
42

53
This is a sample [GitHub style markdown](https://github.github.com/gfm/) file.
@@ -27,6 +25,10 @@ print(f'odd_numbers: {odd_numbers}')
2725
print(f'even_numbers: {even_numbers}')
2826
```
2927

28+
>This is a quote
29+
30+
>![info](info.svg) This is a note
31+
3032
# Ruby
3133

3234
* Arrays are declared within `[]` and elements are separated by `,`

Diff for: ‎files/pandoc_pdf/sample_5.pdf

-1.24 KB
Binary file not shown.

Diff for: ‎files/pandoc_pdf/sample_5_quote.pdf

58.4 KB
Binary file not shown.

Diff for: ‎images/pandoc_pdf/python_vs_ruby_syn.png

2.45 KB
Loading

Diff for: ‎images/pandoc_pdf/styled_blockquote.png

3.75 KB
Loading

0 commit comments

Comments
 (0)
Please sign in to comment.