texttube_baby 1.1.0 → 1.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3c03a1149bdebebe406574df28daf4535cfef08a
4
- data.tar.gz: 663ed918d62ef4dd27291a0fba5e1be2f629cc12
3
+ metadata.gz: 116cb473100dd9d414f79dfa21d42f5fc23db013
4
+ data.tar.gz: 65f85ede3f9046a071674d52ddc7fb752bbea5e4
5
5
  SHA512:
6
- metadata.gz: 24149e6b053b362a72c6bb380ffc9b303c848c7f6ee44b5964beb7c485c616097d1d03f35af62b9f82f1e337b27db6a47894e6d0b731b0f32ad45b61bf49c05d
7
- data.tar.gz: 0f2b5720a574478efbb1a07a3c0b5bc06ec515ed91e2eebd27151698f63d6da2a8a540efe202c6407116b396da315ab289ab15e751140ee93b8f03d1855a0919
6
+ metadata.gz: 0a3bf455bcfaf7ee0cb80f01a1c3f2741c90dee0823d1814c15b1dc69a83b01b93c7cf8d616cb08daa844c30a43bee16b6517adc48df234f9e46525f7b01ac53
7
+ data.tar.gz: d7076f4a4e79690b07b4fdaaad5d1224232bbf1b73aa947a4606882e997c36a75e5a1714afb7af3bef3af092901a10e8f456fd0293bec95bc7d15e6df8ff6a84
data/CHANGES.md CHANGED
@@ -1,6 +1,13 @@
1
1
  ## CH CH CH CH CHANGES! ##
2
2
 
3
3
 
4
+ ### Monday the 12th of June 2015, v1.1.1 ###
5
+
6
+ * Fixed up the README with new info on dropping Nokogiri for Oga, and adding syntax highlighting blocks for Github.
7
+
8
+ ----
9
+
10
+
4
11
  ### Monday the 8th of June 2015, v1.1.0 ###
5
12
 
6
13
  * Changed from Nokogiri to Oga because Nokogiri is annoying to install. Having said that, getting a bugfix into Oga was annoying too, so for now it will rely on my patched library, Oga Without the Wimpiness. This will be replaced by Oga in the next release when *it* is next released.
data/README.md CHANGED
@@ -6,21 +6,37 @@ Here are some ready built filters to use with TextTube. If you write any you thi
6
6
 
7
7
  If you're having a problem with the TextTube::InsideBlock filter on Heroku it could be because of the version of Libxml2 it uses, as [the problem given here states](http://stackoverflow.com/q/8598958/335847), which means Nokogiri won't always work properly on Heroku. When using the InsideBlock filter this can be a problem, so use the `hpricot` branch instead.
8
8
 
9
+ ### Note! Note!! ###
10
+
11
+ Because of the problems with Nokogiri, from v6.0.0 it's been replaced by [Oga](https://github.com/YorickPeterse/oga). If you want alternatives then look in the source for the other versions, or someone could be helpful and send in a plugin with [Ox](https://github.com/ohler55/ox) or some other parser doing the work :)
12
+
9
13
  ## Installation
10
14
 
11
15
  Add this line to your application's Gemfile:
12
16
 
13
- ```ruby
17
+ ```sh
14
18
  gem 'texttube_baby'
15
19
  ```
16
20
 
17
21
  And then execute:
18
22
 
19
- $ bundle
23
+ ```sh
24
+ $ bundle install
25
+ ```
26
+
27
+ though I'm a fan of sandboxing my gems, so:
28
+
29
+ ```sh
30
+ $ bundle install --binstubs --path vendor.noindex
31
+ ```
32
+
33
+ (the .noindex stops OSX Spotlight indexing it, that's just my little tip to you;)
20
34
 
21
35
  Or install it yourself as:
22
36
 
23
- $ gem install texttube_baby
37
+ ```sh
38
+ $ gem install texttube_baby
39
+ ```
24
40
 
25
41
  ## The Filters! ##
26
42
 
@@ -28,35 +44,41 @@ Or install it yourself as:
28
44
 
29
45
  If you'd don't want your links inline and would prefer to have them at the bottom of the document, then you can use this:
30
46
 
31
- require 'texttube/base'
32
- require 'texttube/baby/link_reffing'
33
-
34
- class TextWithLinks < TextTube::Base
35
- register TextTube::Baby::LinkReffing
36
- end
37
-
38
- s = TextWithLinks.new %q!Iain's blog[[http://iainbarnett.me.uk|My blog]] is good. Erik Hollensbe's blog[[http://erik.hollensbe.org/|Holistic Engineering]] is also good, as is James Coglan's blog[[http://blog.jcoglan.com/|The If Works]]!
47
+ ```ruby
48
+ require 'texttube/base'
49
+ require 'texttube/baby/link_reffing'
50
+
51
+ class TextWithLinks < TextTube::Base
52
+ register TextTube::Baby::LinkReffing
53
+ end
54
+
55
+ s = TextWithLinks.new %q!Iain's blog[[http://iainbarnett.me.uk|My blog]] is good. Erik Hollensbe's blog[[http://erik.hollensbe.org/|Holistic Engineering]] is also good, as is James Coglan's blog[[http://blog.jcoglan.com/|The If Works]]!
39
56
 
40
- s.filter
57
+ s.filter
58
+ ```
41
59
 
42
60
  and it will produce this:
43
61
 
44
- # => "Iain's blog[&#8304;](#0 "Jump to reference") is good. Erik Hollensbe's blog[&sup1;](#1 "Jump to reference") is also good, as is James Coglan's blog[&sup2;](#2 "Jump to reference")\n<div markdown='1' id='reflinks'>\n<a name="0"></a>&#91;0&#93; [http://iainbarnett.me.uk](http://iainbarnett.me.uk "http://iainbarnett.me.uk") My blog\n\n\n<a name="1"></a>&#91;1&#93; [http://erik.hollensbe.org/](http://erik.hollensbe.org/ "http://erik.hollensbe.org/") Holistic Engineering\n\n\n<a name="2"></a>&#91;2&#93; [http://blog.jcoglan.com/](http://blog.jcoglan.com/ "http://blog.jcoglan.com/") The If Works\n\n</div>"
62
+ ```
63
+ # => "Iain's blog[&#8304;](#0 "Jump to reference") is good. Erik Hollensbe's blog[&sup1;](#1 "Jump to reference") is also good, as is James Coglan's blog[&sup2;](#2 "Jump to reference")\n<div markdown='1' id='reflinks'>\n<a name="0"></a>&#91;0&#93; [http://iainbarnett.me.uk](http://iainbarnett.me.uk "http://iainbarnett.me.uk") My blog\n\n\n<a name="1"></a>&#91;1&#93; [http://erik.hollensbe.org/](http://erik.hollensbe.org/ "http://erik.hollensbe.org/") Holistic Engineering\n\n\n<a name="2"></a>&#91;2&#93; [http://blog.jcoglan.com/](http://blog.jcoglan.com/ "http://blog.jcoglan.com/") The If Works\n\n</div>"
64
+ ```
45
65
 
46
66
  Run that through a markdown parser and you get:
47
67
 
48
- <p>Iain's blog<a href="#0" title="Jump to reference">&#8304;</a> is good. Erik Hollensbe's blog<a href="#1" title="Jump to reference">&sup1;</a> is also good, as is James Coglan's blog<a href="#2" title="Jump to reference">&sup2;</a></p>
49
-
50
- <div markdown='1' id='reflinks'>
51
- <a name="0"></a>&#91;0&#93; [http://iainbarnett.me.uk](http://iainbarnett.me.uk "http://iainbarnett.me.uk") My blog
52
-
53
-
54
- <a name="1"></a>&#91;1&#93; [http://erik.hollensbe.org/](http://erik.hollensbe.org/ "http://erik.hollensbe.org/") Holistic Engineering
55
-
56
-
57
- <a name="2"></a>&#91;2&#93; [http://blog.jcoglan.com/](http://blog.jcoglan.com/ "http://blog.jcoglan.com/") The If Works
58
-
59
- </div>
68
+ ```html
69
+ <p>Iain's blog<a href="#0" title="Jump to reference">&#8304;</a> is good. Erik Hollensbe's blog<a href="#1" title="Jump to reference">&sup1;</a> is also good, as is James Coglan's blog<a href="#2" title="Jump to reference">&sup2;</a></p>
70
+
71
+ <div markdown='1' id='reflinks'>
72
+ <a name="0"></a>&#91;0&#93; [http://iainbarnett.me.uk](http://iainbarnett.me.uk "http://iainbarnett.me.uk") My blog
73
+
74
+
75
+ <a name="1"></a>&#91;1&#93; [http://erik.hollensbe.org/](http://erik.hollensbe.org/ "http://erik.hollensbe.org/") Holistic Engineering
76
+
77
+
78
+ <a name="2"></a>&#91;2&#93; [http://blog.jcoglan.com/](http://blog.jcoglan.com/ "http://blog.jcoglan.com/") The If Works
79
+
80
+ </div>
81
+ ```
60
82
 
61
83
  Using this will probably end up with also using InsideBlock, to transform the markdown inside the div.
62
84
 
@@ -64,126 +86,145 @@ Using this will probably end up with also using InsideBlock, to transform the ma
64
86
 
65
87
  Sometimes it'd be useful to wrap some markdown with HTML, for example:
66
88
 
67
- <div id="notes">
68
-
69
- * first
70
- * second
71
- * third
72
-
73
- </div>
89
+ ```
90
+ <div id="notes">
91
+
92
+ * first
93
+ * second
94
+ * third
95
+
96
+ </div>
97
+ ```
74
98
 
75
99
  If you put this through a markdown parser the markdown won't get parsed:
76
100
 
77
- require 'rdiscount'
78
- s = "<div id="notes">\n\n* first\n* second\n* third\n\n</div>\n"
79
- puts RDiscount.new(s).to_html
101
+ ```ruby
102
+ require 'rdiscount'
103
+ s = "<div id="notes">\n\n* first\n* second\n* third\n\n</div>\n"
104
+ puts RDiscount.new(s).to_html
105
+ ```
80
106
 
81
107
  This is the output:
82
108
 
83
- <div id="notes">
84
-
85
- * first
86
- * second
87
- * third
88
-
89
- </div>
109
+ ```
110
+ <div id="notes">
111
+
112
+ * first
113
+ * second
114
+ * third
115
+
116
+ </div>
117
+ ```
90
118
 
91
119
  My brilliant idea to get around this is to add an HTML attribute of `markdown='1'` to HTML tags that you want the markdown parser to look inside:
92
120
 
93
- <div id="notes" markdown='1'>
94
-
95
- * first
96
- * second
97
- * third
98
-
99
- </div>
121
+ ```
122
+ <div id="notes" markdown='1'>
123
+
124
+ * first
125
+ * second
126
+ * third
127
+
128
+ </div>
129
+ ```
100
130
 
101
131
  Trying this with `InsideBlock` gives:
102
132
 
133
+ ```ruby
103
134
  puts TextTube::Baby::InsideBlock.run s
135
+ ```
104
136
 
105
- <div id="notes">
106
- <ul>
107
- <li>first</li>
108
- <li>second</li>
109
- <li>third</li>
110
- </ul>
111
-
112
- </div>
137
+ ```
138
+ <div id="notes">
139
+ <ul>
140
+ <li>first</li>
141
+ <li>second</li>
142
+ <li>third</li>
143
+ </ul>
144
+
145
+ </div>
146
+ ```
113
147
 
114
148
  To use it as a filter:
115
149
 
116
- require 'texttube/base'
117
-
118
- class MyFilter < TextTube::Baby::Base
119
- register TextTube::Baby::InsideBlock
120
- end
121
-
122
- myf = MyFilter.new(s)
123
- # => "<div id="notes" markdown='1'>\n\n* first\n* second\n* third\n\n</div>\n"
124
-
125
- puts myf.filter
150
+ ```ruby
151
+ require 'texttube/base'
152
+
153
+ class MyFilter < TextTube::Baby::Base
154
+ register TextTube::Baby::InsideBlock
155
+ end
156
+
157
+ myf = MyFilter.new(s)
158
+ # => "<div id="notes" markdown='1'>\n\n* first\n* second\n* third\n\n</div>\n"
159
+
160
+ puts myf.filter
161
+ ```
126
162
 
127
163
  Gives:
128
164
 
129
- <div id="notes">
130
- <ul>
131
- <li>first</li>
132
- <li>second</li>
133
- <li>third</li>
134
- </ul>
135
-
136
- </div>
165
+ ```
166
+ <div id="notes">
167
+ <ul>
168
+ <li>first</li>
169
+ <li>second</li>
170
+ <li>third</li>
171
+ </ul>
172
+
173
+ </div>
174
+ ```
137
175
 
138
176
  ### Coderay ###
139
177
 
140
178
  Filters an HTML code block and marks it up with [coderay](http://coderay.rubychan.de/):
141
179
 
142
180
 
143
-
144
- require 'texttube/base'
145
- require 'texttube/baby/coderay'
146
- require 'rdiscount' # a markdown parser
147
-
148
- class TextWithCode < TextTube::Baby::Base
149
- register do
150
- filter_with :rdiscount do |text|
151
- RDiscount.new(text).to_html
152
- end
153
- end
154
- register TextTube::Baby::Coderay
181
+ ```ruby
182
+ require 'texttube/base'
183
+ require 'texttube/baby/coderay'
184
+ require 'rdiscount' # a markdown parser
185
+
186
+ class TextWithCode < TextTube::Baby::Base
187
+ register do
188
+ filter_with :rdiscount do |text|
189
+ RDiscount.new(text).to_html
190
+ end
191
+ end
192
+ register TextTube::Baby::Coderay
193
+ end
194
+
195
+ s = TextWithCode.new <<'STR'
196
+ # FizzBuzz #
197
+
198
+ ::::ruby
199
+ (1..100).each do |n|
200
+ out = "#{n}: "
201
+ out << "Fizz" if n % 3 == 0
202
+ out << "Buzz" if n % 5 == 0
203
+ puts out
155
204
  end
156
205
 
157
- s = TextWithCode.new <<'STR'
158
- # FizzBuzz #
159
-
160
- ::::ruby
161
- (1..100).each do |n|
162
- out = "#{n}: "
163
- out << "Fizz" if n % 3 == 0
164
- out << "Buzz" if n % 5 == 0
165
- puts out
166
- end
167
-
168
- That's all folks!
169
- STR
170
- # => "# FizzBuzz #\n\n ::::ruby\n (1..100).each do |n| \n out = "\#{n}: "\n out << "Fizz" if n % 3 == 0\n out << "Buzz" if n % 5 == 0\n puts out\n end\n\nThat's all folks!\n"
206
+ That's all folks!
207
+ STR
208
+ # => "# FizzBuzz #\n\n ::::ruby\n (1..100).each do |n| \n out = "\#{n}: "\n out << "Fizz" if n % 3 == 0\n out << "Buzz" if n % 5 == 0\n puts out\n end\n\nThat's all folks!\n"
171
209
 
172
210
 
173
- puts s.filter
211
+ puts s.filter
212
+ ```
174
213
 
175
214
  Produces:
176
215
 
177
- <h1>FizzBuzz</h1>
178
-
179
- <pre><code class="CodeRay">(<span class="integer">1</span>..<span class="integer">100</span>).each <span class="keyword">do</span> |n|
180
- out = <span class="string"><span class="delimiter">"</span><span class="inline"><span class="inline-delimiter">#{</span>n<span class="inline-delimiter">}</span></span><span class="content">: </span><span class="delimiter">"</span></span>
181
- out &lt;&lt; <span class="string"><span class="delimiter">"</span><span class="content">Fizz</span><span class="delimiter">"</span></span> <span class="keyword">if</span> n % <span class="integer">3</span> == <span class="integer">0</span>
182
- out &lt;&lt; <span class="string"><span class="delimiter">"</span><span class="content">Buzz</span><span class="delimiter">"</span></span> <span class="keyword">if</span> n % <span class="integer">5</span> == <span class="integer">0</span>
183
- puts out
184
- <span class="keyword">end</span></code></pre>
185
-
186
- <p>That's all folks!</p>
216
+ ```
217
+ <h1>FizzBuzz</h1>
218
+
219
+ <pre><code class="CodeRay">(<span class="integer">1</span>..<span class="integer">100</span>).each <span class="keyword">do</span> |n|
220
+ out = <span class="string"><span class="delimiter">"</span><span class="inline"><span class="inline-delimiter">#{</span>n<span class="inline-delimiter">}</span></span><span class="content">: </span><span class="delimiter">"</span></span>
221
+ out &lt;&lt; <span class="string"><span class="delimiter">"</span><span class="content">Fizz</span><span class="delimiter">"</span></span> <span class="keyword">if</span> n % <span class="integer">3</span> == <span class="integer">0</span>
222
+ out &lt;&lt; <span class="string"><span class="delimiter">"</span><span class="content">Buzz</span><span class="delimiter">"</span></span> <span class="keyword">if</span> n % <span class="integer">5</span> == <span class="integer">0</span>
223
+ puts out
224
+ <span class="keyword">end</span></code></pre>
225
+
226
+ <p>That's all folks!</p>
227
+ ```
187
228
 
188
229
  The language was specified with a leading `::::ruby`. It didn't have to be as the default is to use Ruby, but if you want to use any other of the [coderay supported languages](http://coderay.rubychan.de/doc/CodeRay/Scanners.html), that's how to do it.
189
230
 
@@ -191,44 +232,48 @@ The language was specified with a leading `::::ruby`. It didn't have to be as th
191
232
 
192
233
  Transforms CSS written in British English into its ugly sister from across the pond. Inspired by [visualidiot's SpiffingCSS](https://github.com/visualidiot/Spiffing).
193
234
 
194
- content = <<CSS
195
- body {
196
- background-colour: darkgrey;
197
- background-photograph: url(logo.gif);
198
- transparency: .7;
199
-
200
- font: 72px "Comic Sans", cursive !please;
201
- font-weight: plump;
202
- p { text-align: centre }
203
- fieldset input {
204
- text-transform: capitalise;
205
- }
206
- }
207
- CSS
208
-
209
- require 'texttube/base'
210
- require 'texttube/baby/spiffing'
211
-
212
- class CssString < TextTube::Base
213
- register TextTube::Baby::Spiffing
214
- end
215
-
216
- puts CssString.new(content).filter
217
-
218
- # output:
219
-
220
- body {
221
- background-color: darkgray;
222
- background-image: url(logo.gif);
223
- opacity: .7;
224
-
225
- font: 72px "Comic Sans", cursive !important;
226
- font-weight: bold;
227
- p { text-align: center }
228
- fieldset input {
229
- text-transform: capitalize;
230
- }
235
+ ```ruby
236
+ content = <<CSS
237
+ body {
238
+ background-colour: darkgrey;
239
+ background-photograph: url(logo.gif);
240
+ transparency: .7;
241
+
242
+ font: 72px "Comic Sans", cursive !please;
243
+ font-weight: plump;
244
+ p { text-align: centre }
245
+ fieldset input {
246
+ text-transform: capitalise;
231
247
  }
248
+ }
249
+ CSS
250
+
251
+ require 'texttube/base'
252
+ require 'texttube/baby/spiffing'
253
+
254
+ class CssString < TextTube::Base
255
+ register TextTube::Baby::Spiffing
256
+ end
257
+
258
+ puts CssString.new(content).filter
259
+ ```
260
+
261
+ # output:
262
+
263
+ ```css
264
+ body {
265
+ background-color: darkgray;
266
+ background-image: url(logo.gif);
267
+ opacity: .7;
268
+
269
+ font: 72px "Comic Sans", cursive !important;
270
+ font-weight: bold;
271
+ p { text-align: center }
272
+ fieldset input {
273
+ text-transform: capitalize;
274
+ }
275
+ }
276
+ ```
232
277
 
233
278
  God save the Queen!
234
279
 
@@ -1,5 +1,5 @@
1
1
  module TextTube
2
2
  module Baby
3
- VERSION = "1.1.0"
3
+ VERSION = "1.1.1"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: texttube_baby
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Iain Barnett
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-06-08 00:00:00.000000000 Z
11
+ date: 2015-06-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: texttube