cbeta 2.1.2 → 2.1.3
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.
- checksums.yaml +4 -4
- data/lib/cbeta/p5a_to_html_for_pdf.rb +39 -23
- data/lib/data/html-for-pdf.css +6 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6a715f9ac4b0f18f5625856482341f62bdff33a4
|
4
|
+
data.tar.gz: 154ad81979345e05396abeea9469e9af236223f7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3a89be3fc162f65bd4d370ef99005cefbb2baf30d7de1da047226167d711701f0d6c0c7d268a6b8a97dc79621ad9508f07491159ca188c8f1c56d998ef53bf11
|
7
|
+
data.tar.gz: 360a1f08ae300207ca0181bc459bccc9aac3f4b2f926c4a3f2f3d3cc1a2adc625eb14a7ce2a9c9a73825f77f5936757f0233da405d955139aacb32acc9404731
|
@@ -83,28 +83,41 @@ class CBETA::P5aToHTMLForPDF
|
|
83
83
|
@nav_doc.remove_namespaces!()
|
84
84
|
@nav_root = @nav_doc.at_xpath('/ul')
|
85
85
|
@current_nav = [@nav_root]
|
86
|
+
@div_count = 0
|
86
87
|
@mulu_count = 0
|
88
|
+
@open_divs = []
|
89
|
+
@text = ''
|
87
90
|
|
88
91
|
@output_folder_work = File.join(@out_root, @series, work_id)
|
89
92
|
FileUtils.mkdir_p(@output_folder_work) unless Dir.exist? @output_folder_work
|
90
|
-
|
91
|
-
|
92
|
-
def before_parse_xml(xml_fn)
|
93
|
-
@div_count = 0
|
94
|
-
@in_l = false
|
95
|
-
@lg_row_open = false
|
96
|
-
@t_buf1 = []
|
97
|
-
@t_buf2 = []
|
98
|
-
@open_divs = []
|
99
|
-
@sutra_no = File.basename(xml_fn, ".xml")
|
100
|
-
|
93
|
+
|
101
94
|
src = File.join(CBETA::DATA, 'html-for-pdf.css')
|
102
95
|
copy_file(src)
|
103
96
|
|
97
|
+
@cover = nil
|
98
|
+
if @config.key? :graphic_base
|
99
|
+
cover = File.join(@config[:graphic_base], 'covers', @series, "#{work_id}.jpg")
|
100
|
+
if File.exist? cover
|
101
|
+
@mulu_count += 1
|
102
|
+
@cover = "<a id='mulu#{@mulu_count}'></a><mulu1 title='封面'> </mulu1>"
|
103
|
+
@cover += "<div id='cover'><img src='#{work_id}.jpg' /></div>"
|
104
|
+
copy_file(cover)
|
105
|
+
end
|
106
|
+
end
|
107
|
+
|
104
108
|
if @config[:front_page_title]
|
105
109
|
s = @config[:front_page_title]
|
106
110
|
@nav_root.add_child("<li><a href='#front'>#{s}</a></li>")
|
107
111
|
end
|
112
|
+
|
113
|
+
end
|
114
|
+
|
115
|
+
def before_parse_xml(xml_fn)
|
116
|
+
@in_l = false
|
117
|
+
@lg_row_open = false
|
118
|
+
@t_buf1 = []
|
119
|
+
@t_buf2 = []
|
120
|
+
@sutra_no = File.basename(xml_fn, ".xml")
|
108
121
|
end
|
109
122
|
|
110
123
|
def convert_all
|
@@ -126,7 +139,7 @@ class CBETA::P5aToHTMLForPDF
|
|
126
139
|
end
|
127
140
|
|
128
141
|
def convert_work(work_id, xml_files)
|
129
|
-
puts "convert
|
142
|
+
puts "convert xml to html: work_id: #{work_id}"
|
130
143
|
|
131
144
|
before_convert_work(work_id)
|
132
145
|
|
@@ -136,14 +149,6 @@ class CBETA::P5aToHTMLForPDF
|
|
136
149
|
@nav_root.add_child("<li><a href='#back'>#{s}</a></li>")
|
137
150
|
end
|
138
151
|
|
139
|
-
@cover = nil
|
140
|
-
if @config.key? :graphic_base
|
141
|
-
cover = File.join(@config[:graphic_base], 'covers', @series, "#{work_id}.jpg")
|
142
|
-
if File.exist? cover
|
143
|
-
@cover = "<div id='cover'><img src='#{work_id}.jpg' /></div>"
|
144
|
-
copy_file(cover)
|
145
|
-
end
|
146
|
-
end
|
147
152
|
|
148
153
|
if @config.key? :front_page
|
149
154
|
s = File.read(@config[:front_page])
|
@@ -155,7 +160,6 @@ class CBETA::P5aToHTMLForPDF
|
|
155
160
|
@back = "<div id='back'>#{s}</div>"
|
156
161
|
end
|
157
162
|
|
158
|
-
@text = ''
|
159
163
|
xml_files.each do |fn|
|
160
164
|
@text += convert_xml_file(fn)
|
161
165
|
end
|
@@ -419,7 +423,13 @@ class CBETA::P5aToHTMLForPDF
|
|
419
423
|
end
|
420
424
|
|
421
425
|
def handle_list(e)
|
422
|
-
|
426
|
+
doc = Nokogiri::XML::Document.new
|
427
|
+
node = doc.create_element('ul')
|
428
|
+
if e.key? 'rendition'
|
429
|
+
node['class'] = e['rendition']
|
430
|
+
end
|
431
|
+
node.inner_html = traverse(e)
|
432
|
+
to_html(node) + "\n"
|
423
433
|
end
|
424
434
|
|
425
435
|
def handle_milestone(e)
|
@@ -510,7 +520,13 @@ class CBETA::P5aToHTMLForPDF
|
|
510
520
|
end
|
511
521
|
|
512
522
|
def handle_p(e)
|
513
|
-
|
523
|
+
doc = Nokogiri::XML::Document.new
|
524
|
+
node = doc.create_element('p')
|
525
|
+
if e.key? 'rend'
|
526
|
+
node['style'] = e['rend']
|
527
|
+
end
|
528
|
+
node.inner_html = traverse(e)
|
529
|
+
to_html(node) + "\n"
|
514
530
|
end
|
515
531
|
|
516
532
|
def handle_row(e)
|
data/lib/data/html-for-pdf.css
CHANGED
@@ -16,6 +16,11 @@ a {
|
|
16
16
|
body {
|
17
17
|
font-family: PMingLiU, extb;
|
18
18
|
}
|
19
|
+
|
20
|
+
div#cover {
|
21
|
+
page-break-after: always
|
22
|
+
}
|
23
|
+
|
19
24
|
div.lg {
|
20
25
|
display: table;
|
21
26
|
margin-left: 1em;
|
@@ -133,6 +138,7 @@ th, td {
|
|
133
138
|
word-break: break-all;
|
134
139
|
text-indent: 0;
|
135
140
|
}
|
141
|
+
|
136
142
|
ul.simple {
|
137
143
|
list-style-type: none;
|
138
144
|
}
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cbeta
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.1.
|
4
|
+
version: 2.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ray Chou
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-12-
|
11
|
+
date: 2015-12-28 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Ruby gem for use Chinese Buddhist Text resources made by CBETA (http://www.cbeta.org).
|
14
14
|
email: zhoubx@gmail.com
|