oo2md2tex 0.0.15 → 0.0.16

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/bin/oo2text +26 -7
  3. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 030cc13cfba7ba41b8bcc00cf62ef0faea1e5548
4
- data.tar.gz: 46e32cb7888baa66a570be96839fb0ede372326c
3
+ metadata.gz: 1f66a21735bad0d49f64f38ccb929b6689889320
4
+ data.tar.gz: ea9b18b7b1a9635b372f7d7f5e654d6b39f6a3c9
5
5
  SHA512:
6
- metadata.gz: bf5c50aaec005a7b3b7fbf846ecb69edef234c00ad7d4d05dcdc6fd90d56b8876183dc1dfddd8c678959d6a2cc08271a77e5232099d6e2496842b14d5dde1f70
7
- data.tar.gz: 2882dd5f9ff280f7ef7083aaf43ed28c3442a6788403091637a4d4748baf8c26d5c803db23bd5107ad994caecf8b9af4aa772de0fb6ff0edf6e66b2ff08cfdba
6
+ metadata.gz: 7bfb984938eb696d137939e85be91e4c91bc6a0413d24180d20b074917c53f4668c5750311cec448a244ce8ace8631da4d516f4f72edb318e83785589e05a384
7
+ data.tar.gz: 84bdb11e919e10560144bc05d78f8b2b21f40c1cb735bee69113219e3c7a480403f7c6bb4479e1aff5da8fcf8cfca4757332780b29d0daa28ace01e2264f0b90
data/bin/oo2text CHANGED
@@ -21,6 +21,8 @@ require 'nokogiri'
21
21
  require 'zlib'
22
22
  require 'zip'
23
23
  require 'stringio'
24
+ require 'awesome_print'
25
+ require 'pry-byebug'
24
26
 
25
27
  module OmniOutliner
26
28
 
@@ -31,6 +33,7 @@ module OmniOutliner
31
33
  @in_lit = false
32
34
  @in_item = false
33
35
  @in_style = false
36
+ @in_root = false
34
37
  @str = ""
35
38
  super
36
39
  end
@@ -44,6 +47,10 @@ module OmniOutliner
44
47
  @in_item = true if name == "item"
45
48
  @in_style = true if name == "style"
46
49
  @in_lit = true if name == "lit"
50
+ if name == "root"
51
+ @in_root = true
52
+ @str = ""
53
+ end
47
54
  if name == "cell"
48
55
  # if it is a hyperlink, use name part as part of output
49
56
  if n = attrs.find{|a| a[0] == "name"}
@@ -62,7 +69,7 @@ module OmniOutliner
62
69
  end
63
70
  if name == "values"
64
71
  @str.gsub(/\n/, '')
65
- puts @str
72
+ puts @str if @in_root
66
73
  @str = ""
67
74
  end
68
75
  end
@@ -93,6 +100,7 @@ module OmniOutliner
93
100
  class V5
94
101
  class Item
95
102
  attr_reader :attrs
103
+ attr_accessor :is_root
96
104
 
97
105
  def initialize(attrs, text)
98
106
  @attrs = attrs
@@ -101,12 +109,12 @@ module OmniOutliner
101
109
  end
102
110
 
103
111
  def add(rank, item)
104
- rank = "0" if rank == ""
105
- @children[rank.to_i] = item
112
+ rank = "0" if rank.nil? || rank == ""
113
+ @children[rank.hex] = item
106
114
  end
107
115
 
108
116
  def print_all
109
- puts @text
117
+ puts @text unless @is_root
110
118
  @children.keys.sort.each {|k| @children[k].print_all}
111
119
  end
112
120
  end
@@ -120,6 +128,8 @@ module OmniOutliner
120
128
  @str = ""
121
129
  @items = {}
122
130
  @id_stack = []
131
+ @attrs_stack = []
132
+ @in_items = false
123
133
  super
124
134
  end
125
135
 
@@ -138,17 +148,24 @@ module OmniOutliner
138
148
  @in_style = true if name == "style"
139
149
  @in_lit = true if name == "lit"
140
150
  @in_item = true if name == "item"
151
+ @in_items = true if name == "items"
141
152
  if name == "cell"
142
153
  # if it is a hyperlink, use name part as part of output
143
154
  if @attrs.has_key?("name")
144
155
  @str += @attrs["name"]
145
156
  end
146
157
  end
147
- @id_stack.push(@id)
158
+ if name == "item"
159
+ @id_stack.push(@id)
160
+ @attrs_stack.push(@attrs)
161
+ end
148
162
  end
149
163
 
150
164
  def end_element(name)
151
- @id = @id_stack.pop
165
+ if name == "item"
166
+ @id = @id_stack.pop
167
+ @attrs = @attrs_stack.pop
168
+ end
152
169
  @in_column = false if name == "column"
153
170
  @in_style = false if name == "style"
154
171
  if name == "item"
@@ -158,14 +175,16 @@ module OmniOutliner
158
175
  @str = ""
159
176
  end
160
177
  if name == "lit"
161
- @str += "\n"
178
+ @str += "\n" if @in_items
162
179
  @in_lit = false
163
180
  end
164
181
  if name == "outline" # final output
165
182
  @root = nil
183
+ puts "#{@items.count} items"
166
184
  @items.each do |id, item|
167
185
  if item.attrs["is-root"] == "yes"
168
186
  @root = item
187
+ @root.is_root = true
169
188
  elsif pid = item.attrs["parent-id"]
170
189
  @items[pid].add(item.attrs["rank"], item)
171
190
  else
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: oo2md2tex
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.15
4
+ version: 0.0.16
5
5
  platform: ruby
6
6
  authors:
7
7
  - Shigeya Suzuki