cbeta 2.1.3 → 2.1.4

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6a715f9ac4b0f18f5625856482341f62bdff33a4
4
- data.tar.gz: 154ad81979345e05396abeea9469e9af236223f7
3
+ metadata.gz: c06aef5934c9e95c726d91bff646fa7716b27b4f
4
+ data.tar.gz: 4478e65a67161fed6c6289c27071f3aa19ab2430
5
5
  SHA512:
6
- metadata.gz: 3a89be3fc162f65bd4d370ef99005cefbb2baf30d7de1da047226167d711701f0d6c0c7d268a6b8a97dc79621ad9508f07491159ca188c8f1c56d998ef53bf11
7
- data.tar.gz: 360a1f08ae300207ca0181bc459bccc9aac3f4b2f926c4a3f2f3d3cc1a2adc625eb14a7ce2a9c9a73825f77f5936757f0233da405d955139aacb32acc9404731
6
+ metadata.gz: 7754738c2f6f798cf2048952a3bc51d0caa5852f6f078584d098b36c61b1abf0bf9efa7d3c435487ac0b1049a6e4779c0b992772f0a3aa033b1cdda2548d4e0c
7
+ data.tar.gz: 4fd93f3203d0b49bc7f18efbb48227bc724b8e3f0c670ee804eb4caf6e3192b0edb6061ebe444f2a56f8dd2da06f51afa35cc1bff72285bfbce1f5cea3c8c1b6
data/lib/cbeta.rb CHANGED
@@ -121,7 +121,6 @@ require 'cbeta/bm_to_text'
121
121
  require 'cbeta/char_count'
122
122
  require 'cbeta/char_freq'
123
123
  require 'cbeta/html_to_pdf'
124
- require 'cbeta/p5a_parser'
125
124
  require 'cbeta/p5a_to_html'
126
125
  require 'cbeta/p5a_to_html_for_every_edition'
127
126
  require 'cbeta/p5a_to_html_for_pdf'
@@ -308,6 +308,7 @@ class CBETA::P5aToSimpleHTML
308
308
 
309
309
  @orig = @cbeta.get_canon_abbr(vol[0])
310
310
  abort "未處理底本" if @orig.nil?
311
+ @orig_short = @orig.sub(/^【(.*)】$/, '\1')
311
312
 
312
313
  @vol = vol
313
314
  @series = vol[0]
@@ -378,6 +379,9 @@ class CBETA::P5aToSimpleHTML
378
379
  text += "<body>" + to_html(frag) + "</body></html>"
379
380
 
380
381
  fn = ed.sub(/^【(.*?)】$/, '\1')
382
+ if fn != 'CBETA' and fn != @orig_short
383
+ fn = @orig_short + '→' + fn
384
+ end
381
385
  fn = "#{fn}.html"
382
386
  output_path = File.join(folder, fn)
383
387
  File.write(output_path, text)
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.3
4
+ version: 2.1.4
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-28 00:00:00.000000000 Z
11
+ date: 2016-01-14 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
@@ -23,7 +23,6 @@ files:
23
23
  - lib/cbeta/gaiji.rb
24
24
  - lib/cbeta/html_to_pdf.rb
25
25
  - lib/cbeta/html_to_text.rb
26
- - lib/cbeta/p5a_parser.rb
27
26
  - lib/cbeta/p5a_to_html.rb
28
27
  - lib/cbeta/p5a_to_html_for_every_edition.rb
29
28
  - lib/cbeta/p5a_to_html_for_pdf.rb
@@ -1,91 +0,0 @@
1
- class CBETA::P5aParser
2
-
3
- # @example
4
- #
5
- # def handle_notes(e)
6
- # ...
7
- # end
8
- #
9
- # def traverse(e)
10
- # e.children.each { |c| handle_nodes(c) }
11
- # end
12
- #
13
- # xml_string = File.read(xml_file_name)
14
- # parser = CBETA::P5aParser.new(xml_string, :traverse)
15
- #
16
- def initialize(xml_string, children_handler)
17
- @doc = Nokogiri::XML(s)
18
- @doc.remove_namespaces!()
19
- @children_handler = children_handler
20
- end
21
-
22
- # @param e [Nokogiri::XML::Element]
23
- # @param mode [String] 'html' or 'text', default value: 'html'
24
- # @return [Hash]
25
- # 回傳
26
- # * :content [String] 要放在本文中的文字, 如果 mode=='html', 那麼本文文字會包含 footnote anchor
27
- # * :footnote_text [String] 要放在 footnote 的文字
28
- # * :footnote_resp [String]
29
- # * 'orig': 表示這個註解是底本的註
30
- # * 'CBETA': 表示這個註解是 CBETA 修訂過的註
31
- def handle_note(e, mode='html')
32
- r = {
33
- content: '',
34
- footnote_resp: nil,
35
- footnote_text: nil
36
- }
37
- n = e['n']
38
- if e.has_attribute?('type')
39
- t = e['type']
40
- case t
41
- when 'equivalent' then return r
42
- when 'orig' then return handle_note_orig(e, mode)
43
- when 'orig_biao' then return handle_note_orig(e, mode, 'biao')
44
- when 'orig_ke' then return handle_note_orig(e, mode, 'ke')
45
- when 'mod'
46
- r[:footnote_resp] = 'CBETA'
47
- r[:footnote_content] = @children_handler.call(e)
48
- if mode == 'html'
49
- r[:content] = "<a class='noteAnchor' href='#n#{n}'></a>"
50
- end
51
- return r
52
- when 'rest' then return r
53
- else
54
- return r if t.start_with?('cf')
55
- end
56
- end
57
-
58
- if e.has_attribute?('resp')
59
- return r if e['resp'].start_with? 'CBETA'
60
- end
61
-
62
- s = @children_handler.call(e)
63
- r[:content] = s
64
- if e.has_attribute?('place') && e['place']=='inline'
65
- if mode == 'html'
66
- r[:content] = "<span class='doube-line-note'>#{s}</span>"
67
- end
68
- end
69
- r
70
- end
71
-
72
- private
73
-
74
- def handle_note_orig(e, mode, anchor_type=nil)
75
- r = { footnote_resp: 'orig' }
76
- n = e['n']
77
- r[:footnote_content] = @children_handler.call(e)
78
-
79
- if mode == 'html'
80
- label = case anchor_type
81
- when 'biao' then " data-label='標#{n[-2..-1]}'"
82
- when 'ke' then " data-label='科#{n[-2..-1]}'"
83
- else ''
84
- end
85
- r[:content] = "<a class='noteAnchor' href='#n#{n}'#{label}></a>"
86
- end
87
-
88
- r
89
- end
90
-
91
- end