ydocx 1.0.0 → 1.0.1

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/Manifest.txt CHANGED
@@ -10,3 +10,4 @@ lib/docx2html/lib/docx2html/document.rb
10
10
  lib/docx2html/lib/docx2html/html_methods.rb
11
11
  lib/docx2html/lib/docx2html/parser.rb
12
12
  lib/fachinfo.rb
13
+ lib/version.rb
data/bin/docx2html CHANGED
@@ -1,18 +1,19 @@
1
1
  #!/usr/bin/env ruby
2
2
  # coding: utf-8
3
3
 
4
- require 'pathname'
5
-
6
- VERSION = "1.0.0"
7
-
8
- root = Pathname.new(__FILE__).realpath.parent.parent
9
- %w(
10
- lib/docx2html/lib
11
- lib
12
- ).each do |lib|
13
- $:.unshift root.join(lib) if $0 == __FILE__
4
+ if $0 == __FILE__
5
+ require 'pathname'
6
+ root = Pathname.new(__FILE__).realpath.parent.parent
7
+ %w(
8
+ lib/docx2html/lib
9
+ lib
10
+ ).each do |lib|
11
+ $:.unshift root.join(lib)
12
+ end
13
+ require 'docx2html'
14
+ else
15
+ require 'docx2html/lib/docx2html'
14
16
  end
15
- require 'docx2html'
16
17
 
17
18
  if file = ARGV.first
18
19
  unless File.exist?(file)
@@ -22,6 +23,9 @@ if file = ARGV.first
22
23
  if true
23
24
  require 'fachinfo'
24
25
  end
25
- Docx2html::Document.open(file).to_html file, :style => true
26
+ options = {
27
+ :style => :frame
28
+ }
29
+ Docx2html::Document.open(file).to_html file, options
26
30
  end
27
31
  end
@@ -2,12 +2,13 @@
2
2
  # encoding: utf-8
3
3
 
4
4
  require 'nokogiri'
5
- require 'docx2html/html_methods'
5
+ require 'docx2html/lib/docx2html/html_methods'
6
6
 
7
7
  module Docx2html
8
8
  class Builder
9
9
  include HtmlMethods
10
- attr_accessor :body, :indecies, :style, :title
10
+ attr_accessor :body, :indecies, :title,
11
+ :frame, :style
11
12
  def initialize(body)
12
13
  @body = body
13
14
  @container = {}
@@ -3,8 +3,8 @@
3
3
 
4
4
  require 'pathname'
5
5
  require 'zip/zip'
6
- require 'docx2html/parser'
7
- require 'docx2html/builder'
6
+ require 'docx2html/lib/docx2html/parser'
7
+ require 'docx2html/lib/docx2html/builder'
8
8
 
9
9
  module Docx2html
10
10
  class Document
@@ -21,7 +21,7 @@ module Docx2html
21
21
  html = ''
22
22
  Builder.new(@contents) do |builder|
23
23
  builder.title = @path
24
- builder.style = options[:style]
24
+ builder.style = options[:style] if options.has_key?(:style)
25
25
  if @indecies
26
26
  builder.indecies = @indecies
27
27
  end
@@ -3,7 +3,7 @@
3
3
 
4
4
  require 'nokogiri'
5
5
  require 'htmlentities'
6
- require 'docx2html/html_methods'
6
+ require 'docx2html/lib/docx2html/html_methods'
7
7
 
8
8
  module Docx2html
9
9
  class Parser
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
2
  # encoding: utf-8
3
3
 
4
- require 'docx2html/document'
4
+ require 'docx2html/lib/docx2html/document'
5
5
 
6
6
  module Docx2html
7
7
  end
data/lib/fachinfo.rb CHANGED
@@ -8,7 +8,9 @@ module Docx2html
8
8
  private
9
9
  def parse_as_block(r, text)
10
10
  if r.parent.previous.nil?
11
- # first line is package name
11
+ # The first line as package name
12
+ link = tag(:a, text, {:href => ''})
13
+ @indecies << tag(:h2, link)
12
14
  return tag(:h2, text)
13
15
  end
14
16
  text = text.strip
@@ -58,8 +60,13 @@ module Docx2html
58
60
  def build_before_content
59
61
  if @indecies
60
62
  indices = []
63
+ if @indecies.first.has_key?(:tag) and @indecies.first[:tag] == :h2
64
+ indices << @indecies.shift
65
+ end
61
66
  @indecies.each do |index|
62
- indices << tag(:li, tag(:a, index[:text], {:href => "#" + index[:id]}))
67
+ if index.has_key?(:id)
68
+ indices << tag(:li, tag(:a, index[:text], {:href => "#" + index[:id]}))
69
+ end
63
70
  end
64
71
  tag(:div, tag(:ul, indices), {:id => 'indecies'})
65
72
  end
@@ -68,7 +75,7 @@ module Docx2html
68
75
  style = <<-CSS
69
76
  table, tr, td {
70
77
  border-collapse: collapse;
71
- border: 1px solid gray;
78
+ border: 1px solid gray;
72
79
  }
73
80
  table {
74
81
  margin: 5px 0 5px 0;
@@ -78,7 +85,7 @@ td {
78
85
  }
79
86
  body {
80
87
  position: relative;
81
- padding: 0 0 20px 0;
88
+ padding: 0 0 25px 0;
82
89
  margin: 0px;
83
90
  width: 100%;
84
91
  height: auto;
@@ -86,26 +93,59 @@ body {
86
93
  div#indecies {
87
94
  position: relative;
88
95
  padding: 0px;
96
+ margin: 0px;
89
97
  float: left;
90
98
  width: 200px;
91
99
  }
92
100
  div#indecies ul {
93
101
  margin: 0;
94
- padding: 0 0 0 25px;
102
+ padding: 5px 0 0 25px;
95
103
  }
96
104
  div#container {
97
- position: relative;
98
- padding: 0px;
99
- float: top left;
100
- margin-left: 200px;
105
+ position: relative;
106
+ padding: 5px 0 0 0;
107
+ float: top left;
108
+ margin: 0 0 0 200px;
101
109
  }
102
110
  div#footer {
103
- position: relative;
104
- float: bottom right;
105
- text-align: right;
106
- padding-right: 25px;
111
+ position: relative;
112
+ float: bottom right;
113
+ text-align: right;
114
+ padding: 0 25px 0 0;
107
115
  }
108
116
  CSS
117
+ if @style == :frame
118
+ style << <<-FRAME
119
+ html {
120
+ overflow: hidden;
121
+ height: 100%;
122
+ width: 100%;
123
+ }
124
+ body{
125
+ position: absolute;
126
+ overflow: hidden;
127
+ padding: 0;
128
+ height: 100%;
129
+ width: 100%;
130
+ }
131
+ div#indecies {
132
+ position: absolute;
133
+ osition: fixed;
134
+ height: 100%;
135
+ left: 0;
136
+ top: 0;
137
+ }
138
+ div#container {
139
+ position: absolute;
140
+ padding: 0;
141
+ height: 100%;
142
+ overflow: auto;
143
+ }
144
+ div#footer {
145
+ padding: 10px 30px 0 0;
146
+ }
147
+ FRAME
148
+ end
109
149
  style.gsub(/\s\s+|\n/, ' ')
110
150
  end
111
151
  end
data/lib/version.rb ADDED
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env ruby
2
+ # encoding: utf-8
3
+
4
+ module Docx2html
5
+ VERSION = "1.0.1"
6
+ end
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.0
4
+ version: 1.0.1
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: &21539280 !ruby/object:Gem::Requirement
16
+ requirement: &23006340 !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: *21539280
24
+ version_requirements: *23006340
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: hoe
27
- requirement: &21538860 !ruby/object:Gem::Requirement
27
+ requirement: &23005920 !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: *21538860
35
+ version_requirements: *23005920
36
36
  description: ''
37
37
  email:
38
38
  - yasaka@ywesee.com, zdavatz@ywesee.com
@@ -56,6 +56,7 @@ files:
56
56
  - lib/docx2html/lib/docx2html/html_methods.rb
57
57
  - lib/docx2html/lib/docx2html/parser.rb
58
58
  - lib/fachinfo.rb
59
+ - lib/version.rb
59
60
  homepage: https://github.com/zdavatz/ydocx
60
61
  licenses: []
61
62
  post_install_message: