cbeta 2.2.30 → 2.3.0

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: c04e8e940a47a7b5b05a9322ab598a3e8053942f
4
- data.tar.gz: ed1e3c05c7f1991e37a7e18266cd10adc7299331
3
+ metadata.gz: eb30cf1dbade7e5dd1c0fee89281cc0a0b39de7f
4
+ data.tar.gz: f21ed4d913b5e26af500265ea69a0cf2f8764de2
5
5
  SHA512:
6
- metadata.gz: 9828eac0f714977ba235e82137833fd8d6b519923e6622ab19ad3ebb080a78c8b307083eb4347c0249f892d9399155609555b4fe14c803ab1bf6d849fb5bfcd9
7
- data.tar.gz: 8675e03701df763de435cc91549caf932c140291c517d31307da06e41e6523fa84ace512c0410c529f662714e452d7190142f420ce3eaf6d1a0f5f041912fe21
6
+ metadata.gz: 1a88323e03773df0a698f9b4f17613257015775cdbcda49830139fa692497dfedc63b4b41ae347b2a3c4c798417b0fff30ea9ef9145921bb7a136daca0965d37
7
+ data.tar.gz: 8e35361c39b5bcda889c809b6da65cc5a7136c62f1c6e5a1288ff5145e60193f1a3fca8f96eb8d0fc76dcd52a464279b20b843b22c799cb849b34187fe7826a4
@@ -0,0 +1,11 @@
1
+ module CbetaShare
2
+
3
+ def to_html(e)
4
+ e.to_xml(
5
+ encoding: 'UTF-8',
6
+ save_with: Nokogiri::XML::Node::SaveOptions::AS_XML |
7
+ Nokogiri::XML::Node::SaveOptions::NO_EMPTY_TAGS
8
+ )
9
+ end
10
+
11
+ end
@@ -4,6 +4,7 @@ require 'fileutils'
4
4
  require 'json'
5
5
  require 'nokogiri'
6
6
  require 'set'
7
+ require_relative 'cbeta_share'
7
8
 
8
9
  # Convert CBETA XML P5a to HTML
9
10
  #
@@ -64,6 +65,8 @@ class CBETA::P5aToHTML
64
65
  end
65
66
 
66
67
  private
68
+
69
+ include CbetaShare
67
70
 
68
71
  def convert_all
69
72
  Dir.foreach(@xml_root) { |c|
@@ -742,14 +745,6 @@ class CBETA::P5aToHTML
742
745
  text
743
746
  end
744
747
 
745
- def to_html(e)
746
- e.to_xml(
747
- encoding: 'UTF-8',
748
- save_with: Nokogiri::XML::Node::SaveOptions::AS_XML |
749
- Nokogiri::XML::Node::SaveOptions::NO_EMPTY_TAGS
750
- )
751
- end
752
-
753
748
  def traverse(e, mode='html')
754
749
  r = ''
755
750
  e.children.each { |c|
@@ -4,6 +4,7 @@ require 'fileutils'
4
4
  require 'json'
5
5
  require 'nokogiri'
6
6
  require 'set'
7
+ require_relative 'cbeta_share'
7
8
 
8
9
  # Convert CBETA XML P5a to HTML for every edition
9
10
  #
@@ -52,6 +53,8 @@ class CBETA::P5aToHTMLForEveryEdition
52
53
 
53
54
  private
54
55
 
56
+ include CbetaShare
57
+
55
58
  def before_parse_xml(xml_fn)
56
59
  @back = { 0 => '' }
57
60
  @back_orig = { 0 => '' }
@@ -852,10 +855,6 @@ class CBETA::P5aToHTMLForEveryEdition
852
855
  puts msg
853
856
  end
854
857
 
855
- def to_html(e)
856
- e.to_xml(encoding: 'UTF-8', :save_with => Nokogiri::XML::Node::SaveOptions::AS_XML)
857
- end
858
-
859
858
  def traverse(e, mode='html')
860
859
  r = ''
861
860
  e.children.each { |c|
@@ -5,6 +5,7 @@ require 'json'
5
5
  require 'nokogiri'
6
6
  require 'set'
7
7
  require 'erb'
8
+ require_relative 'cbeta_share'
8
9
 
9
10
  # Convert CBETA XML P5a to HTML for PDF
10
11
  #
@@ -58,6 +59,8 @@ class CBETA::P5aToHTMLForPDF
58
59
 
59
60
  private
60
61
 
62
+ include CbetaShare
63
+
61
64
  def before_convert_work(work_id)
62
65
  @nav_doc = Nokogiri::XML('<ul></ul>')
63
66
  @nav_doc.remove_namespaces!()
@@ -729,10 +732,6 @@ class CBETA::P5aToHTMLForPDF
729
732
  end
730
733
  end
731
734
 
732
- def to_html(e)
733
- e.to_xml(encoding: 'UTF-8', :save_with => Nokogiri::XML::Node::SaveOptions::AS_XML)
734
- end
735
-
736
735
  def traverse(e, mode='html')
737
736
  r = ''
738
737
  e.children.each { |c|
@@ -3,6 +3,7 @@ require 'fileutils'
3
3
  require 'json'
4
4
  require 'nokogiri'
5
5
  require 'set'
6
+ require_relative 'cbeta_share'
6
7
 
7
8
  # Convert CBETA XML P5a to simple HTML
8
9
  #
@@ -69,6 +70,8 @@ class CBETA::P5aToSimpleHTML
69
70
  end
70
71
 
71
72
  private
73
+
74
+ include CbetaShare
72
75
 
73
76
  def convert_all
74
77
  Dir.entries(@xml_root).sort.each { |c|
@@ -145,7 +148,7 @@ class CBETA::P5aToSimpleHTML
145
148
 
146
149
  def handle_lb(e)
147
150
  @lb = e['n']
148
- r = "<a id='lb#{@lb}'/>"
151
+ r = %(<a id="lb#{@lb}"></a>)
149
152
  unless @next_line_buf.empty?
150
153
  r += @next_line_buf + "\n"
151
154
  @next_line_buf = ''
@@ -169,7 +172,7 @@ class CBETA::P5aToSimpleHTML
169
172
  if e['unit'] == 'juan'
170
173
  @juan = e['n'].to_i
171
174
  r += "<juan #{@juan}>"
172
- r += "<a id='lb#{@lb}'/>" unless @lb.nil?
175
+ r += %(<a id="lb#{@lb}"></a>) unless @lb.nil?
173
176
  end
174
177
  r
175
178
  end
@@ -410,7 +413,4 @@ class CBETA::P5aToSimpleHTML
410
413
  File.write(fn, text)
411
414
  end
412
415
 
413
- def to_html(e)
414
- e.to_xml(encoding: 'UTF-8', :save_with => Nokogiri::XML::Node::SaveOptions::AS_XML)
415
- end
416
416
  end
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.30
4
+ version: 2.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ray Chou
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-02-07 00:00:00.000000000 Z
11
+ date: 2017-02-08 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
@@ -18,6 +18,7 @@ extra_rdoc_files: []
18
18
  files:
19
19
  - lib/cbeta.rb
20
20
  - lib/cbeta/bm_to_text.rb
21
+ - lib/cbeta/cbeta_share.rb
21
22
  - lib/cbeta/char_count.rb
22
23
  - lib/cbeta/char_freq.rb
23
24
  - lib/cbeta/gaiji.rb