diff --git a/Makefile b/Makefile index cb49880..bab16f4 100644 --- a/Makefile +++ b/Makefile @@ -7,9 +7,9 @@ CHAPTERS = chapters/01-introduction.md chapters/02-using-docker.md \ chapters/07-tutorial-clouds.md chapters/08-tutorial-deployment.md \ chapters/09-final-words.md -all: book html mobi +all: book -book: epub pdf html mobi +book: pdf epub azw3 mobi clean: rm -fr $(BUILD) @@ -17,43 +17,53 @@ clean: pdf: $(BUILD)/pdf/$(BOOKNAME).pdf epub: $(BUILD)/epub/$(BOOKNAME).epub mobi: $(BUILD)/mobi/$(BOOKNAME).mobi +azw3: $(BUILD)/azw3/$(BOOKNAME).azw3 html: $(BUILD)/html/$(BOOKNAME).html $(BUILD)/pdf/$(BOOKNAME).pdf: $(TITLE) $(CHAPTERS) mkdir -p $(BUILD)/pdf docker run --rm --volume `pwd`:/data pandoc/latex:2.6 -f markdown-implicit_figures -H make-code-small.tex -V geometry:margin=1.5in -o /data/$@ $^ +# intermediate format for epub $(BUILD)/html/$(BOOKNAME).html: title.txt $(CHAPTERS) mkdir -p $(BUILD)/html ln -sf ../../figures/ build/html docker run --rm --volume `pwd`:/data pandoc/crossref:2.10 -o /data/$@ $^ -# mv -f build/html/* tests/html-css.html - # issues: # embed fonts # footnotes show a 'V15' char on kindle device # style: line-height, pre left-margin -# + +# --embed-all-fonts \ +# --subset-embedded-fonts \ +# --authors "Marko Anastasov&Jérôme Petazzoni&Tomas Fernandez" # kindle-optimized epub $(BUILD)/epub/$(BOOKNAME).epub: $(BUILD)/html/$(BOOKNAME).html mkdir -p $(BUILD)/epub - ebook-convert $^ $@ \ - --authors "Marko Anastasov&Jérôme Petazzoni&Tomas Fernandez" \ - --book-producer Semaphore \ - --publisher Semaphore \ - --title "TEST CALIBRE 2" \ - --language en-US \ - --comments "How to Deliver Cloud Native Applications at High Velocity" \ - --epub-version 3 \ - --extra-css styles/epub-kindle.css \ - --cover cover/cover.jpg \ + docker run --rm --volume `pwd`:/data --entrypoint ebook-convert -w /data linuxserver/calibre $^ /data/$@ \ --output-profile kindle \ - --chapter "//*[name()='h1' or name()='h2']" + --epub-version 3 \ + --extra-css styles/epub-kindle2.css \ + --chapter "//*[name()='h1' or name()='h2']" \ + --language en-US \ + --publisher Semaphore \ + --book-producer Semaphore \ + --cover cover/cover.jpg \ + --title "$(shell egrep '^title:' title.txt | cut -d: -f2 | sed -e 's/^[[:space:]]*//')" \ + --comments "$(shell egrep '^subtitle:' title.txt | cut -d: -f2 | sed -e 's/^[[:space:]]*//')" \ + --authors "$(shell egrep '^author:' title.txt | cut -d: -f2 | sed -e 's/^[[:space:]]*//')" -# mobipocket format, also compatible with kindle + +# amazon kindle format +$(BUILD)/azw3/$(BOOKNAME).azw3: $(BUILD)/epub/$(BOOKNAME).epub + mkdir -p $(BUILD)/azw3 + docker run --rm --volume `pwd`:/data --entrypoint ebook-convert -w /data linuxserver/calibre $^ /data/$@ + + +# mobipocket format, compatible with kindle $(BUILD)/mobi/$(BOOKNAME).mobi: $(BUILD)/epub/$(BOOKNAME).epub mkdir -p $(BUILD)/mobi - ebook-convert $^ $@ + docker run --rm --volume `pwd`:/data --entrypoint ebook-convert -w /data linuxserver/calibre $^ /data/$@ -.PHONY: all book clean pdf html epub +.PHONY: all book clean pdf html epub azw3 mobi diff --git a/styles/epub-kindle-reset.css b/styles/epub-kindle-reset.css new file mode 100644 index 0000000..97e9864 --- /dev/null +++ b/styles/epub-kindle-reset.css @@ -0,0 +1,398 @@ +/* from http://bbebooksthailand.com/bb-CSS-boilerplate.html */ + +/* This adds margins around every page to stop ADE's line numbers from being superimposed over content */ +@page { + margin: 10px; +} + +/*===Reset code to prevent cross-reader strangeness===*/ +html, +body, +div, +span, +applet, +object, +iframe, +h1, +h2, +h3, +h4, +h5, +h6, +p, +blockquote, +pre, +a, +abbr, +acronym, +address, +big, +cite, +code, +del, +dfn, +em, +img, +ins, +kbd, +q, +s, +samp, +small, +strike, +strong, +sub, +sup, +tt, +var, +b, +u, +i, +center, +fieldset, +form, +label, +legend, +table, +caption, +tbody, +tfoot, +thead, +tr, +th, +td, +article, +aside, +canvas, +details, +embed, +figure, +figcaption, +footer, +header, +hgroup, +menu, +nav, +output, +ruby, +section, +summary, +time, +mark, +audio, +video { + margin: 0; + padding: 0; + border: 0; + font-size: 100%; + vertical-align: baseline; +} + +table { + border-collapse: collapse; + border-spacing: 0; +} + +ol, +ul, +li, +dl, +dt, +dd { + margin: 0; + padding: 0; + border: 0; + font-size: 100%; + vertical-align: baseline; +} + +/*===GENERAL PRESENTATION===*/ + +/*===Body Presentation and Margins===*/ +/* Text alignment is still a matter of debate. Feel free to change to text-align: left; */ +body { + text-align: justify; + line-height: 120%; +} + +/*===Headings===*/ +/* After page breaks, eReaders sometimes do not render margins above the content. Adjusting padding-top can help */ + +h1 { + text-indent: 0; + text-align: center; + margin: 100px 0 0 0; + font-size: 2em; + font-weight: bold; + page-break-before: always; + line-height: 150%; /*gets squished otherwise on ADE */ +} + +h2 { + text-indent: 0; + text-align: center; + margin: 50px 0 0 0; + font-size: 1.5em; + font-weight: bold; + page-break-before: always; + line-height: 135%; /*get squished otherwise on ADE */ +} + +h3 { + text-indent: 0; + text-align: left; + font-size: 1.4em; + font-weight: bold; + margin-top: 1.4em; +} + +h4 { + text-indent: 0; + text-align: left; + font-size: 1.2em; + font-weight: bold; + margin-top: 1.2em; +} + +h5 { + text-indent: 0; + text-align: left; + font-size: 1.1em; + font-weight: bold; + margin-top: 1.1em; +} + +h6 { + text-indent: 0; + text-align: left; + font-size: 1em; + font-weight: bold; + margin-top: 1em; +} + +/* Hyphen and pagination Fixer */ +/* Note: Do not try on the Kindle, it does not recognize the hyphens property */ +h1, +h2, +h3, +h4, +h5, +h6 { + -webkit-hyphens: none !important; + hyphens: none; + page-break-after: avoid; + page-break-inside: avoid; +} + +/*===Paragraph Elements===*/ +/* Margins are usually added on the top, left, and right, but not on the bottom to prevent certain eReaders not collapsing white space properly */ + +/*first-line indent paragraph for fiction*/ +p { + /* text-indent: 1.25em; */ + margin: 0; + widows: 2; + orphans: 2; +} + +/* block type paragraph for non-fiction* / +/* +p +{ +text-indent: 0; +margin: 1.0em 0 0 0; +widows: 2; +orphans: 2; +} +*/ + +/* for centered text and wrappers on images */ +p.centered { + text-indent: 0; + margin: 1em 0 0 0; + text-align: center; +} + +/* section Breaks (can use centered-style for non-fiction) */ +p.centeredbreak { + text-indent: 0; + margin: 1em 0 1em 0; + text-align: center; +} + +/* First sentence in chapters following heading */ +p.texttop { + margin: 1.5em 0 0 0; + text-indent: 0; +} + +/* Use for second sentence to clear drop cap's float */ +p.clearit { + clear: both; +} + +/* 1st level TOC */ +p.toctext { + margin: 0 0 0 1.5em; + text-indent: 0; +} + +/* 2nd level TOC */ +p.toctext2 { + margin: 0 0 0 2.5em; + text-indent: 0; +} + +/*==LISTS==*/ +ul { + margin: 1em 0 0 2em; + text-align: left; +} + +ol { + margin: 1em 0 0 2em; + text-align: left; +} + +/*===IN-LINE STYLES===*/ +/* Recommend avoiding use of , , and . Use span tags instead */ +span.i { + font-style: italic; +} + +span.b { + font-weight: bold; +} + +span.u { + text-decoration: underline; +} + +span.st { + text-decoration: line-through; +} + +/*==in-line combinations==*/ +/* Using something like ... may seem okay, but it causes problems on some eReaders */ +span.ib { + font-style: italic; + font-weight: bold; +} + +span.iu { + font-style: italic; + text-decoration: underline; +} + +span.bu { + font-weight: bold; + text-decoration: underline; +} + +span.ibu { + font-style: italic; + font-weight: bold; + text-decoration: underline; +} + +/* This fixes the bug where the text-align property of block-level elements is not recognized on iBooks + example: html markup would look like

Centered Content

*/ + +span.ipadcenterfix { + text-align: center; +} + +/*==IMAGES==*/ +img { + max-width: 100%; +} + +/*==TABLES==*/ +table { + margin: 1em auto; +} + +tr, +th, +td { + margin: 0; + padding: 2px; + border: 1px solid black; + font-size: 100%; + vertical-align: baseline; +} + +/* Superscripted Footnote Text */ +.footnote { + vertical-align: super; + font-size: 0.75em; + text-decoration: none; +} + +/*==DROP CAPS==*/ +span.dropcap { + font-size: 300%; + font-weight: bold; + height: 1em; + float: left; + margin: 0.3em 0.125em -0.4em 0.1em; +} + +/*==PULL QUOTE==*/ +div.pullquote { + margin: 2em 2em 0 2em; + text-align: left; +} + +div.pullquote p { + font-weight: bold; + font-style: italic; +} + +div.pullquote hr { + width: 100%; + margin: 0; + height: 3px; + color: #2e8de0; + background-color: #2e8de0; + border: 0; +} + +/*==BLOCK QUOTE==*/ +div.blockquote { + margin: 1em 1.5em 0 1.5em; + text-align: left; + font-size: 0.9em; +} + +/*==eBook Specific Formatting Below Here==*/ +body { + padding: 1em; +} + +pre, +code { + font-size: 90%; + line-height: 50%; +} + +pre { + border-left: 1px #000 solid; + padding-left: 10px; +} + +blockquote { + color: #666666; + margin: 1em 0; + padding-left: 1.5em; + border-left: 0.5em #eee solid; +} + +p { + margin: 1em 0; +} + +/* used for strings in code when using HTML */ +span.st { + text-decoration: initial; +} diff --git a/styles/epub-kindle.css b/styles/epub-kindle.css index 97e9864..e338212 100644 --- a/styles/epub-kindle.css +++ b/styles/epub-kindle.css @@ -372,13 +372,24 @@ body { pre, code { - font-size: 90%; - line-height: 50%; + /* font-size: small; */ + /* font-family: "Source Code Pro"; */ + font-size: 60%; } -pre { - border-left: 1px #000 solid; - padding-left: 10px; +pre +{ + background: #cccccc; + /* border: thin solid #ccccff; */ + clear: both; + color: black; + /* font-family: monospace; */ + line-height: 100%; + margin: 0; + padding: 0; + text-align: left; + word-wrap: normal; + overflow: hidden } blockquote { diff --git a/epub.css b/styles/epub-pandoc.css similarity index 84% rename from epub.css rename to styles/epub-pandoc.css index 4937ccf..4afe441 100644 --- a/epub.css +++ b/styles/epub-pandoc.css @@ -1,6 +1,12 @@ +@font-face { +font-family: SourceCodePro; +font-style: normal; +font-weight: normal; +src:url("SourceCodePro-Regular.ttf"); +} /* This defines styles and classes used in the book */ body { margin: 5%; text-align: justify; font-size: medium; } -code { font-family: monospace; word-wrap: break-word; } +code { font-family: SourceCodePro; monospace; word-wrap: break-word; } h1 { text-align: left; } h2 { text-align: left; } h3 { text-align: left; }