feed_yamlizer 0.0.7 → 0.0.8

Sign up to get free protection for your applications and to get access to all the features.
data/lib/feed_yamlizer.rb CHANGED
@@ -66,6 +66,12 @@ class FeedYamlizer
66
66
  simplified = HtmlCleaner.new(content).output
67
67
  textified = Textifier.new(simplified).output
68
68
  #@result[:items][-1][:content][:simplified] = simplified
69
+ textified = textified.gsub(FeedYamlizer::NEWLINE_PLACEHOLDER, "\n").
70
+ gsub(SPACE_PLACEHOLDER, " ").
71
+ gsub(TAB_PLACEHOLDER, " ")
72
+ # next two lines are dev lines
73
+ #puts textified
74
+ #exit
69
75
  @result[:items][-1][:content][:text] = textified
70
76
  end
71
77
 
@@ -1,4 +1,8 @@
1
1
  class FeedYamlizer
2
+ NEWLINE_PLACEHOLDER = '+---NEWLINE---+'
3
+ SPACE_PLACEHOLDER = '+---SPACE---+'
4
+ TAB_PLACEHOLDER = '+---TAB---+'
5
+
2
6
  class HtmlListener
3
7
  include REXML::StreamListener
4
8
 
@@ -85,15 +89,16 @@ class FeedYamlizer
85
89
  when 'blockquote'
86
90
  @content += ["[blockquote]", ""]
87
91
  when 'ul', 'ol', 'dl'
88
- @content << "<#{name}>"
92
+ @content << "<#{name}>\n"
89
93
  when 'li', 'dt', 'dd'
90
- @content[-1] << " <#{name}>"
94
+ @content[-1] << "\n * "
91
95
  when 'strong', 'em'
92
96
  @content[-1] << "<#{name}>"
93
97
  when *BLOCK_TAGS
94
98
  @content << "<p>"
95
99
  when 'pre'
96
- @content << "<pre>"
100
+ @pre = true
101
+ @content << "[pre]\n"
97
102
  end
98
103
  end
99
104
 
@@ -111,13 +116,14 @@ class FeedYamlizer
111
116
  when 'ul', 'ol', 'dl'
112
117
  @content[-1] << "</#{name}>"
113
118
  when 'li', 'dt', 'dd'
114
- @content[-1] << " </#{name}>"
119
+ @content[-1] << "\n"
115
120
  when 'strong', 'em'
116
121
  @content[-1] << "</#{name}>"
117
122
  when *BLOCK_TAGS
118
123
  @content[-1] << "</p>"
119
124
  when 'pre'
120
- @content[-1] << "</pre>"
125
+ @pre = false
126
+ @content[-1] << "\n[/pre]"
121
127
  end
122
128
  end
123
129
 
@@ -128,7 +134,11 @@ class FeedYamlizer
128
134
  return
129
135
  end
130
136
 
131
- @content[-1] << text
137
+ if @pre
138
+ @content[-1] << text.gsub("\n", NEWLINE_PLACEHOLDER).gsub(/\t/, TAB_PLACEHOLDER).gsub(" ", SPACE_PLACEHOLDER)
139
+ else
140
+ @content[-1] << text
141
+ end
132
142
  end
133
143
 
134
144
  def start_of_block?
@@ -1,3 +1,3 @@
1
1
  class FeedYamlizer
2
- VERSION = "0.0.7"
2
+ VERSION = "0.0.8"
3
3
  end
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 0
8
- - 7
9
- version: 0.0.7
8
+ - 8
9
+ version: 0.0.8
10
10
  platform: ruby
11
11
  authors:
12
12
  - Daniel Choi