cbeta 1.1.0 → 1.1.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.
- checksums.yaml +4 -4
- data/lib/cbeta/p5a_to_epub.rb +6 -3
- data/lib/cbeta/p5a_to_html_for_every_edition.rb +4 -40
- 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: 1d32d9bafbfe3851c5f515c8efc2a6911a00a48c
|
4
|
+
data.tar.gz: 65eb0b40419c9ffcd583a98971e263d17b36a85d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c58d630e10c54298c3db15e1c6d154be4b7c3bab835ac495040d2563b20e389f343a341805b472316020782105b924f560166a3dc31d3ffe9c2ffa5a8906a1fa
|
7
|
+
data.tar.gz: a27562a6385befad6767ffcb0ac933fd06b5ee504ef581b6ff1b272683adc8353298ad2f034be845644b3ddb03ec2ff0b91250f7a553cbf41562c068c3b8b119
|
data/lib/cbeta/p5a_to_epub.rb
CHANGED
@@ -92,7 +92,10 @@ class CBETA::P5aToEPUB
|
|
92
92
|
# c.convert_folder('/Users/ray/Documents/Projects/D道安/xml-p5a/DA', '/temp/cbeta-epub/DA')
|
93
93
|
def convert_folder(input_folder, output_folder)
|
94
94
|
@todo = {}
|
95
|
+
|
96
|
+
# 先檢視整個資料夾,哪些是要多檔合一
|
95
97
|
prepare_todo_list(input_folder, output_folder)
|
98
|
+
|
96
99
|
@todo.each_pair do |k, v|
|
97
100
|
convert_sutra(k, v[:xml_files], v[:epub])
|
98
101
|
end
|
@@ -133,7 +136,6 @@ class CBETA::P5aToEPUB
|
|
133
136
|
if xml_files.size > 1
|
134
137
|
@title.sub!(/^(.*)\(.*?\)$/, '\1')
|
135
138
|
@title.sub!(/^(.*?)((.*?))+$/, '\1')
|
136
|
-
puts @title
|
137
139
|
end
|
138
140
|
create_epub(out)
|
139
141
|
end
|
@@ -208,7 +210,7 @@ class CBETA::P5aToEPUB
|
|
208
210
|
end
|
209
211
|
|
210
212
|
builder.generate_epub(output_path)
|
211
|
-
puts "output: #{output_path}"
|
213
|
+
puts "output: #{output_path}\n\n"
|
212
214
|
end
|
213
215
|
|
214
216
|
def create_html_by_juan
|
@@ -512,7 +514,7 @@ eos
|
|
512
514
|
r = ''
|
513
515
|
if e['unit'] == 'juan'
|
514
516
|
r += "</div>" * @open_divs.size # 如果有 div 跨卷,要先結束, ex: T55n2154, p. 680a29, 跨 19, 20 兩卷
|
515
|
-
@juan
|
517
|
+
@juan += 1
|
516
518
|
r += "<juan #{@juan}>"
|
517
519
|
@open_divs.each { |d|
|
518
520
|
r += "<div class='#{d['type']}'>"
|
@@ -751,6 +753,7 @@ eos
|
|
751
753
|
@main_text = ''
|
752
754
|
@dila_note = 0
|
753
755
|
@toc_juan = '' # 卷目次
|
756
|
+
@juan = 0
|
754
757
|
|
755
758
|
FileUtils::mkdir_p File.join(@temp_folder, 'img')
|
756
759
|
FileUtils::mkdir_p File.join(@temp_folder, 'juans')
|
@@ -7,17 +7,17 @@ require 'set'
|
|
7
7
|
|
8
8
|
# Convert CBETA XML P5a to HTML for every edition
|
9
9
|
#
|
10
|
+
# 例如 T0001 長阿含經 有 CBETA、元、宋、聖、磧砂、unknown、大、明、麗等版本,
|
11
|
+
# 每一個版本都會輸出一個 HTML 檔,以版本為檔名。
|
12
|
+
#
|
10
13
|
# CBETA XML P5a 可由此取得: https://github.com/cbeta-git/xml-p5a
|
11
14
|
#
|
12
15
|
# 轉檔規則請參考: http://wiki.ddbc.edu.tw/pages/CBETA_XML_P5a_轉_HTML
|
13
16
|
class CBETA::P5aToHTMLForEveryEdition
|
14
17
|
# 內容不輸出的元素
|
15
18
|
PASS=['back', 'teiHeader']
|
16
|
-
|
17
|
-
# 某版用字缺的符號
|
18
|
-
MISSING = '-'
|
19
19
|
|
20
|
-
private_constant :PASS
|
20
|
+
private_constant :PASS
|
21
21
|
|
22
22
|
# @param xml_root [String] 來源 CBETA XML P5a 路徑
|
23
23
|
# @param out_root [String] 輸出 HTML 路徑
|
@@ -610,42 +610,6 @@ class CBETA::P5aToHTMLForEveryEdition
|
|
610
610
|
}
|
611
611
|
end
|
612
612
|
|
613
|
-
def lem_note_cf(e)
|
614
|
-
# ex: T32n1670A.xml, p. 703a16
|
615
|
-
# <note type="cf1">K30n1002_p0257a01-a23</note>
|
616
|
-
refs = []
|
617
|
-
e.xpath('./note').each { |n|
|
618
|
-
if n.key?('type') and n['type'].start_with? 'cf'
|
619
|
-
s = n.content
|
620
|
-
if linehead_exist_in_cbeta(s)
|
621
|
-
s = "<span class='note_cf'>#{s}</span>"
|
622
|
-
end
|
623
|
-
refs << s
|
624
|
-
end
|
625
|
-
}
|
626
|
-
if refs.empty?
|
627
|
-
''
|
628
|
-
else
|
629
|
-
'修訂依據:' + refs.join(';') + '。'
|
630
|
-
end
|
631
|
-
end
|
632
|
-
|
633
|
-
def lem_note_rdg(lem)
|
634
|
-
r = ''
|
635
|
-
app = lem.parent
|
636
|
-
@pass << false
|
637
|
-
app.xpath('rdg').each { |rdg|
|
638
|
-
if rdg['wit'].include? @orig
|
639
|
-
s = traverse(rdg, 'back')
|
640
|
-
s = MISSING if s.empty?
|
641
|
-
r += @orig + s
|
642
|
-
end
|
643
|
-
}
|
644
|
-
@pass.pop
|
645
|
-
r += '。' unless r.empty?
|
646
|
-
r
|
647
|
-
end
|
648
|
-
|
649
613
|
def linehead_exist_in_cbeta(s)
|
650
614
|
@xml_root
|
651
615
|
corpus = s[0]
|
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: 1.1.
|
4
|
+
version: 1.1.1
|
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-
|
11
|
+
date: 2015-10-02 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
|