ydocx 1.0.1 → 1.0.2
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.
- data/History.txt +8 -0
- data/README.txt +2 -2
- data/lib/docx2html/lib/docx2html/parser.rb +10 -3
- data/lib/fachinfo.rb +16 -28
- data/lib/version.rb +1 -1
- metadata +5 -5
data/History.txt
CHANGED
data/README.txt
CHANGED
@@ -8,12 +8,13 @@ require 'docx2html/lib/docx2html/html_methods'
|
|
8
8
|
module Docx2html
|
9
9
|
class Parser
|
10
10
|
include HtmlMethods
|
11
|
-
attr_accessor :indecies, :result
|
11
|
+
attr_accessor :indecies, :result, :space
|
12
12
|
def initialize(stream)
|
13
13
|
@xml = Nokogiri::XML.parse(stream)
|
14
14
|
@coder = HTMLEntities.new
|
15
15
|
@indecies = []
|
16
16
|
@result = []
|
17
|
+
@space = ' '
|
17
18
|
init
|
18
19
|
if block_given?
|
19
20
|
yield self
|
@@ -73,7 +74,7 @@ module Docx2html
|
|
73
74
|
nil # default no block element
|
74
75
|
end
|
75
76
|
def optional_escape(text)
|
76
|
-
return text =
|
77
|
+
return text = @space if text.empty?
|
77
78
|
text.force_encoding('utf-8')
|
78
79
|
# NOTE
|
79
80
|
# :named only for escape at Builder
|
@@ -146,18 +147,23 @@ module Docx2html
|
|
146
147
|
end
|
147
148
|
def parse_paragraph(node)
|
148
149
|
paragraph = tag :p
|
150
|
+
line_head = true
|
151
|
+
pos = 0
|
149
152
|
node.xpath('w:r').each do |r|
|
150
153
|
unless r.xpath('w:t').empty?
|
151
154
|
paragraph[:content] << parse_text(r)
|
155
|
+
pos += 1
|
152
156
|
else
|
153
157
|
unless r.xpath('w:tab').empty?
|
154
|
-
if paragraph[:content].last !=
|
158
|
+
if paragraph[:content].last != @space and pos != 0 # ignore tab at line head
|
155
159
|
paragraph[:content] << optional_escape('')
|
160
|
+
pos += 1
|
156
161
|
end
|
157
162
|
end
|
158
163
|
unless r.xpath('w:sym').empty?
|
159
164
|
code = r.xpath('w:sym').first['char'].downcase # w:char
|
160
165
|
paragraph[:content] << optional_replace(code)
|
166
|
+
pos += 1
|
161
167
|
end
|
162
168
|
end
|
163
169
|
end
|
@@ -193,6 +199,7 @@ module Docx2html
|
|
193
199
|
block
|
194
200
|
else
|
195
201
|
# inline tag
|
202
|
+
text = text.strip
|
196
203
|
text = apply_align(rpr, text)
|
197
204
|
unless rpr.xpath('w:u').empty?
|
198
205
|
text = tag(:span, text, {:style => "text-decoration:underline;"})
|
data/lib/fachinfo.rb
CHANGED
@@ -6,21 +6,24 @@ require 'cgi'
|
|
6
6
|
module Docx2html
|
7
7
|
class Parser
|
8
8
|
private
|
9
|
+
def escape(text)
|
10
|
+
CGI.escape(text.gsub(/&(.)uml;/, '\1').gsub(/\s*\/\s*|\/|\s+/, '_').downcase)
|
11
|
+
end
|
9
12
|
def parse_as_block(r, text)
|
10
|
-
if r.parent.previous.nil?
|
13
|
+
if r.parent.previous.nil? and @indecies.empty?
|
11
14
|
# The first line as package name
|
12
|
-
|
13
|
-
@indecies <<
|
14
|
-
return tag(:h2, text)
|
15
|
+
id = escape('titel')
|
16
|
+
@indecies << {:text => 'Titel', :id => id}
|
17
|
+
return tag(:h2, text, {:id => id})
|
15
18
|
end
|
16
19
|
text = text.strip
|
17
20
|
# TODO
|
18
21
|
# Franzoesisch
|
19
22
|
chapters = {
|
20
|
-
'Dos./Anw.' => /^Dosierung\s
|
23
|
+
'Dos./Anw.' => /^Dosierung\s*(\/|und)\s*Anwendung/u, # 5
|
21
24
|
'Eigensch.' => /^Eigenschaften\s*\/\s*Wirkungen($|\s*\(\s*(ATC\-Code|Wirkungsmechanismus|Pharmakodyamik|Klinische\s+Wirksamkeit)\s*\)\s*$)|^Propri.t.s/iu, # 13
|
22
|
-
'Galen.Form' => /^Galenische\s+Form\s
|
23
|
-
'Ind./Anw.mögl.' => /^Indikationen(\s+|\s
|
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öglichkeiten$|^Indications/u, # 4
|
24
27
|
'Interakt.' => /^Interaktionen$|^Interactions/u, # 8
|
25
28
|
'Kontraind.' => /^Kontraindikationen($|\s*\(\s*absolute\s+Kontraindikationen\s*\)$)/u, # 6
|
26
29
|
'Name' => /^Name\s+des\s+Präparates$/, # 1
|
@@ -28,7 +31,7 @@ module Docx2html
|
|
28
31
|
'Präklin.' => /^Präklinische\s+Daten$/u, # 15
|
29
32
|
'Pharm.kinetik' => /^Pharmakokinetik($|\s*\((Absorption,\s*Distribution,\s*Metabolisms,\s*Elimination\s|Kinetik\s+spezieller\s+Patientengruppen)*\)$)|^Pharmacocin.tique?/iu, # 14
|
30
33
|
'Sonstige H.' => /^Sonstige\s*Hinweise($|\s*\(\s*(Inkompatibilitäten|Beeinflussung\s*diagnostischer\s*Methoden|Haltbarkeit|Besondere\s*Lagerungshinweise|Hinweise\s+für\s+die\s+Handhabung)\s*\)$)|^Remarques/u, # 16
|
31
|
-
'Schwangerschaft' => /^Schwangerschaft(,\s*|\s*\/\s
|
34
|
+
'Schwangerschaft' => /^Schwangerschaft(,\s*|\s*\/\s*|\s+und\s+)Stillzeit$/u, # 9
|
32
35
|
'Stand d. Info.' => /^Stand\s+der\s+Information$|^Mise\s+.\s+jour$/iu, # 20
|
33
36
|
'Unerw.Wirkungen' => /^Unerwünschte\s+Wirkungen$/u, # 11
|
34
37
|
'Überdos.' => /^Überdosierung$|^Surdosage$/u, # 12
|
@@ -40,7 +43,7 @@ module Docx2html
|
|
40
43
|
}.each_pair do |chapter, regexp|
|
41
44
|
if text =~ regexp
|
42
45
|
next unless r.next.nil? # without line break
|
43
|
-
id =
|
46
|
+
id = escape(text)
|
44
47
|
@indecies << {:text => chapter, :id => id}
|
45
48
|
return tag(:h3, text, {:id => id})
|
46
49
|
end
|
@@ -53,19 +56,13 @@ module Docx2html
|
|
53
56
|
@container = tag(:div, [], {:id => 'container'})
|
54
57
|
end
|
55
58
|
private
|
56
|
-
def build_after_content
|
57
|
-
link = tag(:a, 'Top', {:href => ''})
|
58
|
-
tag(:div, link, {:id => 'footer'})
|
59
|
-
end
|
60
59
|
def build_before_content
|
61
60
|
if @indecies
|
62
61
|
indices = []
|
63
|
-
if @indecies.first.has_key?(:tag) and @indecies.first[:tag] == :h2
|
64
|
-
indices << @indecies.shift
|
65
|
-
end
|
66
62
|
@indecies.each do |index|
|
67
63
|
if index.has_key?(:id)
|
68
|
-
|
64
|
+
link = tag(:a, index[:text], {:href => "#" + index[:id]})
|
65
|
+
indices << tag(:li, link)
|
69
66
|
end
|
70
67
|
end
|
71
68
|
tag(:div, tag(:ul, indices), {:id => 'indecies'})
|
@@ -99,19 +96,13 @@ div#indecies {
|
|
99
96
|
}
|
100
97
|
div#indecies ul {
|
101
98
|
margin: 0;
|
102
|
-
padding:
|
99
|
+
padding: 25px 0 0 25px;
|
103
100
|
}
|
104
101
|
div#container {
|
105
102
|
position: relative;
|
106
103
|
padding: 5px 0 0 0;
|
107
104
|
float: top left;
|
108
105
|
margin: 0 0 0 200px;
|
109
|
-
}
|
110
|
-
div#footer {
|
111
|
-
position: relative;
|
112
|
-
float: bottom right;
|
113
|
-
text-align: right;
|
114
|
-
padding: 0 25px 0 0;
|
115
106
|
}
|
116
107
|
CSS
|
117
108
|
if @style == :frame
|
@@ -130,7 +121,7 @@ body{
|
|
130
121
|
}
|
131
122
|
div#indecies {
|
132
123
|
position: absolute;
|
133
|
-
|
124
|
+
padding: 0;
|
134
125
|
height: 100%;
|
135
126
|
left: 0;
|
136
127
|
top: 0;
|
@@ -140,9 +131,6 @@ div#container {
|
|
140
131
|
padding: 0;
|
141
132
|
height: 100%;
|
142
133
|
overflow: auto;
|
143
|
-
}
|
144
|
-
div#footer {
|
145
|
-
padding: 10px 30px 0 0;
|
146
134
|
}
|
147
135
|
FRAME
|
148
136
|
end
|
data/lib/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ydocx
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -13,7 +13,7 @@ date: 2012-05-01 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rdoc
|
16
|
-
requirement: &
|
16
|
+
requirement: &16773920 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ~>
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: '3.10'
|
22
22
|
type: :development
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *16773920
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: hoe
|
27
|
-
requirement: &
|
27
|
+
requirement: &16773500 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ~>
|
@@ -32,7 +32,7 @@ dependencies:
|
|
32
32
|
version: '2.13'
|
33
33
|
type: :development
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *16773500
|
36
36
|
description: ''
|
37
37
|
email:
|
38
38
|
- yasaka@ywesee.com, zdavatz@ywesee.com
|