cheepub 0.5.1 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +6 -1
- data/Rakefile +1 -0
- data/cheepub.gemspec +2 -0
- data/lib/cheepub/cli.rb +8 -3
- data/lib/cheepub/content.rb +16 -8
- data/lib/cheepub/converter/cheelatex.rb +25 -0
- data/lib/cheepub/ext_hash.rb +2 -2
- data/lib/cheepub/generator/epub.rb +62 -0
- data/lib/cheepub/generator/latex.rb +45 -0
- data/lib/cheepub/generator.rb +14 -44
- data/lib/cheepub/heading_parser/handler.rb +31 -0
- data/lib/cheepub/heading_parser.rb +1 -29
- data/lib/cheepub/markdown.rb +12 -3
- data/lib/cheepub/nav.rb +2 -3
- data/lib/cheepub/templates/bodymatter.tex.erb +3 -0
- data/lib/cheepub/version.rb +1 -1
- data/lib/cheepub.rb +4 -1
- data/lib/{cheepub/markdown → kramdown/parser}/cheemarkdown.rb +2 -2
- data/misc/conv_ruby.rb +30 -0
- metadata +37 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2659a123426dae2c0d7f94b73381e2e05362a9e015e7bd3a26e0f74aaccaa1fe
|
4
|
+
data.tar.gz: 704a0aa4e29387fde80a2ac457ad115f4b356c4a3da4092cbfd5131624c9a6c8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 972f300f46ca01da7c0340163c71ec9edd5d91c8283825f2ec420c885968962500b2a7b2bae65bd7da921da798fb4a4412efb89beb128ed928cd75cec793d086
|
7
|
+
data.tar.gz: a22d6bb40e437164d8ee91b6bede5dc553430aad68cf1729f93113d7093f8822cab9d87b649740822d13a34e7afd9b80079be14a401bb9d318e85f5ca02151fa
|
data/README.md
CHANGED
@@ -37,7 +37,8 @@ $ cheepub source.md
|
|
37
37
|
* `--author AUTOR` set author of the book
|
38
38
|
* `--title TITLE` set title of the book
|
39
39
|
* `--config CONFIG` set configuration file
|
40
|
-
*
|
40
|
+
* `--latex` (experimental) generate PDF (with LaTeX) file
|
41
|
+
* `-o, --out OUTFILE` set output filename
|
41
42
|
* `--[no-]titlepage` add titlepage or not
|
42
43
|
* `-h, --help` print help
|
43
44
|
|
@@ -86,6 +87,10 @@ In a little district west of Washington Square the streets have run crazy and br
|
|
86
87
|
|
87
88
|
## History
|
88
89
|
|
90
|
+
### 0.6.0
|
91
|
+
|
92
|
+
- (experimental) generate PDF file with LaTeX
|
93
|
+
|
89
94
|
### 0.5.1
|
90
95
|
|
91
96
|
- fix to generate valid epub file
|
data/Rakefile
CHANGED
data/cheepub.gemspec
CHANGED
@@ -23,6 +23,8 @@ Gem::Specification.new do |spec|
|
|
23
23
|
spec.add_dependency "kramdown", "~> 1.16"
|
24
24
|
spec.add_dependency "clamp", "~> 1.2"
|
25
25
|
spec.add_dependency "oga", "~> 2.15"
|
26
|
+
spec.add_dependency "coderay"
|
27
|
+
spec.add_dependency "rb_latex"
|
26
28
|
|
27
29
|
spec.add_development_dependency "rufo", "~> 0.3"
|
28
30
|
spec.add_development_dependency "bundler", "~> 1.16"
|
data/lib/cheepub/cli.rb
CHANGED
@@ -9,7 +9,8 @@ module Cheepub
|
|
9
9
|
option ["--author"], "AUTOR", "set author of the book"
|
10
10
|
option ["--title"], "TITLE", "set title of the book"
|
11
11
|
option ["--config"], "CONFIG", "set configuration file"
|
12
|
-
option ["
|
12
|
+
option ["--latex"], :flag, "generate PDF with LaTeX"
|
13
|
+
option ["-o", "--output"], "EPUBFILE", "set output filename", attribute_name: :output
|
13
14
|
option ["--[no-]titlepage"], :flag, "add titlepage (or not)"
|
14
15
|
|
15
16
|
parameter "SRC", "source file"
|
@@ -21,9 +22,13 @@ module Cheepub
|
|
21
22
|
end
|
22
23
|
params[:author] = author
|
23
24
|
params[:title] = title
|
24
|
-
params[:
|
25
|
+
params[:output] = output
|
25
26
|
params[:titlepage] = titlepage?
|
26
|
-
|
27
|
+
if latex?
|
28
|
+
gen = Cheepub::Generator::Latex.new(src, params)
|
29
|
+
else
|
30
|
+
gen = Cheepub::Generator::Epub.new(src, params)
|
31
|
+
end
|
27
32
|
begin
|
28
33
|
gen.execute
|
29
34
|
rescue Cheepub::Error => e
|
data/lib/cheepub/content.rb
CHANGED
@@ -18,10 +18,24 @@ module Cheepub
|
|
18
18
|
@pages = separate_pages(@body)
|
19
19
|
end
|
20
20
|
|
21
|
-
def
|
22
|
-
@pages.map{ |page| Cheepub::Markdown.new(page).
|
21
|
+
def converted_pages(target = :to_html)
|
22
|
+
@pages.map{ |page| Cheepub::Markdown.new(page).__send__(target) }
|
23
23
|
end
|
24
24
|
|
25
|
+
def each_content_with_filename(ext)
|
26
|
+
if ext == "xhtml"
|
27
|
+
target = :to_html
|
28
|
+
elsif ext == "tex"
|
29
|
+
target = :to_latex
|
30
|
+
else
|
31
|
+
raise Cheepub::Error, "invalid ext: #{ext}"
|
32
|
+
end
|
33
|
+
converted_pages(target).each_with_index do |page, idx|
|
34
|
+
yield page, "bodymatter_#{idx}.#{ext}"
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
|
25
39
|
def separate_pages(body)
|
26
40
|
pages = nil
|
27
41
|
if body =~ SEPARATOR_PATTERN
|
@@ -46,11 +60,5 @@ module Cheepub
|
|
46
60
|
end
|
47
61
|
return header, body
|
48
62
|
end
|
49
|
-
|
50
|
-
def each_html_with_filename
|
51
|
-
html_pages.each_with_index do |page, idx|
|
52
|
-
yield page, "bodymatter_#{idx}.xhtml"
|
53
|
-
end
|
54
|
-
end
|
55
63
|
end
|
56
64
|
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
require "kramdown/converter/latex"
|
2
|
+
|
3
|
+
module Cheepub
|
4
|
+
module Converter
|
5
|
+
module CheeLatex
|
6
|
+
def convert_html_element(el, opts)
|
7
|
+
if el.value == :ruby
|
8
|
+
str = inner(el, opts)
|
9
|
+
"\\ruby[g]{#{str}}"
|
10
|
+
elsif el.value == :rt
|
11
|
+
str = inner(el, opts)
|
12
|
+
"}{#{str}"
|
13
|
+
elsif el.value == :span
|
14
|
+
"\\rensuji{#{inner(el, opts)}}"
|
15
|
+
else
|
16
|
+
super
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
class Kramdown::Converter::Latex
|
24
|
+
prepend Cheepub::Converter::CheeLatex
|
25
|
+
end
|
data/lib/cheepub/ext_hash.rb
CHANGED
@@ -6,12 +6,12 @@ module Cheepub
|
|
6
6
|
if self[key].kind_of? Hash
|
7
7
|
self[key].symbolize_keys!
|
8
8
|
end
|
9
|
-
self[
|
9
|
+
self[key_to_sym(key)] = delete(key)
|
10
10
|
end
|
11
11
|
self
|
12
12
|
end
|
13
13
|
|
14
|
-
def
|
14
|
+
def key_to_sym(key)
|
15
15
|
(key.to_sym rescue nil) || key
|
16
16
|
end
|
17
17
|
end
|
@@ -0,0 +1,62 @@
|
|
1
|
+
require 'securerandom'
|
2
|
+
require 'gepub'
|
3
|
+
require 'cheepub/generator'
|
4
|
+
|
5
|
+
module Cheepub
|
6
|
+
class Generator
|
7
|
+
class Epub < Cheepub::Generator
|
8
|
+
|
9
|
+
attr_reader :book
|
10
|
+
|
11
|
+
def initialize(src, params = Hash.new)
|
12
|
+
super
|
13
|
+
@book = GEPUB::Book.new
|
14
|
+
end
|
15
|
+
|
16
|
+
def output_file(params)
|
17
|
+
output = params[:output] || "book.epub"
|
18
|
+
@book.generate_epub(output)
|
19
|
+
end
|
20
|
+
|
21
|
+
def add_creator(name, role)
|
22
|
+
@book.add_creator(name, nil, role)
|
23
|
+
end
|
24
|
+
|
25
|
+
def apply_params(params)
|
26
|
+
@book.identifier = params[:id] || "urn:uuid:#{SecureRandom.uuid}"
|
27
|
+
@book.title = params[:title]
|
28
|
+
@book.add_creator(params[:author])
|
29
|
+
parse_creator(params[:creator])
|
30
|
+
@book.language = params[:language] || 'ja'
|
31
|
+
@book.version = '3.0'
|
32
|
+
@book.publisher = params[:publisher] if params[:publisher]
|
33
|
+
## book.date= params[:date] || Time.now
|
34
|
+
@book.add_date(params[:date] || Time.now, nil)
|
35
|
+
@book.lastmodified = params[:lastModified] || Time.now
|
36
|
+
@book.page_progression_direction = params[:pageDirection]
|
37
|
+
style_content = apply_template("style.css.erb")
|
38
|
+
@book.add_item("style.css").add_raw_content(style_content)
|
39
|
+
@book.ordered do
|
40
|
+
make_titlepage(params)
|
41
|
+
nav = Cheepub::Nav.new(@content)
|
42
|
+
@book.add_item('nav.xhtml', nil,nil,'properties'=>['nav']).add_raw_content(nav.to_html)
|
43
|
+
@content.each_content_with_filename("xhtml") do |html, filename|
|
44
|
+
@book.add_item(filename).add_raw_content(html)
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
def apply_template(template_file)
|
50
|
+
template = File.read(File.join(Cheepub::Generator::TEMPLATES_DIR, template_file))
|
51
|
+
return ERB.new(template).result(binding)
|
52
|
+
end
|
53
|
+
|
54
|
+
def make_titlepage(params)
|
55
|
+
if params[:titlepage]
|
56
|
+
titlepage_content = apply_template("titlepage.xhtml.erb")
|
57
|
+
@book.add_item("titlepage.xhtml").add_raw_content(titlepage_content)
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
require 'cheepub/generator'
|
2
|
+
require 'rb_latex'
|
3
|
+
|
4
|
+
module Cheepub
|
5
|
+
class Generator
|
6
|
+
class Latex < Cheepub::Generator
|
7
|
+
|
8
|
+
attr_reader :maker
|
9
|
+
|
10
|
+
def initialize(src, params = Hash.new)
|
11
|
+
super
|
12
|
+
root_dir = File.dirname(src)
|
13
|
+
@maker = RbLatex::Maker.new(root_dir)
|
14
|
+
end
|
15
|
+
|
16
|
+
def output_file(params)
|
17
|
+
outfile = params[:outfile] || "book.pdf"
|
18
|
+
@maker.generate_pdf(outfile)
|
19
|
+
end
|
20
|
+
|
21
|
+
def add_creator(name, role = "aut")
|
22
|
+
@maker.add_creator(name, role)
|
23
|
+
end
|
24
|
+
|
25
|
+
def apply_params(params)
|
26
|
+
@maker.title = params[:title]
|
27
|
+
add_creator(params[:author])
|
28
|
+
parse_creator(params[:creator])
|
29
|
+
##@maker.language = params[:language] || 'ja'
|
30
|
+
@maker.publisher = params[:publisher] if params[:publisher]
|
31
|
+
@maker.date= params[:date] || Time.now
|
32
|
+
@maker.lastmodified = params[:lastModified] || Time.now
|
33
|
+
@maker.page_progression_direction = params[:pageDirection]
|
34
|
+
@content.each_content_with_filename("tex") do |content, filename|
|
35
|
+
@maker.add_item(filename, content)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
def apply_template(template_file)
|
40
|
+
template = File.read(File.join(Cheepub::Generator::TEMPLATES_DIR, template_file))
|
41
|
+
return ERB.new(template).result(binding)
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
data/lib/cheepub/generator.rb
CHANGED
@@ -1,14 +1,10 @@
|
|
1
|
-
require 'securerandom'
|
2
|
-
require 'gepub'
|
3
|
-
|
4
1
|
module Cheepub
|
5
2
|
class Generator
|
6
3
|
|
7
|
-
attr_reader :book
|
8
|
-
|
9
4
|
ROLES = %i{aut edt trl ill cov cre pht cwt nrt}
|
5
|
+
TEMPLATES_DIR = File.join(File.dirname(__FILE__), "templates")
|
10
6
|
|
11
|
-
def initialize(src, params
|
7
|
+
def initialize(src, params)
|
12
8
|
if src.kind_of? Cheepub::Content
|
13
9
|
@src = nil
|
14
10
|
@content = src
|
@@ -17,15 +13,17 @@ module Cheepub
|
|
17
13
|
@content = Cheepub::Content.new(File.read(@src))
|
18
14
|
end
|
19
15
|
@params = params
|
20
|
-
@book = GEPUB::Book.new
|
21
16
|
end
|
22
17
|
|
23
18
|
def execute
|
24
19
|
params = @content.header.merge(@params){|key, val, arg_val| arg_val.nil? ? val : arg_val}
|
25
20
|
check_params(params)
|
26
21
|
apply_params(params)
|
27
|
-
|
28
|
-
|
22
|
+
output_file(params)
|
23
|
+
end
|
24
|
+
|
25
|
+
def output_file
|
26
|
+
raise NotImplementedError
|
29
27
|
end
|
30
28
|
|
31
29
|
def parse_creator(creator)
|
@@ -33,17 +31,21 @@ module Cheepub
|
|
33
31
|
when nil
|
34
32
|
return
|
35
33
|
when String
|
36
|
-
|
34
|
+
add_creator(name, "aut")
|
37
35
|
else
|
38
36
|
creator.each do |role, name|
|
39
37
|
if !ROLES.include?(role)
|
40
38
|
raise Cheepub::Error, "invalid role: '#{role}' for creator '#{name}'."
|
41
39
|
end
|
42
|
-
|
40
|
+
add_creator(name, role)
|
43
41
|
end
|
44
42
|
end
|
45
43
|
end
|
46
44
|
|
45
|
+
def add_creator(name, role)
|
46
|
+
raise NotImplementedError
|
47
|
+
end
|
48
|
+
|
47
49
|
def check_params(params)
|
48
50
|
if !params[:author] || !params[:title]
|
49
51
|
raise Cheepub::Error, "you must use `--author` and `--title`, or add front-matter in Markdown file."
|
@@ -51,39 +53,7 @@ module Cheepub
|
|
51
53
|
end
|
52
54
|
|
53
55
|
def apply_params(params)
|
54
|
-
|
55
|
-
@book.title = params[:title]
|
56
|
-
@book.add_creator(params[:author])
|
57
|
-
parse_creator(params[:creator])
|
58
|
-
@book.language = params[:language] || 'ja'
|
59
|
-
@book.version = '3.0'
|
60
|
-
@book.publisher = params[:publisher] if params[:publisher]
|
61
|
-
## book.date= params[:date] || Time.now
|
62
|
-
@book.add_date(params[:date] || Time.now, nil)
|
63
|
-
@book.lastmodified = params[:lastModified] || Time.now
|
64
|
-
@book.page_progression_direction = params[:pageDirection]
|
65
|
-
style_content = apply_template("templates/style.css.erb")
|
66
|
-
@book.add_item("style.css").add_raw_content(style_content)
|
67
|
-
@book.ordered do
|
68
|
-
make_titlepage(params)
|
69
|
-
nav = Cheepub::Nav.new(@content)
|
70
|
-
@book.add_item('nav.xhtml', nil,nil,'properties'=>['nav']).add_raw_content(nav.to_html)
|
71
|
-
@content.each_html_with_filename do |html, filename|
|
72
|
-
@book.add_item(filename).add_raw_content(html)
|
73
|
-
end
|
74
|
-
end
|
75
|
-
end
|
76
|
-
|
77
|
-
def apply_template(template_file)
|
78
|
-
template = File.read(File.join(File.dirname(__FILE__), template_file))
|
79
|
-
return ERB.new(template).result(binding)
|
80
|
-
end
|
81
|
-
|
82
|
-
def make_titlepage(params)
|
83
|
-
if params[:titlepage]
|
84
|
-
titlepage_content = apply_template("templates/titlepage.xhtml.erb")
|
85
|
-
@book.add_item("titlepage.xhtml").add_raw_content(titlepage_content)
|
86
|
-
end
|
56
|
+
raise NotImplementedError
|
87
57
|
end
|
88
58
|
end
|
89
59
|
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
module Cheepub
|
2
|
+
class HeadingParser
|
3
|
+
class Handler
|
4
|
+
|
5
|
+
attr_reader :result
|
6
|
+
|
7
|
+
def initialize(filename)
|
8
|
+
@filename = filename
|
9
|
+
@stack = []
|
10
|
+
@result = []
|
11
|
+
end
|
12
|
+
|
13
|
+
def on_element(ns, name, attrs)
|
14
|
+
if name =~ /^h([1-6])/i
|
15
|
+
@stack.push({filename: @filename, name: name, level: $1.to_i, content: "", id: attrs["id"]})
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
def on_text(text)
|
20
|
+
last_elem = @stack[-1]
|
21
|
+
return if !last_elem
|
22
|
+
last_elem[:content] = last_elem[:content]+text
|
23
|
+
end
|
24
|
+
|
25
|
+
def after_element(ns, name)
|
26
|
+
return if @stack.empty?
|
27
|
+
@result.push(@stack.pop)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -1,37 +1,9 @@
|
|
1
1
|
require "oga"
|
2
2
|
require "cheepub/heading_item"
|
3
|
+
require "cheepub/heading_parser/handler"
|
3
4
|
|
4
5
|
module Cheepub
|
5
6
|
class HeadingParser
|
6
|
-
|
7
|
-
class Handler
|
8
|
-
|
9
|
-
attr_reader :result
|
10
|
-
|
11
|
-
def initialize(filename)
|
12
|
-
@filename = filename
|
13
|
-
@stack = []
|
14
|
-
@result = []
|
15
|
-
end
|
16
|
-
|
17
|
-
def on_element(ns, name, attrs)
|
18
|
-
if name =~ /^h([1-6])/i
|
19
|
-
@stack.push({filename: @filename, name: name, level: $1.to_i, content: "", id: attrs["id"]})
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
|
-
def on_text(text)
|
24
|
-
last_elem = @stack[-1]
|
25
|
-
return if !last_elem
|
26
|
-
last_elem[:content] = last_elem[:content]+text
|
27
|
-
end
|
28
|
-
|
29
|
-
def after_element(ns, name)
|
30
|
-
return if @stack.empty?
|
31
|
-
@result.push(@stack.pop)
|
32
|
-
end
|
33
|
-
end
|
34
|
-
|
35
7
|
def initialize
|
36
8
|
end
|
37
9
|
|
data/lib/cheepub/markdown.rb
CHANGED
@@ -12,17 +12,26 @@ module Cheepub
|
|
12
12
|
def initialize(text, **params)
|
13
13
|
default_params = {template: File.join(File.dirname(__FILE__), "templates/bodymatter.html.erb"),
|
14
14
|
lang: "ja",
|
15
|
-
title: "
|
15
|
+
title: "content",
|
16
16
|
cssfile: "style.css",
|
17
17
|
generator: "Cheepub #{Cheepub::VERSION} with kramdown #{Kramdown::VERSION}",
|
18
|
-
input: "
|
18
|
+
input: "cheemarkdown",
|
19
19
|
}
|
20
20
|
@params = default_params.merge(params)
|
21
21
|
@text = text
|
22
22
|
end
|
23
23
|
|
24
24
|
def convert
|
25
|
-
|
25
|
+
params = @params.dup
|
26
|
+
params[:syntax_highlighter] = "coderay"
|
27
|
+
Kramdown::Document.new(@text, params).to_html
|
28
|
+
end
|
29
|
+
|
30
|
+
def to_latex
|
31
|
+
params = @params.dup
|
32
|
+
params[:template] = File.join(File.dirname(__FILE__), "templates/bodymatter.tex.erb")
|
33
|
+
params[:latex_headers] = %w{chapter section subsection subsubsection paragraph subparagraph}
|
34
|
+
Kramdown::Document.new(@text, params).to_latex
|
26
35
|
end
|
27
36
|
|
28
37
|
alias_method :to_html, :convert
|
data/lib/cheepub/nav.rb
CHANGED
@@ -15,8 +15,7 @@ module Cheepub
|
|
15
15
|
template = File.read(File.join(File.dirname(__FILE__), "templates/nav.xhtml.erb"))
|
16
16
|
@body = @root.to_html_ol
|
17
17
|
erb = ERB.new(template)
|
18
|
-
|
19
|
-
str
|
18
|
+
return erb.result(binding)
|
20
19
|
end
|
21
20
|
|
22
21
|
|
@@ -29,7 +28,7 @@ module Cheepub
|
|
29
28
|
end
|
30
29
|
|
31
30
|
def make_file_list
|
32
|
-
@content.to_enum(:
|
31
|
+
@content.to_enum(:each_content_with_filename, "xhtml").map{|html,filename| [filename, html]}.to_a
|
33
32
|
end
|
34
33
|
end
|
35
34
|
end
|
data/lib/cheepub/version.rb
CHANGED
data/lib/cheepub.rb
CHANGED
@@ -3,10 +3,13 @@ require "cheepub/version"
|
|
3
3
|
require "cheepub/error"
|
4
4
|
require "cheepub/ext_hash"
|
5
5
|
require "cheepub/markdown"
|
6
|
-
require "
|
6
|
+
require "kramdown/parser/cheemarkdown"
|
7
7
|
require "cheepub/cli"
|
8
8
|
require "cheepub/generator"
|
9
|
+
require "cheepub/generator/epub"
|
10
|
+
require "cheepub/generator/latex"
|
9
11
|
require "cheepub/content"
|
10
12
|
require "cheepub/heading_parser"
|
11
13
|
require "cheepub/heading_item"
|
12
14
|
require "cheepub/nav"
|
15
|
+
require "cheepub/converter/cheelatex"
|
data/misc/conv_ruby.rb
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
#
|
3
|
+
# convert HTML ruby format into DenDen Markdown ruby format
|
4
|
+
#
|
5
|
+
# if you convert html in Shift_JIS, use:
|
6
|
+
#
|
7
|
+
# $ ruby -Eshift_jis conv_ruby.rb original.html > converted.html
|
8
|
+
#
|
9
|
+
|
10
|
+
RUBY_PATTERN = /<ruby><rb>([^<]+)<\/rb>(?:<rp>[^<]+<\/rp>)?<rt>([^<]+)<\/rt>(?:<rp>[^<]+<\/rp>)?<\/ruby>/
|
11
|
+
|
12
|
+
def conv_ruby(str)
|
13
|
+
str.gsub(RUBY_PATTERN) do |matched|
|
14
|
+
"{#{$1}|#{$2}}"
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
if ARGV.empty?
|
19
|
+
print "usage: ruby conv_ruby.rb [htmlfile]\n"
|
20
|
+
exit 0
|
21
|
+
end
|
22
|
+
|
23
|
+
ARGV.each do |file|
|
24
|
+
File.open(file) do |f|
|
25
|
+
f.each_line do |line|
|
26
|
+
conved = conv_ruby(line)
|
27
|
+
print conved
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cheepub
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- takahashim
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-05-
|
11
|
+
date: 2018-05-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: gepub
|
@@ -66,6 +66,34 @@ dependencies:
|
|
66
66
|
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '2.15'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: coderay
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :runtime
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: rb_latex
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :runtime
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
69
97
|
- !ruby/object:Gem::Dependency
|
70
98
|
name: rufo
|
71
99
|
requirement: !ruby/object:Gem::Requirement
|
@@ -172,19 +200,25 @@ files:
|
|
172
200
|
- lib/cheepub.rb
|
173
201
|
- lib/cheepub/cli.rb
|
174
202
|
- lib/cheepub/content.rb
|
203
|
+
- lib/cheepub/converter/cheelatex.rb
|
175
204
|
- lib/cheepub/error.rb
|
176
205
|
- lib/cheepub/ext_hash.rb
|
177
206
|
- lib/cheepub/generator.rb
|
207
|
+
- lib/cheepub/generator/epub.rb
|
208
|
+
- lib/cheepub/generator/latex.rb
|
178
209
|
- lib/cheepub/heading_item.rb
|
179
210
|
- lib/cheepub/heading_parser.rb
|
211
|
+
- lib/cheepub/heading_parser/handler.rb
|
180
212
|
- lib/cheepub/markdown.rb
|
181
|
-
- lib/cheepub/markdown/cheemarkdown.rb
|
182
213
|
- lib/cheepub/nav.rb
|
183
214
|
- lib/cheepub/templates/bodymatter.html.erb
|
215
|
+
- lib/cheepub/templates/bodymatter.tex.erb
|
184
216
|
- lib/cheepub/templates/nav.xhtml.erb
|
185
217
|
- lib/cheepub/templates/style.css.erb
|
186
218
|
- lib/cheepub/templates/titlepage.xhtml.erb
|
187
219
|
- lib/cheepub/version.rb
|
220
|
+
- lib/kramdown/parser/cheemarkdown.rb
|
221
|
+
- misc/conv_ruby.rb
|
188
222
|
- samples/thelastleaf.md
|
189
223
|
- samples/thelastleaf_ja.md
|
190
224
|
- samples/yume_juya.md
|