cbeta 0.4.1 → 0.4.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.rb +12 -0
- data/lib/cbeta/p5a_to_html.rb +9 -7
- data/lib/cbeta/p5a_to_simple_html.rb +9 -4
- data/lib/cbeta/p5a_to_text.rb +3 -5
- 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: 1c29d0e70255be20d828cecb8f3feff8f0d4b448
|
4
|
+
data.tar.gz: f90911d3955acb1f491e1e7c61fd1797617aa8f2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2a545c0cb3fdc26d8b79a79172112b967f225aadaf03afe41b4117acfc44a67f7626cb1f07cb3262d0b6b4041978af9f87f15f9b6d4b574472f5da6c81153d21
|
7
|
+
data.tar.gz: fcad67ccefa4b4250a6d236671373cc4586f48d4da49b60bfddb659ae1fc0246e613f31e580ad6958b0cd0a1a358b68f9b37f34764a95efbe43f94e8711e8b7e
|
data/lib/cbeta.rb
CHANGED
@@ -20,6 +20,18 @@ class CBETA
|
|
20
20
|
}
|
21
21
|
nil
|
22
22
|
end
|
23
|
+
|
24
|
+
# 傳入 蘭札體 缺字碼,傳回 Unicode PUA 字元
|
25
|
+
def self.ranjana_pua(gid)
|
26
|
+
i = 0x10000 + gid[-4..-1].hex
|
27
|
+
[i].pack("U")
|
28
|
+
end
|
29
|
+
|
30
|
+
# 傳入 悉曇字 缺字碼,傳回 Unicode PUA 字元
|
31
|
+
def self.siddham_pua(gid)
|
32
|
+
i = 0xFA000 + gid[-4..-1].hex
|
33
|
+
[i].pack("U")
|
34
|
+
end
|
23
35
|
|
24
36
|
# 載入藏經資料
|
25
37
|
def initialize()
|
data/lib/cbeta/p5a_to_html.rb
CHANGED
@@ -27,9 +27,9 @@ class CBETA::P5aToHTML
|
|
27
27
|
@gaijis = CBETA::Gaiji.new
|
28
28
|
|
29
29
|
# 載入 unicode 1.1 字集列表
|
30
|
-
fn = File.join(File.dirname(__FILE__), 'unicode-1.1.json')
|
31
|
-
json = File.read(fn)
|
32
|
-
|
30
|
+
#fn = File.join(File.dirname(__FILE__), 'unicode-1.1.json')
|
31
|
+
#json = File.read(fn)
|
32
|
+
#@unicode1 = JSON.parse(json)
|
33
33
|
end
|
34
34
|
|
35
35
|
# 將 CBETA XML P5a 轉為 HTML
|
@@ -175,7 +175,7 @@ class CBETA::P5aToHTML
|
|
175
175
|
|
176
176
|
def handle_g(e, mode)
|
177
177
|
# if 有 <mapping type="unicode">
|
178
|
-
# if
|
178
|
+
# if 不在 Unicode Extension C, D, E 範圍裡
|
179
179
|
# 直接採用
|
180
180
|
# else
|
181
181
|
# 預設呈現 unicode, 但仍包缺字資訊,供點選開 popup
|
@@ -218,10 +218,12 @@ class CBETA::P5aToHTML
|
|
218
218
|
|
219
219
|
default = ''
|
220
220
|
if g.has_key?('unicode')
|
221
|
-
if @unicode1.include?(g['unicode'])
|
222
|
-
|
223
|
-
|
221
|
+
#if @unicode1.include?(g['unicode'])
|
222
|
+
# 如果在 unicode ext-C, ext-D, ext-E 範圍內
|
223
|
+
if (0x2A700..0x2CEAF).include? g['unicode'].hex
|
224
224
|
default = g['unicode-char']
|
225
|
+
else
|
226
|
+
return g['unicode-char'] # 直接採用 unicode
|
225
227
|
end
|
226
228
|
end
|
227
229
|
|
@@ -98,7 +98,9 @@ class CBETA::P5aToSimpleHTML
|
|
98
98
|
end
|
99
99
|
|
100
100
|
def handle_g(e)
|
101
|
-
# if
|
101
|
+
# if 悉曇字、蘭札體
|
102
|
+
# 使用 Unicode PUA
|
103
|
+
# else if 有 <mapping type="unicode">
|
102
104
|
# 直接採用
|
103
105
|
# else if 有 <mapping type="normal_unicode">
|
104
106
|
# 採用 normal_unicode
|
@@ -111,18 +113,21 @@ class CBETA::P5aToSimpleHTML
|
|
111
113
|
abort "Line:#{__LINE__} 無缺字資料:#{gid}" if g.nil?
|
112
114
|
zzs = g['zzs']
|
113
115
|
|
114
|
-
if gid.start_with?('SD')
|
116
|
+
if gid.start_with?('SD') # 悉曇字
|
115
117
|
case gid
|
116
118
|
when 'SD-E35A'
|
117
119
|
return '('
|
118
120
|
when 'SD-E35B'
|
119
121
|
return ')'
|
120
122
|
else
|
121
|
-
return
|
123
|
+
return CBETA.siddham_pua(gid)
|
122
124
|
end
|
123
125
|
end
|
124
126
|
|
125
|
-
|
127
|
+
if gid.start_with? 'RJ' # 蘭札體
|
128
|
+
return CBETA.ranjana_pua(gid)
|
129
|
+
end
|
130
|
+
|
126
131
|
return g['unicode-char'] if g.has_key?('unicode')
|
127
132
|
return g['normal_unicode'] if g.has_key?('normal_unicode')
|
128
133
|
return g['normal'] if g.has_key?('normal')
|
data/lib/cbeta/p5a_to_text.rb
CHANGED
@@ -191,14 +191,12 @@ class CBETA::P5aToText
|
|
191
191
|
when 'SD-E35B'
|
192
192
|
return ')'
|
193
193
|
else
|
194
|
-
|
195
|
-
return [i].pack("U")
|
194
|
+
return CBETA.siddham_pua(gid)
|
196
195
|
end
|
197
196
|
end
|
198
197
|
|
199
|
-
if gid.start_with?('RJ') # 蘭札體
|
200
|
-
|
201
|
-
return [i].pack("U")
|
198
|
+
if gid.start_with?('RJ') # 蘭札體
|
199
|
+
return CBETA.ranjana_pua(gid)
|
202
200
|
end
|
203
201
|
|
204
202
|
return g['unicode-char'] if g.has_key?('unicode')
|
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: 0.4.
|
4
|
+
version: 0.4.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-08-
|
11
|
+
date: 2015-08-20 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
|