publishr 0.5.0 → 0.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README +43 -0
- data/lib/publishr.rb +1 -1
- data/lib/publishr/epub_renderer.rb +3 -3
- data/lib/publishr/{markup_processor.rb → html_processor.rb} +9 -6
- data/lib/publishr/latex_processor.rb +1 -1
- data/lib/publishr/latex_renderer.rb +1 -1
- data/lib/publishr/project.rb +4 -0
- data/lib/publishr/version.rb +1 -1
- metadata +3 -2
data/README
ADDED
@@ -0,0 +1,43 @@
|
|
1
|
+
PublishR -- Fast publishing for ebooks and paper
|
2
|
+
Copyright (C) 2012 Michael Franzl
|
3
|
+
|
4
|
+
|
5
|
+
USAGE: publishr [name] [path_to_source_dir] [format] [path_to_converters]
|
6
|
+
|
7
|
+
[name] is an unique string that identifies your project. Rendered files will be named after this.
|
8
|
+
[path_to_source_dir] directory must minimally contain: [cover.jpg, covertext.txt, frontmatter.txt, toc.txt, metadata.yml]
|
9
|
+
[format] must be {kindle, pdf}
|
10
|
+
[path_to_converters] directory must contain `kindlegen` and `jpg2ps`. They cannot be shipped with this program due to legal reasons.
|
11
|
+
|
12
|
+
|
13
|
+
EXAMPLE: publishr mybook1 my/files/mybook epub path/to/converters
|
14
|
+
|
15
|
+
This will generate the file mybook1.epub in my/files/mybook
|
16
|
+
|
17
|
+
DEPENDENCIES:
|
18
|
+
|
19
|
+
For converting to pdf, you have to install a full verison of a LaTeX system. On Ubuntu systems do
|
20
|
+
|
21
|
+
sudo apt-get install texlive
|
22
|
+
|
23
|
+
If you run into LaTeX errors, you might want to install the full LaTeX suite with
|
24
|
+
|
25
|
+
sudo apt-get install texlive-full
|
26
|
+
|
27
|
+
|
28
|
+
== Licence
|
29
|
+
|
30
|
+
Copyright (C) 2011-2012 Michael Franzl <michael@billgastro.com>
|
31
|
+
|
32
|
+
This program is free software: you can redistribute it and/or modify
|
33
|
+
it under the terms of the GNU Affero General Public License as
|
34
|
+
published by the Free Software Foundation, either version 3 of the
|
35
|
+
License, or (at your option) any later version.
|
36
|
+
|
37
|
+
This program is distributed in the hope that it will be useful,
|
38
|
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
39
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
40
|
+
GNU Affero General Public License for more details.
|
41
|
+
|
42
|
+
You should have received a copy of the GNU Affero General Public License
|
43
|
+
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
data/lib/publishr.rb
CHANGED
@@ -22,7 +22,7 @@ module Publishr
|
|
22
22
|
@inpath = inpath
|
23
23
|
@outpath = outpath
|
24
24
|
@metadata = metadata
|
25
|
-
@gempath =
|
25
|
+
@gempath = Publishr::gempath
|
26
26
|
|
27
27
|
@html_files = []
|
28
28
|
@image_files = []
|
@@ -48,13 +48,13 @@ module Publishr
|
|
48
48
|
def render_htmls
|
49
49
|
kramdown_options = {
|
50
50
|
:auto_ids => false,
|
51
|
-
:smart_quotes => [
|
51
|
+
:smart_quotes => @metadata['kramdown_options']['smart_quotes'],
|
52
52
|
:template => File.join(@gempath,'lib','epub_templates','kramdown.html')
|
53
53
|
}
|
54
54
|
Dir[File.join(@inpath,'*.txt')].each do |infilepath|
|
55
55
|
kramdown = File.open(infilepath, 'r').read
|
56
56
|
html = Kramdown::Document.new(kramdown, kramdown_options).to_html
|
57
|
-
degraded_html =
|
57
|
+
degraded_html = HtmlProcessor.new(html,@inpath,@metadata).degrade
|
58
58
|
outfilepath = File.join(@outpath, File.basename(infilepath).gsub(/(.*).txt/, '\1.html'))
|
59
59
|
File.open(outfilepath, 'w'){ |f| f.write degraded_html }
|
60
60
|
end
|
@@ -1,11 +1,15 @@
|
|
1
1
|
# encoding: UTF-8
|
2
2
|
module Publishr
|
3
|
-
class
|
4
|
-
def initialize(markup,metadata)
|
3
|
+
class HtmlProcessor
|
4
|
+
def initialize(markup,inpath,metadata)
|
5
5
|
@lines = markup.split("\n")
|
6
6
|
@line = ''
|
7
|
+
@inpath = inpath
|
7
8
|
@metadata = metadata
|
8
9
|
|
10
|
+
@custom_fixes = File.open(File.join(@inpath,'html_postprocessing.rb'), 'r').read if File.exists?(File.join(@inpath,'html_postprocessing.rb'))
|
11
|
+
@global_fixes = File.open(File.join(@inpath,'..','html_postprocessing.rb'), 'r').read if File.exists?(File.join(@inpath,'..','html_postprocessing.rb'))
|
12
|
+
|
9
13
|
@depth = 0
|
10
14
|
@quotetype = nil
|
11
15
|
@add_footnote = false
|
@@ -29,6 +33,9 @@ module Publishr
|
|
29
33
|
@process_footnotes = false if @process_footnotes == true and @line.include?('</div>')
|
30
34
|
@add_footnote = true and @footnote_number += 1 if @line.include?('<li id="fn')
|
31
35
|
|
36
|
+
eval(@custom_fixes, binding) if @custom_fixes
|
37
|
+
eval(@global_fixes, binding) if @global_fixes
|
38
|
+
|
32
39
|
annotate_blockquote
|
33
40
|
improve_typography
|
34
41
|
make_uppercase
|
@@ -43,10 +50,6 @@ module Publishr
|
|
43
50
|
@line.gsub!(/title\((.*?)\)/,'<cite>\1</cite>')
|
44
51
|
@line.gsub!(/name\((.*?)\)/,'<var>\1</var>')
|
45
52
|
@line.gsub!(/(\(\w\))/,'<i>\1</i>')
|
46
|
-
|
47
|
-
if @language == 'de'
|
48
|
-
@line.gsub!(/([FA]:)/,'<b>\1</b>')
|
49
|
-
end
|
50
53
|
end
|
51
54
|
|
52
55
|
|
@@ -24,7 +24,7 @@ module Publishr
|
|
24
24
|
@line = ''
|
25
25
|
@inpath = inpath
|
26
26
|
|
27
|
-
@custom_fixes = File.open(File.join(@inpath,'latex_postprocessing.rb'), 'r').read if File.exists?(File.join(@inpath,'latex_postprocessing.rb'
|
27
|
+
@custom_fixes = File.open(File.join(@inpath,'latex_postprocessing.rb'), 'r').read if File.exists?(File.join(@inpath,'latex_postprocessing.rb'))
|
28
28
|
@global_fixes = File.open(File.join(@inpath,'..','latex_postprocessing.rb'), 'r').read if File.exists?(File.join(@inpath,'..','latex_postprocessing.rb'))
|
29
29
|
end
|
30
30
|
|
data/lib/publishr/project.rb
CHANGED
@@ -16,6 +16,10 @@
|
|
16
16
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
17
17
|
|
18
18
|
module Publishr
|
19
|
+
|
20
|
+
mattr_accessor :gempath
|
21
|
+
@@gempath = File.expand_path('../../../', __FILE__)
|
22
|
+
|
19
23
|
class Project
|
20
24
|
def initialize(name,relativepath,converterspath)
|
21
25
|
@name = name
|
data/lib/publishr/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: publishr
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -21,6 +21,7 @@ extra_rdoc_files: []
|
|
21
21
|
files:
|
22
22
|
- .gitignore
|
23
23
|
- Gemfile
|
24
|
+
- README
|
24
25
|
- Rakefile
|
25
26
|
- bin/publishr
|
26
27
|
- lib/epub_skeleton/META-INF/container.xml
|
@@ -34,9 +35,9 @@ files:
|
|
34
35
|
- lib/epub_templates/toc.ncx.erb
|
35
36
|
- lib/publishr.rb
|
36
37
|
- lib/publishr/epub_renderer.rb
|
38
|
+
- lib/publishr/html_processor.rb
|
37
39
|
- lib/publishr/latex_processor.rb
|
38
40
|
- lib/publishr/latex_renderer.rb
|
39
|
-
- lib/publishr/markup_processor.rb
|
40
41
|
- lib/publishr/project.rb
|
41
42
|
- lib/publishr/version.rb
|
42
43
|
- publishr.gemspec
|