cbeta 2.1.6 → 2.1.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/cbeta/p5a_to_html_for_every_edition.rb +9 -3
- data/lib/cbeta/p5a_to_text.rb +27 -13
- 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: 9eb8fa0e6bc0a0b9a049fc6a9c24ce1b57594575
|
4
|
+
data.tar.gz: 3dd5c4dfb50fb78d0290d8dd558710ede86df997
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4eab2c2ddea6eaad8ef585ca61e53b96d47ef39f46ae074d2b0a4a6aeb8e4d8958c4a6f11a5a6e443a9f82507a09e0583f6e597c67969bb18262fb2674e5a7ad
|
7
|
+
data.tar.gz: d4379cf58742674b48d866ef0907c32c773c0fab09606cbd3e88f68aaab5622e69e40fab3d7f7e4d8a0489c0a13d36ebb1982920b8c9998b25b191fd6a28b94b
|
@@ -179,7 +179,7 @@ class CBETA::P5aToHTMLForEveryEdition
|
|
179
179
|
@notes_dila[@juan] << "<span class='footnote dila' id='dila_note#{n}'>#{note}</span>"
|
180
180
|
end
|
181
181
|
end
|
182
|
-
r + "<r w='【CBETA】' l='#{@lb}' w='#{@char_count}'>%s</r>" % traverse(e)
|
182
|
+
r + "<r w='【CBETA】' l='#{@lb}' w='#{@char_count}'><span class='cbeta'>%s</span></r>" % traverse(e)
|
183
183
|
end
|
184
184
|
|
185
185
|
def handle_div(e)
|
@@ -500,7 +500,7 @@ class CBETA::P5aToHTMLForEveryEdition
|
|
500
500
|
@pass.pop
|
501
501
|
#@back[@juan] = "<span class='footnote_cb' id='n#{n}'>#{s}</span>\n"
|
502
502
|
@notes_mod[@juan][n] = s
|
503
|
-
return "<r w='【CBETA】'><a class='noteAnchor' href='#n#{n}'></a></r>"
|
503
|
+
return "<r w='【CBETA】'><a class='noteAnchor cb' href='#n#{n}'></a></r>"
|
504
504
|
when 'rest'
|
505
505
|
return ''
|
506
506
|
else
|
@@ -527,13 +527,18 @@ class CBETA::P5aToHTMLForEveryEdition
|
|
527
527
|
@pass.pop
|
528
528
|
@notes_orig[@juan][n] = s
|
529
529
|
@notes_mod[@juan][n] = s
|
530
|
+
|
531
|
+
c = @series
|
532
|
+
|
533
|
+
# 如果 CBETA 沒有修訂,就跟底本的註一樣
|
534
|
+
c += " cb" unless @mod_notes.include? n
|
530
535
|
|
531
536
|
label = case anchor_type
|
532
537
|
when 'biao' then " data-label='標#{n[-2..-1]}'"
|
533
538
|
when 'ke' then " data-label='科#{n[-2..-1]}'"
|
534
539
|
else ''
|
535
540
|
end
|
536
|
-
s = "<a class='noteAnchor' href='#n#{n}'#{label}></a>"
|
541
|
+
s = "<a class='noteAnchor #{c}' href='#n#{n}'#{label}></a>"
|
537
542
|
r = "<r w='#{@orig}'>#{s}</r>"
|
538
543
|
|
539
544
|
unless @mod_notes.include? n
|
@@ -879,6 +884,7 @@ class CBETA::P5aToHTMLForEveryEdition
|
|
879
884
|
#{copyright}
|
880
885
|
</body></html>
|
881
886
|
eos
|
887
|
+
puts "write #{output_path}"
|
882
888
|
File.write(output_path, text)
|
883
889
|
end
|
884
890
|
end
|
data/lib/cbeta/p5a_to_text.rb
CHANGED
@@ -128,6 +128,16 @@ class CBETA::P5aToText
|
|
128
128
|
end
|
129
129
|
end
|
130
130
|
|
131
|
+
# 取得所有對校版本
|
132
|
+
def get_editions(doc)
|
133
|
+
r = Set.new [@orig, "【CBETA】"] # 至少有底本及 CBETA 兩個版本
|
134
|
+
doc.xpath('//lem|//rdg').each do |e|
|
135
|
+
w = e['wit'].scan(/【.*?】/)
|
136
|
+
r.merge w
|
137
|
+
end
|
138
|
+
r
|
139
|
+
end
|
140
|
+
|
131
141
|
def handle_anchor(e)
|
132
142
|
if e.has_attribute?('type')
|
133
143
|
if e['type'] == 'circle'
|
@@ -274,12 +284,16 @@ class CBETA::P5aToText
|
|
274
284
|
end
|
275
285
|
|
276
286
|
def handle_lem(e)
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
287
|
+
# 沒有 rdg 的版本,用字同 lem
|
288
|
+
editions = Set.new @editions
|
289
|
+
e.xpath('./following-sibling::rdg').each do |rdg|
|
290
|
+
rdg['wit'].scan(/【.*?】/).each do |w|
|
291
|
+
editions.delete w
|
292
|
+
end
|
293
|
+
end
|
294
|
+
|
295
|
+
w = editions.to_a.join(' ')
|
296
|
+
"<r w='#{w}'>%s</r>" % traverse(e)
|
283
297
|
end
|
284
298
|
|
285
299
|
def handle_lg(e)
|
@@ -363,10 +377,7 @@ class CBETA::P5aToText
|
|
363
377
|
end
|
364
378
|
|
365
379
|
def handle_rdg(e)
|
366
|
-
r = traverse(e)
|
367
|
-
w = e['wit'].scan(/【.*?】/)
|
368
|
-
@editions.merge w
|
369
|
-
"<r w='#{e['wit']}'>#{r}</r>"
|
380
|
+
"<r w='#{e['wit']}'>%s</r>" % traverse(e)
|
370
381
|
end
|
371
382
|
|
372
383
|
def handle_row(e)
|
@@ -385,7 +396,7 @@ class CBETA::P5aToText
|
|
385
396
|
puts "convert sutra #{xml_fn}"
|
386
397
|
@dila_note = 0
|
387
398
|
@div_count = 0
|
388
|
-
|
399
|
+
#@editions = Set.new [@orig, "【CBETA】"] # 至少有底本跟CBETA兩種版本
|
389
400
|
@in_l = false
|
390
401
|
@juan = 0
|
391
402
|
@lg_row_open = false
|
@@ -510,6 +521,8 @@ class CBETA::P5aToText
|
|
510
521
|
def parse_xml(xml_fn)
|
511
522
|
doc = open_xml(xml_fn)
|
512
523
|
root = doc.root()
|
524
|
+
|
525
|
+
@editions = get_editions(doc)
|
513
526
|
|
514
527
|
body = root.xpath("text/body")[0]
|
515
528
|
traverse(body)
|
@@ -531,9 +544,10 @@ class CBETA::P5aToText
|
|
531
544
|
@editions.each do |ed|
|
532
545
|
frag = Nokogiri::XML.fragment(txt)
|
533
546
|
frag.search("r").each do |node|
|
534
|
-
if node['w']
|
535
|
-
node.
|
547
|
+
if node['w'].include? ed
|
548
|
+
node.add_previous_sibling node.inner_html
|
536
549
|
end
|
550
|
+
node.remove
|
537
551
|
end
|
538
552
|
text = frag.content
|
539
553
|
text = appify(text) if @settings[:format] == 'app'
|
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.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ray Chou
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-01-
|
11
|
+
date: 2016-01-26 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
|