cheepub 0.7.1 → 0.8.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 -0
- data/lib/cheepub/cli.rb +9 -1
- data/lib/cheepub/converter/cheelatex.rb +12 -0
- data/lib/cheepub/generator/latex.rb +1 -1
- data/lib/cheepub/markdown.rb +13 -0
- data/lib/cheepub/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 538a1c736e4d3cec8c8f051bf9a2a17b6d623694598d83d3470226e1b5b164dc
|
4
|
+
data.tar.gz: 5034ff0f4b102495fdf61773554f9097c1879c923523d2633394f6baff40ae0c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e415c2d6100b921d9d61a4bc8ba078a38d0e4e2e9aa2f50d598c0908743266471ecded67828431e62e78f06032349d7cb97f99601c220af6e7295c877a5bb871
|
7
|
+
data.tar.gz: a2942d1b33fdf849977122d92998b9d91f972a36ba9819190f9b4f3313e04ebb8ec65e9b45dc23c70881329991ddabf7238916768f77aaec531f589c204f8e4c
|
data/README.md
CHANGED
@@ -41,6 +41,8 @@ $ cheepub source.md
|
|
41
41
|
* `--debug` set debug mode
|
42
42
|
* `-o, --out OUTFILE` set output filename
|
43
43
|
* `--[no-]titlepage` add titlepage or not
|
44
|
+
* `--page-direction PAGE_DIRECTION` set page direction (`ltr` or `rtl`)
|
45
|
+
* `--json` output JSON AST and exit
|
44
46
|
* `-h, --help` print help
|
45
47
|
|
46
48
|
|
@@ -88,6 +90,10 @@ In a little district west of Washington Square the streets have run crazy and br
|
|
88
90
|
|
89
91
|
## History
|
90
92
|
|
93
|
+
### 0.8.0
|
94
|
+
|
95
|
+
- support option `--json`
|
96
|
+
|
91
97
|
### 0.7.1
|
92
98
|
|
93
99
|
- show backtrace when `--debug` mode
|
data/lib/cheepub/cli.rb
CHANGED
@@ -11,8 +11,10 @@ module Cheepub
|
|
11
11
|
option ["--config"], "CONFIG", "set configuration file"
|
12
12
|
option ["--latex"], :flag, "generate PDF with LaTeX"
|
13
13
|
option ["--debug"], :flag, "set debug mode"
|
14
|
-
option ["
|
14
|
+
option ["--json"], :flag, "output JSON AST and exit"
|
15
|
+
option ["-o", "--output"], "OUTFILE", "set output filename", attribute_name: :output
|
15
16
|
option ["--[no-]titlepage"], :flag, "add titlepage (or not)"
|
17
|
+
option ["--page-direction"], "PAGE_DIRECTION", "set page direction (ltr or rtl)"
|
16
18
|
|
17
19
|
parameter "SRC", "source file"
|
18
20
|
|
@@ -26,6 +28,12 @@ module Cheepub
|
|
26
28
|
params[:output] = output
|
27
29
|
params[:titlepage] = titlepage?
|
28
30
|
params[:debug] = debug?
|
31
|
+
params[:pageDirection] = page_direction
|
32
|
+
if json?
|
33
|
+
params[:template] = nil
|
34
|
+
print Cheepub::Markdown.parse(src, params).to_json
|
35
|
+
exit 0
|
36
|
+
end
|
29
37
|
if latex?
|
30
38
|
gen = Cheepub::Generator::Latex.new(src, params)
|
31
39
|
else
|
@@ -4,6 +4,16 @@ module Cheepub
|
|
4
4
|
module Converter
|
5
5
|
module CheeLatex
|
6
6
|
|
7
|
+
def convert_p(el, opts)
|
8
|
+
if el.children.size == 1 && el.children.first.type == :img && !(img = convert_img(el.children.first, opts)).empty?
|
9
|
+
convert_standalone_image(el, opts, img)
|
10
|
+
elsif el.attr['class'].to_s =~ /text\-right/
|
11
|
+
"#{latex_link_target(el)}\\begin{flushright}#{inner(el, opts)}\\end{flushright}\n\n"
|
12
|
+
else
|
13
|
+
"#{latex_link_target(el)}#{inner(el, opts)}\n\n"
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
7
17
|
def convert_codeblock(el, opts)
|
8
18
|
show_whitespace = el.attr['class'].to_s =~ /\bshow-whitespaces\b/
|
9
19
|
lang = extract_code_language(el.attr)
|
@@ -35,6 +45,8 @@ module Cheepub
|
|
35
45
|
"}{#{str}"
|
36
46
|
elsif el.value == :span
|
37
47
|
"\\rensuji{#{inner(el, opts)}}"
|
48
|
+
elsif el.value == :p && el.children.size == 1 && el.children.first.value == :br
|
49
|
+
"\\vspace{\\baselineskip}\n"
|
38
50
|
else
|
39
51
|
super
|
40
52
|
end
|
data/lib/cheepub/markdown.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'kramdown'
|
2
|
+
require 'json'
|
2
3
|
|
3
4
|
module Cheepub
|
4
5
|
class Markdown
|
@@ -37,6 +38,18 @@ module Cheepub
|
|
37
38
|
|
38
39
|
alias_method :to_html, :convert
|
39
40
|
|
41
|
+
def to_hash_ast
|
42
|
+
params = @params.dup
|
43
|
+
params[:template] = nil
|
44
|
+
Kramdown::Document.new(@text, params).to_hash_ast
|
45
|
+
end
|
46
|
+
|
47
|
+
def to_json
|
48
|
+
params = @params.dup
|
49
|
+
params[:template] = nil
|
50
|
+
Kramdown::Document.new(@text, params).to_hash_ast.to_json
|
51
|
+
end
|
52
|
+
|
40
53
|
def save_as(filename)
|
41
54
|
html = convert
|
42
55
|
File.write(filename, html)
|
data/lib/cheepub/version.rb
CHANGED
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.8.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-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: gepub
|