Skip to content

Commit

Permalink
Add hyphenation. Remove fonts from ebooks.
Browse files Browse the repository at this point in the history
  • Loading branch information
czerwonamaupa committed Dec 20, 2018
1 parent 680f193 commit df761cd
Show file tree
Hide file tree
Showing 9 changed files with 344 additions and 455 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/styles/ebook.css
/ebooks/*
2 changes: 2 additions & 0 deletions build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/bin/sh
ls New-Introductory-Lectures-On-Psycho-Analysis.md styles/* template.t filters/* cover.png | entr make
16 changes: 16 additions & 0 deletions filters/hyphenate.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import re
from pandocfilters import Str, toJSONFilter
from pyphen import Pyphen

dic = Pyphen(lang='en_GB', left=3, right=3)

word_detection_pattern = re.compile(r'\w{7,}', re.UNICODE)

def hyphenate(key, value, format, meta):
if key == 'Str':
return Str(word_detection_pattern.sub(
lambda match: dic.inserted(match.group(0), hyphen='­'),
value))

if __name__ == "__main__":
toJSONFilter(hyphenate)
570 changes: 285 additions & 285 deletions index.html

Large diffs are not rendered by default.

7 changes: 4 additions & 3 deletions makefile
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
default : index.html ebooks/New-Introductory-Lectures-On-Psycho-Analysis.mobi

index.html : New-Introductory-Lectures-On-Psycho-Analysis.md styles/index.css styles/html.css template.t
index.html : New-Introductory-Lectures-On-Psycho-Analysis.md styles/index.css styles/html.css filters/* template.t
pandoc \
-s \
--filter filters/hyphenate.py \
--section-divs \
-o index.html \
-c styles/index.css \
Expand All @@ -13,15 +14,15 @@ index.html : New-Introductory-Lectures-On-Psycho-Analysis.md styles/index.css st
styles/ebook.css : styles/index.css styles/epub.css
cat styles/index.css > styles/ebook.css && cat styles/epub.css >> styles/ebook.css

ebooks/New-Introductory-Lectures-On-Psycho-Analysis.epub : New-Introductory-Lectures-On-Psycho-Analysis.md styles/ebook.css template.t cover.png
ebooks/New-Introductory-Lectures-On-Psycho-Analysis.epub : New-Introductory-Lectures-On-Psycho-Analysis.md styles/ebook.css filters/* template.t cover.png
pandoc \
-s \
--filter filters/hyphenate.py \
--section-divs \
--toc-depth=1 \
--epub-cover-image cover.png \
-o ebooks/New-Introductory-Lectures-On-Psycho-Analysis.epub \
-c styles/ebook.css \
--epub-embed-font 'fonts/*' \
--template template.t \
-t epub3 \
New-Introductory-Lectures-On-Psycho-Analysis.md
Expand Down
2 changes: 2 additions & 0 deletions nix-shell.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/bin/sh
nix-shell -p pkgs.{pandoc,gnumake,entr} 'pkgs.python3.withPackages (pkgs: with pkgs; [pandocfilters pyphen])'
138 changes: 0 additions & 138 deletions styles/ebook.css

This file was deleted.

31 changes: 31 additions & 0 deletions styles/html.css
Original file line number Diff line number Diff line change
@@ -1,2 +1,33 @@
@font-face
{ font-family: libertine;
src: url(../fonts/LinLibertine_R.woff); }

@font-face
{ font-family: libertine;
font-style: italic;
src: url(../fonts/LinLibertine_RI.woff); }

@font-face
{ font-family: libertine;
font-weight: bold;
src: url(../fonts/LinLibertine_RB.woff); }

@font-face
{ font-family: libertine;
font-weight: bold;
font-style: italic;
src: url(../fonts/LinLibertine_RBI.woff); }

body
{ font-family: libertine, serif; }

@media (min-width: 34rem)
{ html
{ font-size: 1rem; }

body
{ width: 34rem;
margin: 0 auto; } }

section.level1
{ margin-bottom: 20rem; }
31 changes: 2 additions & 29 deletions styles/index.css
Original file line number Diff line number Diff line change
@@ -1,39 +1,11 @@
@charset "UTF-8";

@font-face
{ font-family: libertine;
src: url(../fonts/LinLibertine_R.woff); }

@font-face
{ font-family: libertine;
font-style: italic;
src: url(../fonts/LinLibertine_RI.woff); }

@font-face
{ font-family: libertine;
font-weight: bold;
src: url(../fonts/LinLibertine_RB.woff); }

@font-face
{ font-family: libertine;
font-weight: bold;
font-style: italic;
src: url(../fonts/LinLibertine_RBI.woff); }

html
{ font-size: 0.7rem; }

body
{ padding: 1rem;
font-family: libertine, serif; }

@media (min-width: 34rem)
{ html
{ font-size: 1rem; }

body
{ width: 34rem;
margin: 0 auto; } }
hyphens: none; }

h1
{ font-weight: 400;
Expand Down Expand Up @@ -70,6 +42,7 @@ p
margin-bottom: 0;
margin-top: 0;
text-align: justify;
hyphens: manual;
text-indent: 1rem; }

blockquote
Expand Down

0 comments on commit df761cd

Please sign in to comment.