ydocx 1.0.2 → 1.0.3

Sign up to get free protection for your applications and to get access to all the features.
data/History.txt CHANGED
@@ -1,3 +1,7 @@
1
+ === 1.0.3 / 01.05.2012
2
+
3
+ * Fixed blank tag without fachinfo format
4
+
1
5
  === 1.0.2 / 01.05.2012
2
6
 
3
7
  * Improved tab handling at line head
@@ -57,7 +57,11 @@ module Docx2html
57
57
  nil
58
58
  end
59
59
  def build_tag(tag, content, attributes)
60
- return '' if content.empty?
60
+ if tag == :br
61
+ return "<br/>"
62
+ elsif content.nil? or content.empty?
63
+ return ''
64
+ end
61
65
  _content = ''
62
66
  if content.is_a? Array
63
67
  content.each do |c|
@@ -80,7 +84,7 @@ module Docx2html
80
84
  _attributes << " #{k.to_s}=#{v.to_s}"
81
85
  end
82
86
  end
83
- "<#{_tag}#{_attributes}>#{_content}</#{_tag}>"
87
+ return "<#{_tag}#{_attributes}>#{_content}</#{_tag}>"
84
88
  end
85
89
  def style
86
90
  style = <<-CSS
@@ -146,28 +146,40 @@ module Docx2html
146
146
  # pending
147
147
  end
148
148
  def parse_paragraph(node)
149
- paragraph = tag :p
149
+ content = []
150
150
  line_head = true
151
151
  pos = 0
152
152
  node.xpath('w:r').each do |r|
153
153
  unless r.xpath('w:t').empty?
154
- paragraph[:content] << parse_text(r)
154
+ content << parse_text(r)
155
155
  pos += 1
156
156
  else
157
157
  unless r.xpath('w:tab').empty?
158
- if paragraph[:content].last != @space and pos != 0 # ignore tab at line head
159
- paragraph[:content] << optional_escape('')
158
+ if content.last != @space and pos != 0 # ignore tab at line head
159
+ content << optional_escape('')
160
160
  pos += 1
161
161
  end
162
162
  end
163
163
  unless r.xpath('w:sym').empty?
164
164
  code = r.xpath('w:sym').first['char'].downcase # w:char
165
- paragraph[:content] << optional_replace(code)
165
+ content << optional_replace(code)
166
166
  pos += 1
167
167
  end
168
168
  end
169
169
  end
170
- paragraph
170
+ content.compact!
171
+ unless content.empty?
172
+ paragraph = content.select do |c|
173
+ c.is_a?(Hash) and c[:tag].to_s =~ /^h[1-9]/u
174
+ end.empty?
175
+ if paragraph
176
+ tag :p, content
177
+ else
178
+ content.first
179
+ end
180
+ else
181
+ {}
182
+ end
171
183
  end
172
184
  def parse_table(node)
173
185
  table = tag :table
data/lib/fachinfo.rb CHANGED
@@ -20,26 +20,26 @@ module Docx2html
20
20
  # TODO
21
21
  # Franzoesisch
22
22
  chapters = {
23
- 'Dos./Anw.' => /^Dosierung\s*(\/|und)\s*Anwendung/u, # 5
24
- 'Eigensch.' => /^Eigenschaften\s*\/\s*Wirkungen($|\s*\(\s*(ATC\-Code|Wirkungsmechanismus|Pharmakodyamik|Klinische\s+Wirksamkeit)\s*\)\s*$)|^Propri.t.s/iu, # 13
25
- 'Galen.Form' => /^Galenische\s+Form\s*(und|\/)\s*Wirkstoffmenge\s+pro\s+Einheit$|^Forme\s*gal.nique/iu, # 3
26
- 'Ind./Anw.mögl.' => /^Indikationen(\s+|\s*(\/|und)\s*)Anwendungsm&ouml;glichkeiten$|^Indications/u, # 4
27
- 'Interakt.' => /^Interaktionen$|^Interactions/u, # 8
28
- 'Kontraind.' => /^Kontraindikationen($|\s*\(\s*absolute\s+Kontraindikationen\s*\)$)/u, # 6
29
- 'Name' => /^Name\s+des\s+Pr&auml;parates$/, # 1
30
- 'Packungen' => /^Packungen($|\s*\(\s*mit\s+Angabe\s+der\s+Abgabekategorie\s*\)$)/u, # 18
31
- 'Präklin.' => /^Pr&auml;klinische\s+Daten$/u, # 15
32
- 'Pharm.kinetik' => /^Pharmakokinetik($|\s*\((Absorption,\s*Distribution,\s*Metabolisms,\s*Elimination\s|Kinetik\s+spezieller\s+Patientengruppen)*\)$)|^Pharmacocin.tique?/iu, # 14
33
- 'Sonstige H.' => /^Sonstige\s*Hinweise($|\s*\(\s*(Inkompatibilit&auml;ten|Beeinflussung\s*diagnostischer\s*Methoden|Haltbarkeit|Besondere\s*Lagerungshinweise|Hinweise\s+f&uuml;r\s+die\s+Handhabung)\s*\)$)|^Remarques/u, # 16
34
- 'Schwangerschaft' => /^Schwangerschaft(,\s*|\s*\/\s*|\s+und\s+)Stillzeit$/u, # 9
35
- 'Stand d. Info.' => /^Stand\s+der\s+Information$|^Mise\s+.\s+jour$/iu, # 20
36
- 'Unerw.Wirkungen' => /^Unerw&uuml;nschte\s+Wirkungen$/u, # 11
37
- 'Überdos.' => /^&Uuml;berdosierung$|^Surdosage$/u, # 12
38
- 'Warn.hinw.' => /^Warnhinweise\s+und\s+Vorsichtsmassnahmen($|\s*\/\s*(relative\s+Kontraindikationen|Warnhinweise\s*und\s*Vorsichtsmassnahmen)$)/u, # 7
39
- 'Fahrtücht.' => /^Wirkung\s+auf\s+die\s+Fahrt&uuml;chtigkeit\s+und\s+auf\s+das\s+Bedienen\s+von\s+Maschinen$/u, # 10
40
- 'Swissmedic-Nr.' => /^Zulassungsnummer($|\s*\(\s*Swissmedic\s*\)$)/u, # 17
41
- 'Reg.Inhaber' => /^Zulassungsinhaberin($|\s*\(\s*Firma\s+und\s+Sitz\s+gem&auml;ss\s*Handelsregisterauszug\s*\))/u, # 19
42
- 'Zusammens.' => /^Zusammensetzung($|\s*\/\s*(Wirkstoffe|Hilsstoffe)$)/u, # 2
23
+ 'Dos./Anw.' => /^Dosierung\s*(\/|und)\s*Anwendung/u, # 5
24
+ 'Eigensch.' => /^Eigenschaften\s*\/\s*Wirkungen($|\s*\(\s*(ATC\-Code|Wirkungsmechanismus|Pharmakodyamik|Klinische\s+Wirksamkeit)\s*\)\s*$)|^Propri.t.s/iu, # 13
25
+ 'Galen.Form' => /^Galenische\s+Form\s*(und|\/)\s*Wirkstoffmenge\s+pro\s+Einheit$|^Forme\s*gal.nique/iu, # 3
26
+ 'Ind./Anw.m&ouml;gl.' => /^Indikationen(\s+|\s*(\/|und)\s*)Anwendungsm&ouml;glichkeiten$|^Indications/u, # 4
27
+ 'Interakt.' => /^Interaktionen$|^Interactions/u, # 8
28
+ 'Kontraind.' => /^Kontraindikationen($|\s*\(\s*absolute\s+Kontraindikationen\s*\)$)/u, # 6
29
+ 'Name' => /^Name\s+des\s+Pr&auml;parates$/, # 1
30
+ 'Packungen' => /^Packungen($|\s*\(\s*mit\s+Angabe\s+der\s+Abgabekategorie\s*\)$)/u, # 18
31
+ 'Pr&auml;klin.' => /^Pr&auml;klinische\s+Daten$/u, # 15
32
+ 'Pharm.kinetik' => /^Pharmakokinetik($|\s*\((Absorption,\s*Distribution,\s*Metabolisms,\s*Elimination\s|Kinetik\s+spezieller\s+Patientengruppen)*\)$)|^Pharmacocin.tique?/iu, # 14
33
+ 'Sonstige H.' => /^Sonstige\s*Hinweise($|\s*\(\s*(Inkompatibilit&auml;ten|Beeinflussung\s*diagnostischer\s*Methoden|Haltbarkeit|Besondere\s*Lagerungshinweise|Hinweise\s+f&uuml;r\s+die\s+Handhabung)\s*\)$)|^Remarques/u, # 16
34
+ 'Schwangerschaft' => /^Schwangerschaft(,\s*|\s*\/\s*|\s+und\s+)Stillzeit$/u, # 9
35
+ 'Stand d. Info.' => /^Stand\s+der\s+Information$|^Mise\s+.\s+jour$/iu, # 20
36
+ 'Unerw.Wirkungen' => /^Unerw&uuml;nschte\s+Wirkungen$/u, # 11
37
+ '&Uuml;berdos.' => /^&Uuml;berdosierung$|^Surdosage$/u, # 12
38
+ 'Warn.hinw.' => /^Warnhinweise\s+und\s+Vorsichtsmassnahmen($|\s*\/\s*(relative\s+Kontraindikationen|Warnhinweise\s*und\s*Vorsichtsmassnahmen)$)/u, # 7
39
+ 'Fahrt&uuml;cht.' => /^Wirkung\s+auf\s+die\s+Fahrt&uuml;chtigkeit\s+und\s+auf\s+das\s+Bedienen\s+von\s+Maschinen$/u, # 10
40
+ 'Swissmedic-Nr.' => /^Zulassungsnummer($|\s*\(\s*Swissmedic\s*\)$)/u, # 17
41
+ 'Reg.Inhaber' => /^Zulassungsinhaberin($|\s*\(\s*Firma\s+und\s+Sitz\s+gem&auml;ss\s*Handelsregisterauszug\s*\))/u, # 19
42
+ 'Zusammens.' => /^Zusammensetzung($|\s*\/\s*(Wirkstoffe|Hilsstoffe)$)/u, # 2
43
43
  }.each_pair do |chapter, regexp|
44
44
  if text =~ regexp
45
45
  next unless r.next.nil? # without line break
data/lib/version.rb CHANGED
@@ -2,5 +2,5 @@
2
2
  # encoding: utf-8
3
3
 
4
4
  module Docx2html
5
- VERSION = "1.0.2"
5
+ VERSION = "1.0.3"
6
6
  end
metadata CHANGED
@@ -1,49 +1,48 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: ydocx
3
- version: !ruby/object:Gem::Version
4
- version: 1.0.2
5
- prerelease:
3
+ version: !ruby/object:Gem::Version
4
+ prerelease: false
5
+ segments:
6
+ - 1
7
+ - 0
8
+ - 3
9
+ version: 1.0.3
6
10
  platform: ruby
7
- authors:
11
+ authors:
8
12
  - Yasuhiro Asaka, Zeno R.R. Davatz
9
13
  autorequire:
10
14
  bindir: bin
11
15
  cert_chain: []
12
- date: 2012-05-01 00:00:00.000000000 Z
13
- dependencies:
14
- - !ruby/object:Gem::Dependency
15
- name: rdoc
16
- requirement: &16773920 !ruby/object:Gem::Requirement
17
- none: false
18
- requirements:
19
- - - ~>
20
- - !ruby/object:Gem::Version
21
- version: '3.10'
22
- type: :development
23
- prerelease: false
24
- version_requirements: *16773920
25
- - !ruby/object:Gem::Dependency
16
+
17
+ date: 2012-05-01 00:00:00 +02:00
18
+ default_executable:
19
+ dependencies:
20
+ - !ruby/object:Gem::Dependency
26
21
  name: hoe
27
- requirement: &16773500 !ruby/object:Gem::Requirement
28
- none: false
29
- requirements:
30
- - - ~>
31
- - !ruby/object:Gem::Version
32
- version: '2.13'
33
- type: :development
34
22
  prerelease: false
35
- version_requirements: *16773500
36
- description: ''
37
- email:
23
+ requirement: &id001 !ruby/object:Gem::Requirement
24
+ requirements:
25
+ - - ">="
26
+ - !ruby/object:Gem::Version
27
+ segments:
28
+ - 2
29
+ - 9
30
+ - 1
31
+ version: 2.9.1
32
+ type: :development
33
+ version_requirements: *id001
34
+ description: ""
35
+ email:
38
36
  - yasaka@ywesee.com, zdavatz@ywesee.com
39
- executables:
37
+ executables:
40
38
  - docx2html
41
39
  extensions: []
42
- extra_rdoc_files:
40
+
41
+ extra_rdoc_files:
43
42
  - History.txt
44
43
  - Manifest.txt
45
44
  - README.txt
46
- files:
45
+ files:
47
46
  - History.txt
48
47
  - Manifest.txt
49
48
  - README.txt
@@ -57,30 +56,36 @@ files:
57
56
  - lib/docx2html/lib/docx2html/parser.rb
58
57
  - lib/fachinfo.rb
59
58
  - lib/version.rb
59
+ has_rdoc: true
60
60
  homepage: https://github.com/zdavatz/ydocx
61
61
  licenses: []
62
+
62
63
  post_install_message:
63
- rdoc_options:
64
+ rdoc_options:
64
65
  - --main
65
66
  - README.txt
66
- require_paths:
67
+ require_paths:
67
68
  - lib
68
- required_ruby_version: !ruby/object:Gem::Requirement
69
- none: false
70
- requirements:
71
- - - ! '>='
72
- - !ruby/object:Gem::Version
73
- version: '0'
74
- required_rubygems_version: !ruby/object:Gem::Requirement
75
- none: false
76
- requirements:
77
- - - ! '>='
78
- - !ruby/object:Gem::Version
79
- version: '0'
69
+ required_ruby_version: !ruby/object:Gem::Requirement
70
+ requirements:
71
+ - - ">="
72
+ - !ruby/object:Gem::Version
73
+ segments:
74
+ - 0
75
+ version: "0"
76
+ required_rubygems_version: !ruby/object:Gem::Requirement
77
+ requirements:
78
+ - - ">="
79
+ - !ruby/object:Gem::Version
80
+ segments:
81
+ - 0
82
+ version: "0"
80
83
  requirements: []
84
+
81
85
  rubyforge_project: ydocx
82
- rubygems_version: 1.8.15
86
+ rubygems_version: 1.3.6
83
87
  signing_key:
84
88
  specification_version: 3
85
- summary: ''
89
+ summary: ""
86
90
  test_files: []
91
+