cbeta 2.2.27 → 2.2.29
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/cbeta.rb +1 -0
- data/lib/cbeta/p5a_to_html.rb +127 -127
- 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: '0867984be6dd74892f06f72ec040506624eb0f4e'
|
4
|
+
data.tar.gz: 312247c4fe0e8fb6ab8bef2a5a19929e758f1285
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5dc20c564c934a406571bc62e698c50efdfe3a4489fc7d8d09dea74e8e9248d74992674812e50a14b197c2722db005520cd41d7a5ca5cf2dba9cb5e78cc41ba4
|
7
|
+
data.tar.gz: e4f448fee9eafaf5e9bd0d08643f7dc654a66b44d2002be75a75ca4cd071da7a12671157a68744385e180566ebcfecb19dfe747943c90c8bdafbde624f5db14b
|
data/lib/cbeta.rb
CHANGED
data/lib/cbeta/p5a_to_html.rb
CHANGED
@@ -72,7 +72,7 @@ class CBETA::P5aToHTML
|
|
72
72
|
}
|
73
73
|
end
|
74
74
|
|
75
|
-
def
|
75
|
+
def e_anchor(e)
|
76
76
|
id = e['id']
|
77
77
|
if e.has_attribute?('id')
|
78
78
|
if id.start_with?('nkr_note_orig')
|
@@ -95,7 +95,7 @@ class CBETA::P5aToHTML
|
|
95
95
|
''
|
96
96
|
end
|
97
97
|
|
98
|
-
def
|
98
|
+
def e_app(e)
|
99
99
|
r = ''
|
100
100
|
if e['type'] == 'star'
|
101
101
|
c = e['corresp'][1..-1]
|
@@ -104,14 +104,14 @@ class CBETA::P5aToHTML
|
|
104
104
|
r + traverse(e)
|
105
105
|
end
|
106
106
|
|
107
|
-
def
|
107
|
+
def e_byline(e)
|
108
108
|
r = '<p class="byline">'
|
109
109
|
r += "<span class='lineInfo' line='#{@lb}'></span>"
|
110
110
|
r += traverse(e)
|
111
111
|
r + '</p>'
|
112
112
|
end
|
113
113
|
|
114
|
-
def
|
114
|
+
def e_cell(e)
|
115
115
|
doc = Nokogiri::XML::Document.new
|
116
116
|
cell = doc.create_element('div')
|
117
117
|
cell['class'] = 'bip-table-cell'
|
@@ -121,17 +121,7 @@ class CBETA::P5aToHTML
|
|
121
121
|
to_html(cell)
|
122
122
|
end
|
123
123
|
|
124
|
-
def
|
125
|
-
@series = c
|
126
|
-
puts 'handle_collection ' + c
|
127
|
-
folder = File.join(@xml_root, @series)
|
128
|
-
Dir.foreach(folder) { |vol|
|
129
|
-
next if ['.', '..', '.DS_Store'].include? vol
|
130
|
-
handle_vol(vol)
|
131
|
-
}
|
132
|
-
end
|
133
|
-
|
134
|
-
def handle_corr(e)
|
124
|
+
def e_corr(e)
|
135
125
|
r = ''
|
136
126
|
if e.parent.name == 'choice'
|
137
127
|
sic = e.parent.at_xpath('sic')
|
@@ -152,7 +142,7 @@ class CBETA::P5aToHTML
|
|
152
142
|
r + "<span class='cbeta'>%s</span>" % traverse(e)
|
153
143
|
end
|
154
144
|
|
155
|
-
def
|
145
|
+
def e_div(e)
|
156
146
|
@div_count += 1
|
157
147
|
n = @div_count
|
158
148
|
if e.has_attribute? 'type'
|
@@ -165,11 +155,11 @@ class CBETA::P5aToHTML
|
|
165
155
|
end
|
166
156
|
end
|
167
157
|
|
168
|
-
def
|
158
|
+
def e_figure(e)
|
169
159
|
"<p class='figure'>%s</p>" % traverse(e)
|
170
160
|
end
|
171
161
|
|
172
|
-
def
|
162
|
+
def e_g(e, mode)
|
173
163
|
# if 有 <mapping type="unicode">
|
174
164
|
# if 不在 Unicode Extension C, D, E 範圍裡
|
175
165
|
# 直接採用
|
@@ -244,12 +234,12 @@ class CBETA::P5aToHTML
|
|
244
234
|
"<a class='gaijiAnchor' href='##{gid}'>#{default}</a>"
|
245
235
|
end
|
246
236
|
|
247
|
-
def
|
237
|
+
def e_graphic(e)
|
248
238
|
url = File.basename(e['url'])
|
249
239
|
"<span imgsrc='#{url}' class='graphic'></span>"
|
250
240
|
end
|
251
241
|
|
252
|
-
def
|
242
|
+
def e_head(e)
|
253
243
|
r = ''
|
254
244
|
unless e['type'] == 'added'
|
255
245
|
i = @open_divs.size
|
@@ -258,15 +248,15 @@ class CBETA::P5aToHTML
|
|
258
248
|
r
|
259
249
|
end
|
260
250
|
|
261
|
-
def
|
251
|
+
def e_item(e)
|
262
252
|
"<li>%s</li>\n" % traverse(e)
|
263
253
|
end
|
264
254
|
|
265
|
-
def
|
255
|
+
def e_juan(e)
|
266
256
|
"<p class='juan'>%s</p>" % traverse(e)
|
267
257
|
end
|
268
258
|
|
269
|
-
def
|
259
|
+
def e_l(e)
|
270
260
|
if @lg_type == 'abnormal'
|
271
261
|
return traverse(e)
|
272
262
|
end
|
@@ -301,13 +291,13 @@ class CBETA::P5aToHTML
|
|
301
291
|
r
|
302
292
|
end
|
303
293
|
|
304
|
-
def
|
294
|
+
def e_lb(e)
|
305
295
|
# 卍續藏有 X 跟 R 兩種 lb, 只處理 X
|
306
296
|
return '' if e['ed'] != @series
|
307
297
|
|
308
298
|
@char_count = 1
|
309
299
|
@lb = e['n']
|
310
|
-
line_head = CBETA.
|
300
|
+
line_head = CBETA.get_linehead(@sutra_no, @lb)
|
311
301
|
|
312
302
|
r = ''
|
313
303
|
#if e.parent.name == 'lg' and $lg_row_open
|
@@ -326,7 +316,7 @@ class CBETA::P5aToHTML
|
|
326
316
|
r
|
327
317
|
end
|
328
318
|
|
329
|
-
def
|
319
|
+
def e_lem(e)
|
330
320
|
r = ''
|
331
321
|
w = e['wit']
|
332
322
|
if w.include? 'CBETA' and not w.include? @orig
|
@@ -343,7 +333,7 @@ class CBETA::P5aToHTML
|
|
343
333
|
r
|
344
334
|
end
|
345
335
|
|
346
|
-
def
|
336
|
+
def e_lg(e)
|
347
337
|
r = ''
|
348
338
|
@lg_type = e['type']
|
349
339
|
if @lg_type == 'abnormal'
|
@@ -368,11 +358,11 @@ class CBETA::P5aToHTML
|
|
368
358
|
r
|
369
359
|
end
|
370
360
|
|
371
|
-
def
|
361
|
+
def e_list(e)
|
372
362
|
"<ul>%s</ul>" % traverse(e)
|
373
363
|
end
|
374
364
|
|
375
|
-
def
|
365
|
+
def e_milestone(e)
|
376
366
|
r = ''
|
377
367
|
if e['unit'] == 'juan'
|
378
368
|
|
@@ -387,7 +377,7 @@ class CBETA::P5aToHTML
|
|
387
377
|
r
|
388
378
|
end
|
389
379
|
|
390
|
-
def
|
380
|
+
def e_mulu(e)
|
391
381
|
r = ''
|
392
382
|
if e['type'] == '品'
|
393
383
|
@pass << false
|
@@ -396,49 +386,8 @@ class CBETA::P5aToHTML
|
|
396
386
|
end
|
397
387
|
r
|
398
388
|
end
|
399
|
-
|
400
|
-
def
|
401
|
-
return '' if e.comment?
|
402
|
-
return handle_text(e, mode) if e.text?
|
403
|
-
return '' if PASS.include?(e.name)
|
404
|
-
r = case e.name
|
405
|
-
when 'anchor' then handle_anchor(e)
|
406
|
-
when 'app' then handle_app(e)
|
407
|
-
when 'byline' then handle_byline(e)
|
408
|
-
when 'cell' then handle_cell(e)
|
409
|
-
when 'corr' then handle_corr(e)
|
410
|
-
when 'div' then handle_div(e)
|
411
|
-
when 'figure' then handle_figure(e)
|
412
|
-
when 'foreign' then ''
|
413
|
-
when 'g' then handle_g(e, mode)
|
414
|
-
when 'graphic' then handle_graphic(e)
|
415
|
-
when 'head' then handle_head(e)
|
416
|
-
when 'item' then handle_item(e)
|
417
|
-
when 'juan' then handle_juan(e)
|
418
|
-
when 'l' then handle_l(e)
|
419
|
-
when 'lb' then handle_lb(e)
|
420
|
-
when 'lem' then handle_lem(e)
|
421
|
-
when 'lg' then handle_lg(e)
|
422
|
-
when 'list' then handle_list(e)
|
423
|
-
when 'mulu' then handle_mulu(e)
|
424
|
-
when 'note' then handle_note(e)
|
425
|
-
when 'milestone' then handle_milestone(e)
|
426
|
-
when 'p' then handle_p(e)
|
427
|
-
when 'rdg' then ''
|
428
|
-
when 'reg' then ''
|
429
|
-
when 'row' then handle_row(e)
|
430
|
-
when 'sic' then ''
|
431
|
-
when 'sg' then handle_sg(e)
|
432
|
-
when 't' then handle_t(e)
|
433
|
-
when 'tt' then handle_tt(e)
|
434
|
-
when 'table' then handle_table(e)
|
435
|
-
when 'unclear' then handle_unclear(e)
|
436
|
-
else traverse(e)
|
437
|
-
end
|
438
|
-
r
|
439
|
-
end
|
440
|
-
|
441
|
-
def handle_note(e)
|
389
|
+
|
390
|
+
def e_note(e)
|
442
391
|
n = e['n']
|
443
392
|
if e.has_attribute?('type')
|
444
393
|
t = e['type']
|
@@ -478,6 +427,111 @@ class CBETA::P5aToHTML
|
|
478
427
|
end
|
479
428
|
r
|
480
429
|
end
|
430
|
+
|
431
|
+
def e_p(e)
|
432
|
+
if e.key? 'type'
|
433
|
+
r = "<p class='%s'>" % e['type']
|
434
|
+
else
|
435
|
+
r = '<p>'
|
436
|
+
end
|
437
|
+
r += "<span class='lineInfo' line='#{@lb}'></span>"
|
438
|
+
r += traverse(e)
|
439
|
+
r + '</p>'
|
440
|
+
end
|
441
|
+
|
442
|
+
def e_row(e)
|
443
|
+
"<div class='bip-table-row'>" + traverse(e) + "</div>"
|
444
|
+
end
|
445
|
+
|
446
|
+
def e_sg(e)
|
447
|
+
'(' + traverse(e) + ')'
|
448
|
+
end
|
449
|
+
|
450
|
+
def e_t(e)
|
451
|
+
if e.has_attribute? 'place'
|
452
|
+
return '' if e['place'].include? 'foot'
|
453
|
+
end
|
454
|
+
r = traverse(e)
|
455
|
+
|
456
|
+
# <tt type="app"> 不是 悉漢雙行對照
|
457
|
+
return r if @tt_type == 'app'
|
458
|
+
|
459
|
+
# 處理雙行對照
|
460
|
+
i = e.xpath('../t').index(e)
|
461
|
+
case i
|
462
|
+
when 0
|
463
|
+
return r + ' '
|
464
|
+
when 1
|
465
|
+
@next_line_buf += r + ' '
|
466
|
+
return ''
|
467
|
+
else
|
468
|
+
return r
|
469
|
+
end
|
470
|
+
end
|
471
|
+
|
472
|
+
def e_tt(e)
|
473
|
+
@tt_type = e['type']
|
474
|
+
traverse(e)
|
475
|
+
end
|
476
|
+
|
477
|
+
def e_table(e)
|
478
|
+
"<div class='bip-table'>" + traverse(e) + "</div>"
|
479
|
+
end
|
480
|
+
|
481
|
+
def e_unclear(e)
|
482
|
+
'▆'
|
483
|
+
end
|
484
|
+
|
485
|
+
def handle_collection(c)
|
486
|
+
@series = c
|
487
|
+
puts 'handle_collection ' + c
|
488
|
+
folder = File.join(@xml_root, @series)
|
489
|
+
Dir.foreach(folder) { |vol|
|
490
|
+
next if ['.', '..', '.DS_Store'].include? vol
|
491
|
+
handle_vol(vol)
|
492
|
+
}
|
493
|
+
end
|
494
|
+
|
495
|
+
def handle_node(e, mode)
|
496
|
+
return '' if e.comment?
|
497
|
+
return handle_text(e, mode) if e.text?
|
498
|
+
return '' if PASS.include?(e.name)
|
499
|
+
r = case e.name
|
500
|
+
when 'anchor' then e_anchor(e)
|
501
|
+
when 'app' then e_app(e)
|
502
|
+
when 'byline' then e_byline(e)
|
503
|
+
when 'cell' then e_cell(e)
|
504
|
+
when 'corr' then e_corr(e)
|
505
|
+
when 'div' then e_div(e)
|
506
|
+
when 'figure' then e_figure(e)
|
507
|
+
when 'foreign' then ''
|
508
|
+
when 'g' then e_g(e, mode)
|
509
|
+
when 'graphic' then e_graphic(e)
|
510
|
+
when 'head' then e_head(e)
|
511
|
+
when 'item' then e_item(e)
|
512
|
+
when 'juan' then e_juan(e)
|
513
|
+
when 'l' then e_l(e)
|
514
|
+
when 'lb' then e_lb(e)
|
515
|
+
when 'lem' then e_lem(e)
|
516
|
+
when 'lg' then e_lg(e)
|
517
|
+
when 'list' then e_list(e)
|
518
|
+
when 'mulu' then e_mulu(e)
|
519
|
+
when 'note' then e_note(e)
|
520
|
+
when 'milestone' then e_milestone(e)
|
521
|
+
when 'p' then e_p(e)
|
522
|
+
when 'rdg' then ''
|
523
|
+
when 'reg' then ''
|
524
|
+
when 'row' then e_row(e)
|
525
|
+
when 'sic' then ''
|
526
|
+
when 'sg' then e_sg(e)
|
527
|
+
when 't' then e_t(e)
|
528
|
+
when 'tt' then e_tt(e)
|
529
|
+
when 'table' then e_table(e)
|
530
|
+
when 'unclear' then e_unclear(e)
|
531
|
+
else traverse(e)
|
532
|
+
end
|
533
|
+
r
|
534
|
+
end
|
481
535
|
|
482
536
|
def handle_note_orig(e, anchor_type=nil)
|
483
537
|
n = e['n']
|
@@ -501,25 +555,6 @@ class CBETA::P5aToHTML
|
|
501
555
|
return "<a class='noteAnchor #{c}' href='#n#{n}'#{label}></a>"
|
502
556
|
end
|
503
557
|
|
504
|
-
def handle_p(e)
|
505
|
-
if e.key? 'type'
|
506
|
-
r = "<p class='%s'>" % e['type']
|
507
|
-
else
|
508
|
-
r = '<p>'
|
509
|
-
end
|
510
|
-
r += "<span class='lineInfo' line='#{@lb}'></span>"
|
511
|
-
r += traverse(e)
|
512
|
-
r + '</p>'
|
513
|
-
end
|
514
|
-
|
515
|
-
def handle_row(e)
|
516
|
-
"<div class='bip-table-row'>" + traverse(e) + "</div>"
|
517
|
-
end
|
518
|
-
|
519
|
-
def handle_sg(e)
|
520
|
-
'(' + traverse(e) + ')'
|
521
|
-
end
|
522
|
-
|
523
558
|
def handle_sutra(xml_fn)
|
524
559
|
puts "convert sutra #{xml_fn}"
|
525
560
|
@back = { 0 => '' }
|
@@ -558,37 +593,6 @@ class CBETA::P5aToHTML
|
|
558
593
|
}
|
559
594
|
end
|
560
595
|
|
561
|
-
def handle_t(e)
|
562
|
-
if e.has_attribute? 'place'
|
563
|
-
return '' if e['place'].include? 'foot'
|
564
|
-
end
|
565
|
-
r = traverse(e)
|
566
|
-
|
567
|
-
# <tt type="app"> 不是 悉漢雙行對照
|
568
|
-
return r if @tt_type == 'app'
|
569
|
-
|
570
|
-
# 處理雙行對照
|
571
|
-
i = e.xpath('../t').index(e)
|
572
|
-
case i
|
573
|
-
when 0
|
574
|
-
return r + ' '
|
575
|
-
when 1
|
576
|
-
@next_line_buf += r + ' '
|
577
|
-
return ''
|
578
|
-
else
|
579
|
-
return r
|
580
|
-
end
|
581
|
-
end
|
582
|
-
|
583
|
-
def handle_tt(e)
|
584
|
-
@tt_type = e['type']
|
585
|
-
traverse(e)
|
586
|
-
end
|
587
|
-
|
588
|
-
def handle_table(e)
|
589
|
-
"<div class='bip-table'>" + traverse(e) + "</div>"
|
590
|
-
end
|
591
|
-
|
592
596
|
def handle_text(e, mode)
|
593
597
|
s = e.content().chomp
|
594
598
|
return '' if s.empty?
|
@@ -607,10 +611,6 @@ class CBETA::P5aToHTML
|
|
607
611
|
end
|
608
612
|
r
|
609
613
|
end
|
610
|
-
|
611
|
-
def handle_unclear(e)
|
612
|
-
'▆'
|
613
|
-
end
|
614
614
|
|
615
615
|
def handle_vol(vol)
|
616
616
|
puts "convert volumn: #{vol}"
|
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.2.
|
4
|
+
version: 2.2.29
|
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-12-
|
11
|
+
date: 2016-12-15 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
|