Skip to content

Instantly share code, notes, and snippets.

@plinionaves
Forked from scastiel/Makefile
Created February 3, 2021 17:44
Show Gist options
  • Save plinionaves/186fd5acffc4ec5b6b9143ba166c1ed8 to your computer and use it in GitHub Desktop.
Save plinionaves/186fd5acffc4ec5b6b9143ba166c1ed8 to your computer and use it in GitHub Desktop.
Resources for eBook creating using Pandoc
{
"text-color": "#f8f8f2",
"background-color": "#282a36",
"line-number-color": "#aaaaaa",
"line-number-background-color": null,
"text-styles": {
"Other": {
"text-color": "#50fa7b",
"background-color": null,
"bold": false,
"italic": true,
"underline": false
},
"Attribute": {
"text-color": "#f8f8f2",
"background-color": null,
"bold": false,
"italic": false,
"underline": false
},
"SpecialString": {
"text-color": "#bb6688",
"background-color": null,
"bold": false,
"italic": false,
"underline": false
},
"Annotation": {
"text-color": "#60a0b0",
"background-color": null,
"bold": false,
"italic": false,
"underline": false
},
"Function": {
"text-color": "#50fa7b",
"background-color": null,
"bold": false,
"italic": false,
"underline": false
},
"String": {
"text-color": "#f1fa8c",
"background-color": null,
"bold": false,
"italic": false,
"underline": false
},
"ControlFlow": {
"text-color": "#ff79c6",
"background-color": null,
"bold": false,
"italic": false,
"underline": false
},
"Operator": {
"text-color": "#ff79c6",
"background-color": null,
"bold": false,
"italic": false,
"underline": false
},
"Error": {
"text-color": "#ff0000",
"background-color": null,
"bold": false,
"italic": false,
"underline": false
},
"BaseN": {
"text-color": "#40a070",
"background-color": null,
"bold": false,
"italic": false,
"underline": false
},
"Alert": {
"text-color": "#ff0000",
"background-color": null,
"bold": false,
"italic": false,
"underline": false
},
"Variable": {
"text-color": "#ff79c6",
"background-color": null,
"bold": false,
"italic": false,
"underline": false
},
"BuiltIn": {
"text-color": null,
"background-color": null,
"bold": false,
"italic": false,
"underline": false
},
"Extension": {
"text-color": null,
"background-color": null,
"bold": false,
"italic": false,
"underline": false
},
"Preprocessor": {
"text-color": "#8be9fd",
"background-color": null,
"bold": false,
"italic": false,
"underline": false
},
"Information": {
"text-color": "#60a0b0",
"background-color": null,
"bold": false,
"italic": false,
"underline": false
},
"VerbatimString": {
"text-color": "#f1fa8c",
"background-color": null,
"bold": false,
"italic": false,
"underline": false
},
"Warning": {
"text-color": "#60a0b0",
"background-color": null,
"bold": false,
"italic": false,
"underline": false
},
"Documentation": {
"text-color": "#ba2121",
"background-color": null,
"bold": false,
"italic": false,
"underline": false
},
"Import": {
"text-color": "#ff79c6",
"background-color": null,
"bold": false,
"italic": false,
"underline": false
},
"Char": {
"text-color": "#4070a0",
"background-color": null,
"bold": false,
"italic": false,
"underline": false
},
"DataType": {
"text-color": "#f8f8f2",
"background-color": null,
"bold": false,
"italic": false,
"underline": false
},
"Float": {
"text-color": "#40a070",
"background-color": null,
"bold": false,
"italic": false,
"underline": false
},
"Comment": {
"text-color": "#6272a4",
"background-color": null,
"bold": false,
"italic": false,
"underline": false
},
"CommentVar": {
"text-color": "#60a0b0",
"background-color": null,
"bold": false,
"italic": false,
"underline": false
},
"Constant": {
"text-color": "#880000",
"background-color": null,
"bold": false,
"italic": false,
"underline": false
},
"SpecialChar": {
"text-color": "#ff79c6",
"background-color": null,
"bold": false,
"italic": false,
"underline": false
},
"DecVal": {
"text-color": "#bd93f9",
"background-color": null,
"bold": false,
"italic": false,
"underline": false
},
"Keyword": {
"text-color": "#ff79c6",
"background-color": null,
"bold": false,
"italic": false,
"underline": false
}
}
}
\usepackage{tikz,xcolor,sectsty,pdfpages,titlesec}
% Colors
\definecolor{foreground}{RGB}{248,248,242}
\definecolor{comment}{RGB}{98,114,164}
\definecolor{pink}{RGB}{255,121,198}
\definecolor{purple}{RGB}{189,147,249}
\definecolor{blue}{RGB}{139,233,253}
\definecolor{background}{RGB}{40,42,54}
\definecolor{background2}{RGB}{33,34,44}
% Background and text color
\pagecolor{background2}
\color{foreground}
% Chapter and section formatting
\chapterfont{\color{pink}\raggedright}
\sectionfont{\color{blue}\raggedright}
% Use font Helvetica instead of default sans-serif
\renewcommand{\familydefault}{\sfdefault}
\usepackage[scaled]{helvet}
\renewcommand\familydefault{\sfdefault}
\usepackage[T1]{fontenc}
% Smaller source code
\renewenvironment{Shaded} {\begin{snugshade}\scriptsize} {\end{snugshade}}
% Page geometry
\usepackage[paperwidth=178mm,paperheight=233mm,left=0.8in,right=0.8in,top=0.8in,footskip=0.5in,bmargin=0.8in]{geometry}
% Custom page footer
\usepackage{fancyhdr}
\pagestyle{fancy}
\fancyhf{}
\lfoot{
\begin{tikzpicture}[overlay,baseline={(0,0)}]
\node[rectangle, outer sep=0pt, text=white, anchor=west ]
(pageno)
{A React Developer’s Guide to Hooks, © Sebastien Castiel};
\draw[ fill=comment, draw=comment]
([xshift=-\oddsidemargin-1in]pageno.north west)
rectangle
([yshift=1.5pt]pageno.south east);
\node[rectangle, outer sep=0pt, text=white, anchor=west]
(pageno2)
{A React Developer’s Guide to Hooks, © Sebastien Castiel};
\end{tikzpicture}
}
\rfoot{
\begin{tikzpicture}[overlay,baseline={(0,0)}]
\node[rectangle,outer sep=0pt,text=white,fill=pink,draw=pink,anchor=east]
(pageno)
{\thepage};
\draw[fill=pink,draw=pink]
([xshift=\oddsidemargin+1in]pageno.north east)
rectangle
(pageno.south east);
\end{tikzpicture}%
}
% Remove header and footer lines
\renewcommand{\headrulewidth}{0pt}
\renewcommand{\footrulewidth}{0pt}
% Customize figures
\usepackage{float}
\let\origfigure\figure
\let\endorigfigure\endfigure
\renewenvironment{figure}[1][2] {
\expandafter\origfigure\expandafter[H]
} {
\endorigfigure
}
% Show only chapters in table of contents
\setcounter{tocdepth}{0}
% Customize section formatting
\titleformat{\section}%
[hang]% <shape>
{\normalfont\bfseries\Large\color{blue}}% <format>
{}% <label>
{0pt}% <sep>
{}% <before code>
% Use “Lesson” instead of “Chapter” in chapter numbering
\renewcommand{\chaptername}{Lesson}
% Disable section numbering
\renewcommand{\thesection}{}
% Don’t use different page style (header and footer) for chapter pages
\usepackage{etoolbox}
\patchcmd{\chapter}{\thispagestyle{plain}}{\thispagestyle{fancy}}{}{}
% Avoid widows and clubs
\widowpenalty10000
\clubpenalty10000
all: pdf epub kindle html examples
BOOK_TITLE = A\ React\ Developer’s\ Guide\ to\ Hooks\ -\ Sebastien\ Castiel
dist:
@mkdir -p dist
pdf: dist/${BOOK_TITLE}.pdf
@echo '✅ PDF'
epub: dist/${BOOK_TITLE}.epub
@echo '✅ ePub'
kindle: dist/${BOOK_TITLE}.mobi
@echo '✅ Kindle'
html: dist/${BOOK_TITLE}.html
@echo '✅ HTML'
examples: dist/Examples.zip
@echo '✅ Examples'
dist/${BOOK_TITLE}.pdf: dist content/*.md images/* resources/dracula.theme resources/header.tex
@pandoc content/foreword.md content/toc.md content/ch*.md content/resources.md content/solutions.md \
--output=dist/${BOOK_TITLE}.pdf \
--highlight-style resources/dracula.theme \
-H resources/header.tex --filter pandoc-crossref -V fontsize=12pt --number-sections -V documentclass=report
dist/${BOOK_TITLE}.html: dist content/*.md images/* resources/dracula.theme resources/header.html
@pandoc content/foreword.md content/ch*.md content/resources.md \
--output=dist/${BOOK_TITLE}.html \
--highlight-style resources/dracula.theme \
--standalone \
-H resources/header.html \
--metadata title="A React Developer’s Guide to Hooks"
dist/${BOOK_TITLE}.epub: dist content/*.md images/* resources/dracula.theme resources/metadata.xml resources/epub.css
@pandoc content/foreword.md content/ch*.md content/resources.md \
--output=dist/${BOOK_TITLE}.epub \
--highlight-style resources/dracula.theme \
--standalone \
--epub-metadata=resources/metadata.xml \
-c resources/epub.css \
--epub-cover-image=cover.png \
--toc --toc-depth=1 \
--metadata title="A React Developer’s Guide to Hooks"
dist/${BOOK_TITLE}.mobi: dist/${BOOK_TITLE}.epub
@kindlegen dist/${BOOK_TITLE}.epub -o ${BOOK_TITLE}.mobi >/dev/null 2>&1
dist/Examples.zip: examples/**/*
@git archive --prefix=examples/ -o dist/Examples.zip HEAD:examples/
clean:
@rm -rf dist
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment