bookmaker 0.2.0 → 0.3.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -39,7 +39,7 @@ module Bookmaker
39
39
  end
40
40
  def entries
41
41
  return @entries unless @entries.nil?
42
- files = Dir["text/**/*.md"]
42
+ files = Dir["text/**/*.tex"]
43
43
  @entries = {}
44
44
  files.each do |f|
45
45
  k = File.dirname(f)
@@ -6,12 +6,10 @@ module Bookmaker
6
6
  def content
7
7
  raw = []
8
8
  entries.keys.each do |chapter|
9
- raw << "{::nomarkdown}\\Chapter{#{chapter.split(/_/)[1].gsub('-',' ')}}{:/}"
9
+ title = (chapter.empty?) ? "Untitled" : chapter.split('_')[1]
10
+ raw << "\\Chapter{#{title.gsub('-',' ')}}\n\n"
10
11
  entries[chapter].each do |section|
11
12
  s = read_content(section)[0]
12
- s.gsub!(/\[([^\]]+?)\]\(([^\)]+?\![^\)]+?)\)/m) { "{::nomarkdown}\\emph{#{$1}}\\index{#{$2}}{:/}" }
13
- # puts s
14
- # exit
15
13
  raw << "#{s}\n\n* * *"
16
14
  end
17
15
  end
@@ -29,7 +27,7 @@ module Bookmaker
29
27
  # spawn_command ["makeglossaries #{name}.glo"]
30
28
  spawn_command ["xelatex", tex_file.to_s,]
31
29
 
32
- spawn_command ["rm *.glo *.idx *.log *.out *.toc *aux"]
30
+ spawn_command ["rm *.glo *.idx *.log *.out *.toc *aux *ilg *ind *ist"]
33
31
  spawn_command ["mv #{name}.pdf output/#{name}.pdf"]
34
32
  true
35
33
  rescue Exception
@@ -38,8 +36,7 @@ module Bookmaker
38
36
  end
39
37
  def parse_layout(text)
40
38
  text = text.join("\n\n")
41
- text.gsub!('* * *', "\n\n{::nomarkdown}\\pbreak{:/}\n\n")
42
- Kramdown::Document.new(text).to_latex
39
+ text.gsub!('* * *', "\n\n\\pbreak{}\n\n")
43
40
  end
44
41
  def tex_file
45
42
  root_dir.join("output/#{name}.tex")
@@ -1,3 +1,3 @@
1
1
  module Bookmaker
2
- VERSION = "0.2.0"
2
+ VERSION = "0.3.1"
3
3
  end
@@ -1,44 +1,10 @@
1
1
  \NeedsTeXFormat{LaTeX2e}[1996/06/01]
2
-
3
- \documentclass[11pt,twoside,makeidx]{memoir}
2
+ \documentclass[11pt,twoside,makeidx,hidelinks]{memoir}
4
3
  \usepackage{layouts}[2001/04/29]
5
- \makeglossary
6
- \makeindex
7
-
8
- %========================
9
- % Page Layout
10
- \setstocksize{9in}{6in}
11
- \settrimmedsize{9in}{6in}{*} % Use entire page
12
- \settrims{0pt}{0pt}
13
-
14
- \setlrmarginsandblock{0.8in}{0.5in}{*}
15
- \setulmarginsandblock{0.8in}{0.5in}{*}
16
-
17
- \setmarginnotes{0.1pt}{0.2in}{\onelineskip}
18
- \setheadfoot{\onelineskip}{2\onelineskip}
19
- \setheaderspaces{*}{2\onelineskip}{*}
20
- \linespread{1.05}
21
-
22
- \checkandfixthelayout
23
- \setlength{\headsep}{8pt}
24
- \aliaspagestyle{title}{empty}
25
-
26
- \makepagestyle{ebook}
27
- \makeoddhead{ebook}{}{\normalfont\scshape\theauthor}{\normalfont\thepage}
28
- \makeevenhead{ebook}{\normalfont\thepage}{\normalfont\scshape \thetitle}{}
29
-
30
- %========================
31
- % Fonts
32
- \usepackage{fontspec}
33
- \usepackage{xunicode}
34
- \usepackage{xltxtra}
35
- \defaultfontfeatures{Mapping=tex-text}
36
- \setmainfont{Liberation Serif}
37
- \setsansfont{TitilliumText22L Light}
38
- \setmonofont{Liberation Mono}
39
- \newfontinstance\scshape[Letters=SmallCaps, Numbers=Uppercase]{Liberation Mono}
40
- \DeclareOldFontCommand{\tt}{\normalfont\ttfamily}{\mathtt}
4
+ \def\isfinal{<%= is_final %>}
41
5
 
6
+ % Packages
7
+ %=========
42
8
  \usepackage{verbatim}
43
9
  \usepackage[colorlinks=false]{hyperref}
44
10
  % \usepackage[utf8x]{inputenc}
@@ -54,32 +20,37 @@
54
20
  titling
55
21
  }
56
22
 
57
- \ifdefined\disableligature
58
- \DisableLigatures[f]{encoding = *, family = * }
59
- \fi
23
+ % Boolean-ness
24
+ %=============
25
+ \newcommand{\onlyfinal}[1]{\ifdefined\isfinal{#1}\fi}
26
+ \newcommand{\notfinal}[1]{\ifdefined\isfinal\else{#1}\fi}
27
+ \newcommand{\whenfinal}[2]{%
28
+ \ifdefined\isfinal%
29
+ #1
30
+ \else%
31
+ #2
32
+ \fi}%
60
33
 
61
- %========================
62
- % Document Headings
34
+ % Page Layout
35
+ %============
36
+ \setstocksize{9in}{6in}
37
+ \settrimmedsize{9in}{6in}{*} % Use entire page
38
+ \settrims{0pt}{0pt}
39
+ \setlrmarginsandblock{0.8in}{0.5in}{*}
40
+ \setulmarginsandblock{0.8in}{0.5in}{*}
63
41
 
64
- %% Chapter
65
- \setsecheadstyle{\bfseries\large\centering}
66
- \newcounter{renewsection}
67
- \newcommand{\Chapter}[1]{
68
- \setcounter{renewsection}{\value{section}}
69
- \chapter{#1}
70
- \setcounter{section}{\value{renewsection}}
71
- }
42
+ \setmarginnotes{0.1pt}{0.2in}{\onelineskip}
43
+ \setheadfoot{\onelineskip}{2\onelineskip}
44
+ \setheaderspaces{*}{2\onelineskip}{*}
45
+ \linespread{1.05}
72
46
 
73
- %========================
74
- \renewcommand{\thesection}{\arabic{section}.}
47
+ \checkandfixthelayout
48
+
49
+ \setlength{\headsep}{8pt}
75
50
 
76
- %========================
77
- % TEXT LAYOUT
78
51
  \newlength{\AfterFancyBreakMin}
79
52
  \setlength{\AfterFancyBreakMin}{3\baselineskip}
80
-
81
53
  \setlength{\parindent}{1.5 em}
82
-
83
54
  \makeatletter
84
55
  \g@addto@macro\quote{\linespread{1}\small{}}
85
56
  \g@addto@macro\quotation{\linespread{1}\small{}}
@@ -93,15 +64,40 @@
93
64
  \hfuzz 0.3pt
94
65
  \widowpenalty=10000
95
66
  \clubpenalty=10000
96
-
97
67
  \setlength{\parindent}{1.5 em}
98
68
 
69
+ % Page Heading
70
+ %-------------
71
+ \makepagestyle{ebook}
72
+ \makeoddhead{ebook}{}{\normalfont\scshape\theauthor}{\normalfont\thepage}
73
+ \makeevenhead{ebook}{\normalfont\thepage}{\normalfont\scshape \thetitle}{}
74
+
75
+ \aliaspagestyle{title}{empty}
76
+
77
+ % Text Tweaks
78
+ %-------------
99
79
  \def\thinspace{\kern .16667em }
80
+ \newcommand{\ellip}{\ldots}
100
81
  \newcommand{\Dash}{\thinspace---\thinspace}
101
82
  \newcommand{\dash}{\tk{--Wrong Dash--}}
102
83
 
103
- %========================
84
+ % Fonts
85
+ %------
86
+ \usepackage{fontspec}
87
+ \usepackage{xunicode}
88
+ \usepackage{xltxtra}
89
+ \defaultfontfeatures{Mapping=tex-text}
90
+ \setmainfont{Liberation Serif}
91
+ \setsansfont{TitilliumText22L Light}
92
+ \setmonofont{Liberation Mono}
93
+ \newfontinstance\scshape[Letters=SmallCaps, Numbers=Uppercase]{Liberation Mono}
94
+ \DeclareOldFontCommand{\tt}{\normalfont\ttfamily}{\mathtt}
95
+ \ifdefined\disableligature
96
+ \DisableLigatures[f]{encoding = *, family = * }
97
+ \fi
98
+
104
99
  % Dates
100
+ %-------
105
101
  \usepackage{datetime}
106
102
  \newdateformat{yearonly}{\THEYEAR}
107
103
  \newdateformat{usmonthyear}{\monthname[\THEMONTH], \THEYEAR}
@@ -111,23 +107,98 @@
111
107
  December\fi\space\number\year
112
108
  }
113
109
 
114
- %========================
115
- % Text Tweaks
116
- \newcommand{\ellip}{\ldots}
117
- \newcommand{\pbreak}{\pfbreak}%
110
+ % Document Headings
111
+ %==================
112
+
113
+ % Chapter
114
+ %-----------
115
+ \setsecheadstyle{\bfseries\large\centering}
116
+ \newcounter{renewsection}
117
+ \newcommand{\Chapter}[1]{
118
+ \setcounter{renewsection}{\value{section}}
119
+ \chapter{#1}
120
+ \setcounter{section}{\value{renewsection}}
121
+ }
122
+
123
+ % Section
124
+ %---------
125
+ \renewcommand{\thesection}{\arabic{section}.}
126
+
127
+ % Novel Tweaks
128
+ %=============
129
+
130
+ % Scene Formatting
131
+ %-----------------
132
+
133
+ \newcommand{\thought}[1]{\emph{#1}}
134
+ \newcommand{\email}[1]{\texttt{#1}}
135
+ \newcommand{\status}[1]{\notfinal{\textbf{Status:} #1\newline}}
136
+ \newcommand{\synopsis}[1]{\notfinal{\line(1,0){320}\newline\textbf{What's going on here?} #1\newline
137
+ \line(1,0){320}\newline}}
138
+ \newcommand{\slug}[1]{\notfinal{\MakeUppercase{#1}\newline\newline}}
139
+ \newcommand{\slugline}[2]{\notfinal{\section{#1}}\onlyfinal{\section{}}\slug{#2}}
140
+ \newcommand{\interlude}[1]{\plainfancybreak{\AfterFancyBreakMin}{1}{#1}}
141
+
142
+ \newcommand{\scene}[3]{%
143
+ \notfinal{\section{#1}\slug{#2}}
144
+ \input{#3}
145
+ \pbreak
146
+ }%
147
+
148
+ \newcommand{\smee}[1]{\Dash{}\textsc{\small#1}}
149
+ \whenfinal%
150
+ {\newcommand{\pbreak}{\pfbreak}}%
151
+ {\newcommand{\pbreak}{\begin{center} \# \# \# \end{center}}}
152
+
153
+ % Indices
154
+ %=========
155
+ \makeglossary
156
+ \makeindex
157
+ \let\oldindex\index
158
+ \newcommand{\marked}[1]{\whenfinal{#1}{\underline{#1}}}%
159
+ \renewcommand{\index}[1]{\oldindex{#1}\marked{#1}}%
160
+ \newcommand{\Index}[2]{\oldindex{#1}\marked{#2}}%
161
+ \newcommand{\orbital}[1]{\oldindex{Orbital!#1}\marked{#1}}%
162
+ \newcommand{\equipment}[1]{\oldindex{Equipment!#1}\marked{#1}}%
163
+ \newcommand{\system}[1]{\oldindex{System!#1}\marked{#1}}%
164
+ \newcommand{\character}[1]{\oldindex{Character!#1}\marked{#1}}%
165
+ \newcommand{\Character}[2]{\oldindex{Character!#1}\marked{#2}}%
166
+ \newcommand{\ship}[1]{\oldindex{Ship!#1}\marked{\emph{#1}}}%
167
+ \newcommand{\Ship}[1]{\oldindex{Ship!#1}\marked{\emph{#1}}}%
168
+ \newcommand{\location}[1]{\oldindex{Location!#1}\marked{#1}}%
169
+ \newcommand{\Location}[2]{\oldindex{Location!#1}\marked{#2}}%
170
+ \newcommand{\clin}[1]{\oldindex{Clin!#1}Clin \marked{#1}}%
118
171
 
119
- %========================
120
172
  % Book-Specific Metadata
173
+ %========================
174
+
121
175
  \def\NextBook{Luctation}
122
176
  \def\ReturningCharacters{Bophendze and Smee}
123
177
  \title{<%= title %>}
124
178
  \author{<%= authors.join(', ') %>}
125
179
  \date{<%= published_at %>}
126
180
  \newdate{firstprint}{<%= published_at.split('-')[2]%>}{<%= published_at.split('-')[1]%>}{<%= published_at.split('-')[0]%>}
127
- % \newcommand{\isbn}{<}
128
- \renewcommand{\thesection}{\arabic{section}.}
129
181
 
182
+
183
+ % Drafting Help
184
+ %==============
185
+ \newcommand{\tk}[1]{%
186
+ \ifdefined\isdraft%
187
+ % \textbf{TK-#1}
188
+ \todo{#1}\textbf{TK-#1}%
189
+ \else%
190
+ \textbf{TK-#1}%
191
+ % \todo{#1}\textbf{TK-#1}
192
+ \fi%
193
+ }%
194
+ \newcommand{\TK}[1]{\tk{BAD-TK--#1}}
195
+
196
+ % Document
197
+ %========================
130
198
  \begin{document}
199
+
200
+ % Frontmatter
201
+ %-------------
131
202
  \frontmatter
132
203
  \begin{titlingpage}
133
204
  \pagestyle{empty}
@@ -201,8 +272,9 @@
201
272
  % \ifdefined\isdraft
202
273
  % \listoftodos
203
274
  % \fi
275
+
204
276
  % Back Matter
205
- %
277
+ %-------------
206
278
  \backmatter
207
279
 
208
280
  %% Bibliography
@@ -241,8 +313,4 @@
241
313
  \printindex
242
314
  % }
243
315
 
244
- % \chapter{Colophon}
245
-
246
- % This book was typeset using the venerable \TeX document markup protocol, using \XeTeX. The \emph{Memoir} class was used for the many features it provided over the standard \emph{Book} class of \TeX{}. \XeTeX{} is distributed at no cost under the \TeX{} Project Public License. Spell checking was done using Aspell. The final version was compiled into the Portable Document Format (PDF) or various epublishing formats, facilitated by use of Make, a utility for automatically building large applications that would otherwise be time-consuming to build through non-automated means.
247
-
248
316
  \end{document}
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bookmaker
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -13,7 +13,7 @@ date: 2013-03-03 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activesupport
16
- requirement: &2153103420 !ruby/object:Gem::Requirement
16
+ requirement: &2152320520 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '0'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *2153103420
24
+ version_requirements: *2152320520
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: aruba
27
- requirement: &2153102900 !ruby/object:Gem::Requirement
27
+ requirement: &2152318860 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: '0'
33
33
  type: :development
34
34
  prerelease: false
35
- version_requirements: *2153102900
35
+ version_requirements: *2152318860
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: cucumber
38
- requirement: &2153102120 !ruby/object:Gem::Requirement
38
+ requirement: &2152312100 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: '0'
44
44
  type: :development
45
45
  prerelease: false
46
- version_requirements: *2153102120
46
+ version_requirements: *2152312100
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: eeepub
49
- requirement: &2153101480 !ruby/object:Gem::Requirement
49
+ requirement: &2152310880 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ! '>='
@@ -54,10 +54,10 @@ dependencies:
54
54
  version: '0'
55
55
  type: :runtime
56
56
  prerelease: false
57
- version_requirements: *2153101480
57
+ version_requirements: *2152310880
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: kramdown
60
- requirement: &2153101020 !ruby/object:Gem::Requirement
60
+ requirement: &2152307400 !ruby/object:Gem::Requirement
61
61
  none: false
62
62
  requirements:
63
63
  - - ! '>='
@@ -65,10 +65,10 @@ dependencies:
65
65
  version: '0'
66
66
  type: :runtime
67
67
  prerelease: false
68
- version_requirements: *2153101020
68
+ version_requirements: *2152307400
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: thor
71
- requirement: &2153100380 !ruby/object:Gem::Requirement
71
+ requirement: &2152287540 !ruby/object:Gem::Requirement
72
72
  none: false
73
73
  requirements:
74
74
  - - ! '>='
@@ -76,10 +76,10 @@ dependencies:
76
76
  version: '0'
77
77
  type: :runtime
78
78
  prerelease: false
79
- version_requirements: *2153100380
79
+ version_requirements: *2152287540
80
80
  - !ruby/object:Gem::Dependency
81
81
  name: nokogiri
82
- requirement: &2153099740 !ruby/object:Gem::Requirement
82
+ requirement: &2152281980 !ruby/object:Gem::Requirement
83
83
  none: false
84
84
  requirements:
85
85
  - - ! '>='
@@ -87,10 +87,10 @@ dependencies:
87
87
  version: '0'
88
88
  type: :runtime
89
89
  prerelease: false
90
- version_requirements: *2153099740
90
+ version_requirements: *2152281980
91
91
  - !ruby/object:Gem::Dependency
92
92
  name: notifier
93
- requirement: &2153099060 !ruby/object:Gem::Requirement
93
+ requirement: &2152258980 !ruby/object:Gem::Requirement
94
94
  none: false
95
95
  requirements:
96
96
  - - ! '>='
@@ -98,7 +98,7 @@ dependencies:
98
98
  version: '0'
99
99
  type: :runtime
100
100
  prerelease: false
101
- version_requirements: *2153099060
101
+ version_requirements: *2152258980
102
102
  description: ! 'ODO: Write a gem description'
103
103
  email:
104
104
  - dausha@gmail.com