mbrao 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (73) hide show
  1. data/.gitignore +6 -0
  2. data/.travis-gemfile +13 -0
  3. data/.travis.yml +8 -0
  4. data/.yardopts +1 -0
  5. data/Gemfile +21 -0
  6. data/README.md +60 -0
  7. data/Rakefile +11 -0
  8. data/doc/ActionView/Template/Handlers/MbraoTemplate.html +568 -0
  9. data/doc/ActionView/Template/Handlers.html +125 -0
  10. data/doc/HTML/Pipeline/KramdownFilter.html +354 -0
  11. data/doc/HTML/Pipeline.html +140 -0
  12. data/doc/HTML.html +125 -0
  13. data/doc/Mbrao/Author.html +1402 -0
  14. data/doc/Mbrao/Content.html +4779 -0
  15. data/doc/Mbrao/ContentPublicInterface.html +658 -0
  16. data/doc/Mbrao/Exceptions/InvalidDate.html +133 -0
  17. data/doc/Mbrao/Exceptions/InvalidMetadata.html +133 -0
  18. data/doc/Mbrao/Exceptions/Parsing.html +133 -0
  19. data/doc/Mbrao/Exceptions/Rendering.html +133 -0
  20. data/doc/Mbrao/Exceptions/UnavailableLocalization.html +133 -0
  21. data/doc/Mbrao/Exceptions/Unimplemented.html +133 -0
  22. data/doc/Mbrao/Exceptions/UnknownEngine.html +133 -0
  23. data/doc/Mbrao/Exceptions.html +125 -0
  24. data/doc/Mbrao/Parser.html +418 -0
  25. data/doc/Mbrao/ParsingEngines/Base.html +658 -0
  26. data/doc/Mbrao/ParsingEngines/PlainText.html +571 -0
  27. data/doc/Mbrao/ParsingEngines.html +127 -0
  28. data/doc/Mbrao/PublicInterface/ClassMethods.html +1727 -0
  29. data/doc/Mbrao/PublicInterface.html +134 -0
  30. data/doc/Mbrao/RenderingEngines/Base.html +280 -0
  31. data/doc/Mbrao/RenderingEngines/HtmlPipeline.html +873 -0
  32. data/doc/Mbrao/RenderingEngines.html +127 -0
  33. data/doc/Mbrao/Validations/ClassMethods.html +692 -0
  34. data/doc/Mbrao/Validations.html +134 -0
  35. data/doc/Mbrao/Version.html +189 -0
  36. data/doc/Mbrao.html +130 -0
  37. data/doc/_index.html +395 -0
  38. data/doc/class_list.html +53 -0
  39. data/doc/css/common.css +1 -0
  40. data/doc/css/full_list.css +57 -0
  41. data/doc/css/style.css +338 -0
  42. data/doc/file.README.html +135 -0
  43. data/doc/file_list.html +55 -0
  44. data/doc/frames.html +28 -0
  45. data/doc/index.html +135 -0
  46. data/doc/js/app.js +214 -0
  47. data/doc/js/full_list.js +173 -0
  48. data/doc/js/jquery.js +4 -0
  49. data/doc/method_list.html +516 -0
  50. data/doc/top-level-namespace.html +112 -0
  51. data/lib/mbrao/author.rb +61 -0
  52. data/lib/mbrao/content.rb +300 -0
  53. data/lib/mbrao/exceptions.rb +38 -0
  54. data/lib/mbrao/integrations/rails.rb +51 -0
  55. data/lib/mbrao/parser.rb +276 -0
  56. data/lib/mbrao/parsing_engines/base.rb +51 -0
  57. data/lib/mbrao/parsing_engines/plain_text.rb +187 -0
  58. data/lib/mbrao/rendering_engines/base.rb +22 -0
  59. data/lib/mbrao/rendering_engines/html_pipeline.rb +147 -0
  60. data/lib/mbrao/version.rb +25 -0
  61. data/lib/mbrao.rb +24 -0
  62. data/mbrao.gemspec +31 -0
  63. data/spec/coverage_helper.rb +17 -0
  64. data/spec/mbrao/author_spec.rb +62 -0
  65. data/spec/mbrao/content_spec.rb +280 -0
  66. data/spec/mbrao/integrations/rails_spec.rb +92 -0
  67. data/spec/mbrao/parser_spec.rb +269 -0
  68. data/spec/mbrao/parsing_engines/base_spec.rb +52 -0
  69. data/spec/mbrao/parsing_engines/plain_text_spec.rb +141 -0
  70. data/spec/mbrao/rendering_engines/base_spec.rb +17 -0
  71. data/spec/mbrao/rendering_engines/html_pipeline_spec.rb +128 -0
  72. data/spec/spec_helper.rb +15 -0
  73. metadata +195 -0
@@ -0,0 +1,873 @@
1
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
2
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
4
+ <head>
5
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
6
+ <title>
7
+ Class: Mbrao::RenderingEngines::HtmlPipeline
8
+
9
+ &mdash; Documentation by YARD 0.8.5.2
10
+
11
+ </title>
12
+
13
+ <link rel="stylesheet" href="../../css/style.css" type="text/css" media="screen" charset="utf-8" />
14
+
15
+ <link rel="stylesheet" href="../../css/common.css" type="text/css" media="screen" charset="utf-8" />
16
+
17
+ <script type="text/javascript" charset="utf-8">
18
+ hasFrames = window.top.frames.main ? true : false;
19
+ relpath = '../../';
20
+ framesUrl = "../../frames.html#!" + escape(window.location.href);
21
+ </script>
22
+
23
+
24
+ <script type="text/javascript" charset="utf-8" src="../../js/jquery.js"></script>
25
+
26
+ <script type="text/javascript" charset="utf-8" src="../../js/app.js"></script>
27
+
28
+
29
+ </head>
30
+ <body>
31
+ <div id="header">
32
+ <div id="menu">
33
+
34
+ <a href="../../_index.html">Index (H)</a> &raquo;
35
+ <span class='title'><span class='object_link'><a href="../../Mbrao.html" title="Mbrao (module)">Mbrao</a></span></span> &raquo; <span class='title'><span class='object_link'><a href="../RenderingEngines.html" title="Mbrao::RenderingEngines (module)">RenderingEngines</a></span></span>
36
+ &raquo;
37
+ <span class="title">HtmlPipeline</span>
38
+
39
+
40
+ <div class="noframes"><span class="title">(</span><a href="." target="_top">no frames</a><span class="title">)</span></div>
41
+ </div>
42
+
43
+ <div id="search">
44
+
45
+ <a class="full_list_link" id="class_list_link"
46
+ href="../../class_list.html">
47
+ Class List
48
+ </a>
49
+
50
+ <a class="full_list_link" id="method_list_link"
51
+ href="../../method_list.html">
52
+ Method List
53
+ </a>
54
+
55
+ <a class="full_list_link" id="file_list_link"
56
+ href="../../file_list.html">
57
+ File List
58
+ </a>
59
+
60
+ </div>
61
+ <div class="clear"></div>
62
+ </div>
63
+
64
+ <iframe id="search_frame"></iframe>
65
+
66
+ <div id="content"><h1>Class: Mbrao::RenderingEngines::HtmlPipeline
67
+
68
+
69
+
70
+ </h1>
71
+
72
+ <dl class="box">
73
+
74
+ <dt class="r1">Inherits:</dt>
75
+ <dd class="r1">
76
+ <span class="inheritName"><span class='object_link'><a href="Base.html" title="Mbrao::RenderingEngines::Base (class)">Base</a></span></span>
77
+
78
+ <ul class="fullTree">
79
+ <li>Object</li>
80
+
81
+ <li class="next"><span class='object_link'><a href="Base.html" title="Mbrao::RenderingEngines::Base (class)">Base</a></span></li>
82
+
83
+ <li class="next">Mbrao::RenderingEngines::HtmlPipeline</li>
84
+
85
+ </ul>
86
+ <a href="#" class="inheritanceTree">show all</a>
87
+
88
+ </dd>
89
+
90
+
91
+
92
+
93
+
94
+
95
+
96
+
97
+
98
+ <dt class="r2 last">Defined in:</dt>
99
+ <dd class="r2 last">lib/mbrao/rendering_engines/html_pipeline.rb</dd>
100
+
101
+ </dl>
102
+ <div class="clear"></div>
103
+
104
+ <h2>Overview</h2><div class="docstring">
105
+ <div class="discussion">
106
+ <p>A renders which use the <a href="https://github.com/jch/html-pipeline">html-pipeline</a> gem.</p>
107
+
108
+
109
+ </div>
110
+ </div>
111
+ <div class="tags">
112
+
113
+
114
+ </div>
115
+
116
+
117
+
118
+ <h2>Instance Attribute Summary <small>(<a href="#" class="summary_toggle">collapse</a>)</small></h2>
119
+ <ul class="summary">
120
+
121
+ <li class="public ">
122
+ <span class="summary_signature">
123
+
124
+ <a href="#default_options-instance_method" title="#default_options (instance method)">- (Hash) <strong>default_options</strong> </a>
125
+
126
+
127
+
128
+ </span>
129
+
130
+
131
+
132
+
133
+
134
+
135
+
136
+
137
+
138
+
139
+
140
+
141
+ <span class="summary_desc"><div class='inline'><p>Gets the default options.</p>
142
+ </div></span>
143
+
144
+ </li>
145
+
146
+
147
+ <li class="public ">
148
+ <span class="summary_signature">
149
+
150
+ <a href="#default_pipeline-instance_method" title="#default_pipeline (instance method)">- (Array) <strong>default_pipeline</strong> </a>
151
+
152
+
153
+
154
+ </span>
155
+
156
+
157
+
158
+
159
+
160
+
161
+
162
+
163
+
164
+
165
+
166
+
167
+ <span class="summary_desc"><div class='inline'><p>Gets the default pipeline.</p>
168
+ </div></span>
169
+
170
+ </li>
171
+
172
+
173
+ </ul>
174
+
175
+
176
+
177
+
178
+
179
+ <h2>
180
+ Instance Method Summary
181
+ <small>(<a href="#" class="summary_toggle">collapse</a>)</small>
182
+ </h2>
183
+
184
+ <ul class="summary">
185
+
186
+ <li class="public ">
187
+ <span class="summary_signature">
188
+
189
+ <a href="#render-instance_method" title="#render (instance method)">- (Object) <strong>render</strong>(content, options = {}, context = {}) </a>
190
+
191
+
192
+
193
+ </span>
194
+
195
+
196
+
197
+
198
+
199
+
200
+
201
+
202
+
203
+ <span class="summary_desc"><div class='inline'><p>Renders a content.</p>
204
+ </div></span>
205
+
206
+ </li>
207
+
208
+
209
+ </ul>
210
+
211
+
212
+
213
+
214
+
215
+
216
+
217
+
218
+
219
+ <div id="instance_attr_details" class="attr_details">
220
+ <h2>Instance Attribute Details</h2>
221
+
222
+
223
+ <span id="default_options=-instance_method"></span>
224
+ <div class="method_details first">
225
+ <h3 class="signature first" id="default_options-instance_method">
226
+
227
+ - (<tt>Hash</tt>) <strong>default_options</strong>
228
+
229
+
230
+
231
+
232
+
233
+ </h3><div class="docstring">
234
+ <div class="discussion">
235
+ <p>Gets the default options.</p>
236
+
237
+
238
+ </div>
239
+ </div>
240
+ <div class="tags">
241
+
242
+ <p class="tag_title">Returns:</p>
243
+ <ul class="return">
244
+
245
+ <li>
246
+
247
+
248
+ <span class='type'>(<tt>Hash</tt>)</span>
249
+
250
+
251
+
252
+ &mdash;
253
+ <div class='inline'><p>The default options.</p>
254
+ </div>
255
+
256
+ </li>
257
+
258
+ </ul>
259
+
260
+ </div><table class="source_code">
261
+ <tr>
262
+ <td>
263
+ <pre class="lines">
264
+
265
+
266
+ 42
267
+ 43
268
+ 44
269
+ 45
270
+ 46
271
+ 47
272
+ 48
273
+ 49
274
+ 50
275
+ 51
276
+ 52
277
+ 53
278
+ 54
279
+ 55
280
+ 56
281
+ 57
282
+ 58
283
+ 59
284
+ 60
285
+ 61
286
+ 62
287
+ 63
288
+ 64
289
+ 65
290
+ 66
291
+ 67
292
+ 68
293
+ 69
294
+ 70
295
+ 71
296
+ 72
297
+ 73
298
+ 74
299
+ 75
300
+ 76
301
+ 77
302
+ 78
303
+ 79
304
+ 80
305
+ 81
306
+ 82
307
+ 83
308
+ 84
309
+ 85
310
+ 86
311
+ 87
312
+ 88
313
+ 89
314
+ 90
315
+ 91
316
+ 92
317
+ 93
318
+ 94
319
+ 95
320
+ 96
321
+ 97
322
+ 98
323
+ 99
324
+ 100
325
+ 101
326
+ 102
327
+ 103
328
+ 104
329
+ 105
330
+ 106
331
+ 107
332
+ 108
333
+ 109
334
+ 110
335
+ 111
336
+ 112
337
+ 113
338
+ 114
339
+ 115
340
+ 116
341
+ 117
342
+ 118
343
+ 119
344
+ 120
345
+ 121
346
+ 122
347
+ 123
348
+ 124
349
+ 125
350
+ 126
351
+ 127
352
+ 128
353
+ 129
354
+ 130
355
+ 131
356
+ 132
357
+ 133
358
+ 134
359
+ 135
360
+ 136
361
+ 137
362
+ 138
363
+ 139
364
+ 140
365
+ 141
366
+ 142
367
+ 143
368
+ 144
369
+ 145</pre>
370
+ </td>
371
+ <td>
372
+ <pre class="code"><span class="info file"># File 'lib/mbrao/rendering_engines/html_pipeline.rb', line 42</span>
373
+
374
+ <span class='kw'>class</span> <span class='const'>HtmlPipeline</span> <span class='op'>&lt;</span> <span class='const'>Mbrao</span><span class='op'>::</span><span class='const'>RenderingEngines</span><span class='op'>::</span><span class='const'>Base</span>
375
+ <span class='id identifier rubyid_attr_accessor'>attr_accessor</span> <span class='symbol'>:default_pipeline</span>
376
+ <span class='id identifier rubyid_attr_accessor'>attr_accessor</span> <span class='symbol'>:default_options</span>
377
+
378
+ <span class='comment'># Renders a content.
379
+ </span> <span class='comment'>#
380
+ </span> <span class='comment'># @param content [Content|String] The content to parse.
381
+ </span> <span class='comment'># @param options [Hash] A list of options for renderer.
382
+ </span> <span class='comment'># @param context [Hash] A context for rendering.
383
+ </span> <span class='kw'>def</span> <span class='id identifier rubyid_render'>render</span><span class='lparen'>(</span><span class='id identifier rubyid_content'>content</span><span class='comma'>,</span> <span class='id identifier rubyid_options'>options</span> <span class='op'>=</span> <span class='lbrace'>{</span><span class='rbrace'>}</span><span class='comma'>,</span> <span class='id identifier rubyid_context'>context</span> <span class='op'>=</span> <span class='lbrace'>{</span><span class='rbrace'>}</span><span class='rparen'>)</span>
384
+ <span class='id identifier rubyid_options'>options</span> <span class='op'>=</span> <span class='id identifier rubyid_sanitize_options'>sanitize_options</span><span class='lparen'>(</span><span class='id identifier rubyid_options'>options</span><span class='rparen'>)</span>
385
+ <span class='id identifier rubyid_context'>context</span> <span class='op'>=</span> <span class='id identifier rubyid_context'>context</span><span class='period'>.</span><span class='id identifier rubyid_is_a?'>is_a?</span><span class='lparen'>(</span><span class='const'>Hash</span><span class='rparen'>)</span> <span class='op'>?</span> <span class='id identifier rubyid_context'>context</span><span class='period'>.</span><span class='id identifier rubyid_symbolize_keys'>symbolize_keys</span> <span class='op'>:</span> <span class='lbrace'>{</span><span class='rbrace'>}</span>
386
+
387
+ <span class='kw'>begin</span>
388
+ <span class='id identifier rubyid_create_pipeline'>create_pipeline</span><span class='lparen'>(</span><span class='id identifier rubyid_options'>options</span><span class='comma'>,</span> <span class='id identifier rubyid_context'>context</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_call'>call</span><span class='lparen'>(</span><span class='id identifier rubyid_get_body'>get_body</span><span class='lparen'>(</span><span class='id identifier rubyid_content'>content</span><span class='comma'>,</span> <span class='id identifier rubyid_options'>options</span><span class='rparen'>)</span><span class='rparen'>)</span><span class='lbracket'>[</span><span class='symbol'>:output</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_to_s'>to_s</span>
389
+ <span class='kw'>rescue</span> <span class='const'>Mbrao</span><span class='op'>::</span><span class='const'>Exceptions</span><span class='op'>::</span><span class='const'>UnavailableLocalization</span> <span class='op'>=&gt;</span> <span class='id identifier rubyid_le'>le</span>
390
+ <span class='id identifier rubyid_raise'>raise</span> <span class='id identifier rubyid_le'>le</span>
391
+ <span class='kw'>rescue</span> <span class='const'>Exception</span> <span class='op'>=&gt;</span> <span class='id identifier rubyid_e'>e</span>
392
+ <span class='id identifier rubyid_raise'>raise</span> <span class='op'>::</span><span class='const'>Mbrao</span><span class='op'>::</span><span class='const'>Exceptions</span><span class='op'>::</span><span class='const'>Rendering</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='id identifier rubyid_e'>e</span><span class='period'>.</span><span class='id identifier rubyid_to_s'>to_s</span><span class='rparen'>)</span>
393
+ <span class='kw'>end</span>
394
+ <span class='kw'>end</span>
395
+
396
+ <span class='comment'># Gets the default pipeline.
397
+ </span> <span class='comment'>#
398
+ </span> <span class='comment'># @return [Array] The default pipeline.
399
+ </span> <span class='kw'>def</span> <span class='id identifier rubyid_default_pipeline'>default_pipeline</span>
400
+ <span class='ivar'>@default_pipeline</span> <span class='op'>||</span> <span class='lbracket'>[</span><span class='lbracket'>[</span><span class='symbol'>:kramdown</span><span class='rbracket'>]</span><span class='comma'>,</span> <span class='lbracket'>[</span><span class='symbol'>:table_of_contents</span><span class='comma'>,</span> <span class='symbol'>:toc</span><span class='rbracket'>]</span><span class='comma'>,</span> <span class='lbracket'>[</span><span class='symbol'>:autolink</span><span class='comma'>,</span> <span class='symbol'>:links</span><span class='rbracket'>]</span><span class='comma'>,</span> <span class='lbracket'>[</span><span class='symbol'>:emoji</span><span class='rbracket'>]</span><span class='comma'>,</span> <span class='lbracket'>[</span><span class='symbol'>:image_max_width</span><span class='rbracket'>]</span><span class='rbracket'>]</span>
401
+ <span class='kw'>end</span>
402
+
403
+ <span class='comment'># Sets the default pipeline.
404
+ </span> <span class='comment'>#
405
+ </span> <span class='comment'># @return [Array] The default pipeline.
406
+ </span> <span class='kw'>def</span> <span class='id identifier rubyid_default_pipeline='>default_pipeline=</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span>
407
+ <span class='ivar'>@default_pipeline</span> <span class='op'>=</span> <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_ensure_array'>ensure_array</span><span class='period'>.</span><span class='id identifier rubyid_collect'>collect</span> <span class='lbrace'>{</span><span class='op'>|</span><span class='id identifier rubyid_v'>v</span><span class='op'>|</span> <span class='id identifier rubyid_v'>v</span><span class='period'>.</span><span class='id identifier rubyid_ensure_array'>ensure_array</span><span class='period'>.</span><span class='id identifier rubyid_flatten'>flatten</span><span class='period'>.</span><span class='id identifier rubyid_compact'>compact</span><span class='period'>.</span><span class='id identifier rubyid_collect'>collect</span> <span class='lbrace'>{</span> <span class='op'>|</span><span class='id identifier rubyid_p'>p</span><span class='op'>|</span> <span class='id identifier rubyid_p'>p</span><span class='period'>.</span><span class='id identifier rubyid_ensure_string'>ensure_string</span><span class='period'>.</span><span class='id identifier rubyid_to_sym'>to_sym</span> <span class='rbrace'>}</span> <span class='rbrace'>}</span>
408
+ <span class='kw'>end</span>
409
+
410
+ <span class='comment'># Gets the default options.
411
+ </span> <span class='comment'>#
412
+ </span> <span class='comment'># @return [Hash] The default options.
413
+ </span> <span class='kw'>def</span> <span class='id identifier rubyid_default_options'>default_options</span>
414
+ <span class='ivar'>@default_options</span> <span class='op'>||</span> <span class='lbrace'>{</span><span class='label'>gfm:</span> <span class='kw'>true</span><span class='comma'>,</span> <span class='label'>asset_root:</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>/</span><span class='tstring_end'>&quot;</span></span><span class='rbrace'>}</span>
415
+ <span class='kw'>end</span>
416
+
417
+ <span class='comment'># Sets the default options.
418
+ </span> <span class='comment'>#
419
+ </span> <span class='comment'># @param value [Object] The new default options.
420
+ </span> <span class='kw'>def</span> <span class='id identifier rubyid_default_options='>default_options=</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span>
421
+ <span class='ivar'>@default_options</span> <span class='op'>=</span> <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_is_a?'>is_a?</span><span class='lparen'>(</span><span class='const'>Hash</span><span class='rparen'>)</span> <span class='op'>?</span> <span class='id identifier rubyid_value'>value</span> <span class='op'>:</span> <span class='lbrace'>{</span><span class='rbrace'>}</span>
422
+ <span class='kw'>end</span>
423
+
424
+ <span class='id identifier rubyid_private'>private</span>
425
+ <span class='comment'># Sanitizes options.
426
+ </span> <span class='comment'>#
427
+ </span> <span class='comment'># @param options [Hash] The options to sanitize.
428
+ </span> <span class='comment'># @return [Hash] The sanitized options.
429
+ </span> <span class='kw'>def</span> <span class='id identifier rubyid_sanitize_options'>sanitize_options</span><span class='lparen'>(</span><span class='id identifier rubyid_options'>options</span><span class='rparen'>)</span>
430
+ <span class='id identifier rubyid_options'>options</span> <span class='op'>=</span> <span class='id identifier rubyid_options'>options</span><span class='period'>.</span><span class='id identifier rubyid_is_a?'>is_a?</span><span class='lparen'>(</span><span class='const'>Hash</span><span class='rparen'>)</span> <span class='op'>?</span> <span class='id identifier rubyid_options'>options</span><span class='period'>.</span><span class='id identifier rubyid_symbolize_keys'>symbolize_keys</span> <span class='op'>:</span> <span class='lbrace'>{</span><span class='rbrace'>}</span>
431
+ <span class='id identifier rubyid_options'>options</span> <span class='op'>=</span> <span class='id identifier rubyid_filter_filters'>filter_filters</span><span class='lparen'>(</span><span class='id identifier rubyid_options'>options</span><span class='rparen'>)</span>
432
+ <span class='id identifier rubyid_options'>options</span><span class='lbracket'>[</span><span class='symbol'>:pipeline_options</span><span class='rbracket'>]</span> <span class='op'>=</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_default_options'>default_options</span><span class='period'>.</span><span class='id identifier rubyid_merge'>merge</span><span class='lparen'>(</span><span class='lparen'>(</span><span class='id identifier rubyid_options'>options</span><span class='lbracket'>[</span><span class='symbol'>:pipeline_options</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_is_a?'>is_a?</span><span class='lparen'>(</span><span class='const'>Hash</span><span class='rparen'>)</span> <span class='op'>?</span> <span class='id identifier rubyid_options'>options</span><span class='lbracket'>[</span><span class='symbol'>:pipeline_options</span><span class='rbracket'>]</span> <span class='op'>:</span> <span class='lbrace'>{</span><span class='rbrace'>}</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_symbolize_keys'>symbolize_keys</span><span class='rparen'>)</span>
433
+
434
+ <span class='id identifier rubyid_options'>options</span>
435
+ <span class='kw'>end</span>
436
+
437
+ <span class='comment'># Get body of a content.
438
+ </span> <span class='comment'>#
439
+ </span> <span class='comment'># @param content [Content|String] The content to sanitize.
440
+ </span> <span class='comment'># @param options [Hash] A list of options for renderer.
441
+ </span> <span class='comment'># @return [Array] The body to parse.
442
+ </span> <span class='kw'>def</span> <span class='id identifier rubyid_get_body'>get_body</span><span class='lparen'>(</span><span class='id identifier rubyid_content'>content</span><span class='comma'>,</span> <span class='id identifier rubyid_options'>options</span><span class='rparen'>)</span>
443
+ <span class='id identifier rubyid_content'>content</span> <span class='op'>=</span> <span class='op'>::</span><span class='const'>Mbrao</span><span class='op'>::</span><span class='const'>Content</span><span class='period'>.</span><span class='id identifier rubyid_create'>create</span><span class='lparen'>(</span><span class='kw'>nil</span><span class='comma'>,</span> <span class='id identifier rubyid_content'>content</span><span class='period'>.</span><span class='id identifier rubyid_ensure_string'>ensure_string</span><span class='rparen'>)</span> <span class='kw'>if</span> <span class='op'>!</span><span class='id identifier rubyid_content'>content</span><span class='period'>.</span><span class='id identifier rubyid_is_a?'>is_a?</span><span class='lparen'>(</span><span class='op'>::</span><span class='const'>Mbrao</span><span class='op'>::</span><span class='const'>Content</span><span class='rparen'>)</span>
444
+ <span class='id identifier rubyid_content'>content</span><span class='period'>.</span><span class='id identifier rubyid_get_body'>get_body</span><span class='lparen'>(</span><span class='id identifier rubyid_options'>options</span><span class='period'>.</span><span class='id identifier rubyid_fetch'>fetch</span><span class='lparen'>(</span><span class='symbol'>:locale</span><span class='comma'>,</span> <span class='op'>::</span><span class='const'>Mbrao</span><span class='op'>::</span><span class='const'>Parser</span><span class='period'>.</span><span class='id identifier rubyid_locale'>locale</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_ensure_string'>ensure_string</span><span class='rparen'>)</span>
445
+ <span class='kw'>end</span>
446
+
447
+ <span class='comment'># Creates the pipeline for rendering.
448
+ </span> <span class='comment'>#
449
+ </span> <span class='comment'># @param options [Hash] A list of options for renderer.
450
+ </span> <span class='comment'># @param context [Hash] A context for rendering.
451
+ </span> <span class='comment'># @return [HTML::Pipeline] The pipeline
452
+ </span> <span class='kw'>def</span> <span class='id identifier rubyid_create_pipeline'>create_pipeline</span><span class='lparen'>(</span><span class='id identifier rubyid_options'>options</span><span class='comma'>,</span> <span class='id identifier rubyid_context'>context</span><span class='rparen'>)</span>
453
+ <span class='op'>::</span><span class='const'>HTML</span><span class='op'>::</span><span class='const'>Pipeline</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='id identifier rubyid_options'>options</span><span class='lbracket'>[</span><span class='symbol'>:pipeline</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_collect'>collect</span> <span class='lbrace'>{</span><span class='op'>|</span><span class='id identifier rubyid_f'>f</span><span class='op'>|</span> <span class='op'>::</span><span class='const'>Mbrao</span><span class='op'>::</span><span class='const'>Parser</span><span class='period'>.</span><span class='id identifier rubyid_find_class'>find_class</span><span class='lparen'>(</span><span class='id identifier rubyid_f'>f</span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>::HTML::Pipeline::%CLASS%Filter</span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span> <span class='kw'>true</span><span class='rparen'>)</span> <span class='rbrace'>}</span><span class='comma'>,</span> <span class='id identifier rubyid_options'>options</span><span class='lbracket'>[</span><span class='symbol'>:pipeline_options</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_merge'>merge</span><span class='lparen'>(</span><span class='id identifier rubyid_context'>context</span><span class='rparen'>)</span><span class='rparen'>)</span>
454
+ <span class='kw'>end</span>
455
+
456
+ <span class='comment'># Filters pipeline filters basing on the options provided.
457
+ </span> <span class='comment'>#
458
+ </span> <span class='comment'># @param options [Hash] The original options.
459
+ </span> <span class='comment'># @return [Hash] The options with the new set of filters.
460
+ </span> <span class='kw'>def</span> <span class='id identifier rubyid_filter_filters'>filter_filters</span><span class='lparen'>(</span><span class='id identifier rubyid_options'>options</span><span class='rparen'>)</span>
461
+ <span class='id identifier rubyid_options'>options</span><span class='lbracket'>[</span><span class='symbol'>:pipeline</span><span class='rbracket'>]</span> <span class='op'>=</span> <span class='id identifier rubyid_get_pipeline'>get_pipeline</span><span class='lparen'>(</span><span class='id identifier rubyid_options'>options</span><span class='rparen'>)</span>
462
+
463
+ <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_default_pipeline'>default_pipeline</span><span class='period'>.</span><span class='id identifier rubyid_each'>each</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_f'>f</span><span class='op'>|</span>
464
+ <span class='id identifier rubyid_options'>options</span><span class='lbracket'>[</span><span class='symbol'>:pipeline</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_delete'>delete</span><span class='lparen'>(</span><span class='id identifier rubyid_f'>f</span><span class='period'>.</span><span class='id identifier rubyid_first'>first</span><span class='rparen'>)</span> <span class='kw'>if</span> <span class='op'>!</span><span class='id identifier rubyid_options'>options</span><span class='period'>.</span><span class='id identifier rubyid_fetch'>fetch</span><span class='lparen'>(</span><span class='id identifier rubyid_f'>f</span><span class='period'>.</span><span class='id identifier rubyid_last'>last</span><span class='comma'>,</span> <span class='kw'>true</span><span class='rparen'>)</span>
465
+ <span class='kw'>end</span>
466
+
467
+ <span class='id identifier rubyid_options'>options</span>
468
+ <span class='kw'>end</span>
469
+
470
+ <span class='comment'># Gets the pipeline for the current options.
471
+ </span> <span class='comment'>#
472
+ </span> <span class='comment'># @param options [Hash] The options to parse.
473
+ </span> <span class='comment'># @return [Array] The pipeline to process.
474
+ </span> <span class='kw'>def</span> <span class='id identifier rubyid_get_pipeline'>get_pipeline</span><span class='lparen'>(</span><span class='id identifier rubyid_options'>options</span><span class='rparen'>)</span>
475
+ <span class='id identifier rubyid_options'>options</span><span class='period'>.</span><span class='id identifier rubyid_fetch'>fetch</span><span class='lparen'>(</span><span class='symbol'>:pipeline</span><span class='comma'>,</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_default_pipeline'>default_pipeline</span><span class='period'>.</span><span class='id identifier rubyid_collect'>collect</span><span class='lparen'>(</span><span class='op'>&amp;</span><span class='symbol'>:first</span><span class='rparen'>)</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_collect'>collect</span><span class='lparen'>(</span><span class='op'>&amp;</span><span class='symbol'>:to_sym</span><span class='rparen'>)</span>
476
+ <span class='kw'>end</span>
477
+ <span class='kw'>end</span></pre>
478
+ </td>
479
+ </tr>
480
+ </table>
481
+ </div>
482
+
483
+
484
+ <span id="default_pipeline=-instance_method"></span>
485
+ <div class="method_details ">
486
+ <h3 class="signature " id="default_pipeline-instance_method">
487
+
488
+ - (<tt>Array</tt>) <strong>default_pipeline</strong>
489
+
490
+
491
+
492
+
493
+
494
+ </h3><div class="docstring">
495
+ <div class="discussion">
496
+ <p>Gets the default pipeline.</p>
497
+
498
+
499
+ </div>
500
+ </div>
501
+ <div class="tags">
502
+
503
+ <p class="tag_title">Returns:</p>
504
+ <ul class="return">
505
+
506
+ <li>
507
+
508
+
509
+ <span class='type'>(<tt>Array</tt>)</span>
510
+
511
+
512
+
513
+ &mdash;
514
+ <div class='inline'><p>The default pipeline.</p>
515
+ </div>
516
+
517
+ </li>
518
+
519
+ </ul>
520
+
521
+ </div><table class="source_code">
522
+ <tr>
523
+ <td>
524
+ <pre class="lines">
525
+
526
+
527
+ 42
528
+ 43
529
+ 44
530
+ 45
531
+ 46
532
+ 47
533
+ 48
534
+ 49
535
+ 50
536
+ 51
537
+ 52
538
+ 53
539
+ 54
540
+ 55
541
+ 56
542
+ 57
543
+ 58
544
+ 59
545
+ 60
546
+ 61
547
+ 62
548
+ 63
549
+ 64
550
+ 65
551
+ 66
552
+ 67
553
+ 68
554
+ 69
555
+ 70
556
+ 71
557
+ 72
558
+ 73
559
+ 74
560
+ 75
561
+ 76
562
+ 77
563
+ 78
564
+ 79
565
+ 80
566
+ 81
567
+ 82
568
+ 83
569
+ 84
570
+ 85
571
+ 86
572
+ 87
573
+ 88
574
+ 89
575
+ 90
576
+ 91
577
+ 92
578
+ 93
579
+ 94
580
+ 95
581
+ 96
582
+ 97
583
+ 98
584
+ 99
585
+ 100
586
+ 101
587
+ 102
588
+ 103
589
+ 104
590
+ 105
591
+ 106
592
+ 107
593
+ 108
594
+ 109
595
+ 110
596
+ 111
597
+ 112
598
+ 113
599
+ 114
600
+ 115
601
+ 116
602
+ 117
603
+ 118
604
+ 119
605
+ 120
606
+ 121
607
+ 122
608
+ 123
609
+ 124
610
+ 125
611
+ 126
612
+ 127
613
+ 128
614
+ 129
615
+ 130
616
+ 131
617
+ 132
618
+ 133
619
+ 134
620
+ 135
621
+ 136
622
+ 137
623
+ 138
624
+ 139
625
+ 140
626
+ 141
627
+ 142
628
+ 143
629
+ 144
630
+ 145</pre>
631
+ </td>
632
+ <td>
633
+ <pre class="code"><span class="info file"># File 'lib/mbrao/rendering_engines/html_pipeline.rb', line 42</span>
634
+
635
+ <span class='kw'>class</span> <span class='const'>HtmlPipeline</span> <span class='op'>&lt;</span> <span class='const'>Mbrao</span><span class='op'>::</span><span class='const'>RenderingEngines</span><span class='op'>::</span><span class='const'>Base</span>
636
+ <span class='id identifier rubyid_attr_accessor'>attr_accessor</span> <span class='symbol'>:default_pipeline</span>
637
+ <span class='id identifier rubyid_attr_accessor'>attr_accessor</span> <span class='symbol'>:default_options</span>
638
+
639
+ <span class='comment'># Renders a content.
640
+ </span> <span class='comment'>#
641
+ </span> <span class='comment'># @param content [Content|String] The content to parse.
642
+ </span> <span class='comment'># @param options [Hash] A list of options for renderer.
643
+ </span> <span class='comment'># @param context [Hash] A context for rendering.
644
+ </span> <span class='kw'>def</span> <span class='id identifier rubyid_render'>render</span><span class='lparen'>(</span><span class='id identifier rubyid_content'>content</span><span class='comma'>,</span> <span class='id identifier rubyid_options'>options</span> <span class='op'>=</span> <span class='lbrace'>{</span><span class='rbrace'>}</span><span class='comma'>,</span> <span class='id identifier rubyid_context'>context</span> <span class='op'>=</span> <span class='lbrace'>{</span><span class='rbrace'>}</span><span class='rparen'>)</span>
645
+ <span class='id identifier rubyid_options'>options</span> <span class='op'>=</span> <span class='id identifier rubyid_sanitize_options'>sanitize_options</span><span class='lparen'>(</span><span class='id identifier rubyid_options'>options</span><span class='rparen'>)</span>
646
+ <span class='id identifier rubyid_context'>context</span> <span class='op'>=</span> <span class='id identifier rubyid_context'>context</span><span class='period'>.</span><span class='id identifier rubyid_is_a?'>is_a?</span><span class='lparen'>(</span><span class='const'>Hash</span><span class='rparen'>)</span> <span class='op'>?</span> <span class='id identifier rubyid_context'>context</span><span class='period'>.</span><span class='id identifier rubyid_symbolize_keys'>symbolize_keys</span> <span class='op'>:</span> <span class='lbrace'>{</span><span class='rbrace'>}</span>
647
+
648
+ <span class='kw'>begin</span>
649
+ <span class='id identifier rubyid_create_pipeline'>create_pipeline</span><span class='lparen'>(</span><span class='id identifier rubyid_options'>options</span><span class='comma'>,</span> <span class='id identifier rubyid_context'>context</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_call'>call</span><span class='lparen'>(</span><span class='id identifier rubyid_get_body'>get_body</span><span class='lparen'>(</span><span class='id identifier rubyid_content'>content</span><span class='comma'>,</span> <span class='id identifier rubyid_options'>options</span><span class='rparen'>)</span><span class='rparen'>)</span><span class='lbracket'>[</span><span class='symbol'>:output</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_to_s'>to_s</span>
650
+ <span class='kw'>rescue</span> <span class='const'>Mbrao</span><span class='op'>::</span><span class='const'>Exceptions</span><span class='op'>::</span><span class='const'>UnavailableLocalization</span> <span class='op'>=&gt;</span> <span class='id identifier rubyid_le'>le</span>
651
+ <span class='id identifier rubyid_raise'>raise</span> <span class='id identifier rubyid_le'>le</span>
652
+ <span class='kw'>rescue</span> <span class='const'>Exception</span> <span class='op'>=&gt;</span> <span class='id identifier rubyid_e'>e</span>
653
+ <span class='id identifier rubyid_raise'>raise</span> <span class='op'>::</span><span class='const'>Mbrao</span><span class='op'>::</span><span class='const'>Exceptions</span><span class='op'>::</span><span class='const'>Rendering</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='id identifier rubyid_e'>e</span><span class='period'>.</span><span class='id identifier rubyid_to_s'>to_s</span><span class='rparen'>)</span>
654
+ <span class='kw'>end</span>
655
+ <span class='kw'>end</span>
656
+
657
+ <span class='comment'># Gets the default pipeline.
658
+ </span> <span class='comment'>#
659
+ </span> <span class='comment'># @return [Array] The default pipeline.
660
+ </span> <span class='kw'>def</span> <span class='id identifier rubyid_default_pipeline'>default_pipeline</span>
661
+ <span class='ivar'>@default_pipeline</span> <span class='op'>||</span> <span class='lbracket'>[</span><span class='lbracket'>[</span><span class='symbol'>:kramdown</span><span class='rbracket'>]</span><span class='comma'>,</span> <span class='lbracket'>[</span><span class='symbol'>:table_of_contents</span><span class='comma'>,</span> <span class='symbol'>:toc</span><span class='rbracket'>]</span><span class='comma'>,</span> <span class='lbracket'>[</span><span class='symbol'>:autolink</span><span class='comma'>,</span> <span class='symbol'>:links</span><span class='rbracket'>]</span><span class='comma'>,</span> <span class='lbracket'>[</span><span class='symbol'>:emoji</span><span class='rbracket'>]</span><span class='comma'>,</span> <span class='lbracket'>[</span><span class='symbol'>:image_max_width</span><span class='rbracket'>]</span><span class='rbracket'>]</span>
662
+ <span class='kw'>end</span>
663
+
664
+ <span class='comment'># Sets the default pipeline.
665
+ </span> <span class='comment'>#
666
+ </span> <span class='comment'># @return [Array] The default pipeline.
667
+ </span> <span class='kw'>def</span> <span class='id identifier rubyid_default_pipeline='>default_pipeline=</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span>
668
+ <span class='ivar'>@default_pipeline</span> <span class='op'>=</span> <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_ensure_array'>ensure_array</span><span class='period'>.</span><span class='id identifier rubyid_collect'>collect</span> <span class='lbrace'>{</span><span class='op'>|</span><span class='id identifier rubyid_v'>v</span><span class='op'>|</span> <span class='id identifier rubyid_v'>v</span><span class='period'>.</span><span class='id identifier rubyid_ensure_array'>ensure_array</span><span class='period'>.</span><span class='id identifier rubyid_flatten'>flatten</span><span class='period'>.</span><span class='id identifier rubyid_compact'>compact</span><span class='period'>.</span><span class='id identifier rubyid_collect'>collect</span> <span class='lbrace'>{</span> <span class='op'>|</span><span class='id identifier rubyid_p'>p</span><span class='op'>|</span> <span class='id identifier rubyid_p'>p</span><span class='period'>.</span><span class='id identifier rubyid_ensure_string'>ensure_string</span><span class='period'>.</span><span class='id identifier rubyid_to_sym'>to_sym</span> <span class='rbrace'>}</span> <span class='rbrace'>}</span>
669
+ <span class='kw'>end</span>
670
+
671
+ <span class='comment'># Gets the default options.
672
+ </span> <span class='comment'>#
673
+ </span> <span class='comment'># @return [Hash] The default options.
674
+ </span> <span class='kw'>def</span> <span class='id identifier rubyid_default_options'>default_options</span>
675
+ <span class='ivar'>@default_options</span> <span class='op'>||</span> <span class='lbrace'>{</span><span class='label'>gfm:</span> <span class='kw'>true</span><span class='comma'>,</span> <span class='label'>asset_root:</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>/</span><span class='tstring_end'>&quot;</span></span><span class='rbrace'>}</span>
676
+ <span class='kw'>end</span>
677
+
678
+ <span class='comment'># Sets the default options.
679
+ </span> <span class='comment'>#
680
+ </span> <span class='comment'># @param value [Object] The new default options.
681
+ </span> <span class='kw'>def</span> <span class='id identifier rubyid_default_options='>default_options=</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span>
682
+ <span class='ivar'>@default_options</span> <span class='op'>=</span> <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_is_a?'>is_a?</span><span class='lparen'>(</span><span class='const'>Hash</span><span class='rparen'>)</span> <span class='op'>?</span> <span class='id identifier rubyid_value'>value</span> <span class='op'>:</span> <span class='lbrace'>{</span><span class='rbrace'>}</span>
683
+ <span class='kw'>end</span>
684
+
685
+ <span class='id identifier rubyid_private'>private</span>
686
+ <span class='comment'># Sanitizes options.
687
+ </span> <span class='comment'>#
688
+ </span> <span class='comment'># @param options [Hash] The options to sanitize.
689
+ </span> <span class='comment'># @return [Hash] The sanitized options.
690
+ </span> <span class='kw'>def</span> <span class='id identifier rubyid_sanitize_options'>sanitize_options</span><span class='lparen'>(</span><span class='id identifier rubyid_options'>options</span><span class='rparen'>)</span>
691
+ <span class='id identifier rubyid_options'>options</span> <span class='op'>=</span> <span class='id identifier rubyid_options'>options</span><span class='period'>.</span><span class='id identifier rubyid_is_a?'>is_a?</span><span class='lparen'>(</span><span class='const'>Hash</span><span class='rparen'>)</span> <span class='op'>?</span> <span class='id identifier rubyid_options'>options</span><span class='period'>.</span><span class='id identifier rubyid_symbolize_keys'>symbolize_keys</span> <span class='op'>:</span> <span class='lbrace'>{</span><span class='rbrace'>}</span>
692
+ <span class='id identifier rubyid_options'>options</span> <span class='op'>=</span> <span class='id identifier rubyid_filter_filters'>filter_filters</span><span class='lparen'>(</span><span class='id identifier rubyid_options'>options</span><span class='rparen'>)</span>
693
+ <span class='id identifier rubyid_options'>options</span><span class='lbracket'>[</span><span class='symbol'>:pipeline_options</span><span class='rbracket'>]</span> <span class='op'>=</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_default_options'>default_options</span><span class='period'>.</span><span class='id identifier rubyid_merge'>merge</span><span class='lparen'>(</span><span class='lparen'>(</span><span class='id identifier rubyid_options'>options</span><span class='lbracket'>[</span><span class='symbol'>:pipeline_options</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_is_a?'>is_a?</span><span class='lparen'>(</span><span class='const'>Hash</span><span class='rparen'>)</span> <span class='op'>?</span> <span class='id identifier rubyid_options'>options</span><span class='lbracket'>[</span><span class='symbol'>:pipeline_options</span><span class='rbracket'>]</span> <span class='op'>:</span> <span class='lbrace'>{</span><span class='rbrace'>}</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_symbolize_keys'>symbolize_keys</span><span class='rparen'>)</span>
694
+
695
+ <span class='id identifier rubyid_options'>options</span>
696
+ <span class='kw'>end</span>
697
+
698
+ <span class='comment'># Get body of a content.
699
+ </span> <span class='comment'>#
700
+ </span> <span class='comment'># @param content [Content|String] The content to sanitize.
701
+ </span> <span class='comment'># @param options [Hash] A list of options for renderer.
702
+ </span> <span class='comment'># @return [Array] The body to parse.
703
+ </span> <span class='kw'>def</span> <span class='id identifier rubyid_get_body'>get_body</span><span class='lparen'>(</span><span class='id identifier rubyid_content'>content</span><span class='comma'>,</span> <span class='id identifier rubyid_options'>options</span><span class='rparen'>)</span>
704
+ <span class='id identifier rubyid_content'>content</span> <span class='op'>=</span> <span class='op'>::</span><span class='const'>Mbrao</span><span class='op'>::</span><span class='const'>Content</span><span class='period'>.</span><span class='id identifier rubyid_create'>create</span><span class='lparen'>(</span><span class='kw'>nil</span><span class='comma'>,</span> <span class='id identifier rubyid_content'>content</span><span class='period'>.</span><span class='id identifier rubyid_ensure_string'>ensure_string</span><span class='rparen'>)</span> <span class='kw'>if</span> <span class='op'>!</span><span class='id identifier rubyid_content'>content</span><span class='period'>.</span><span class='id identifier rubyid_is_a?'>is_a?</span><span class='lparen'>(</span><span class='op'>::</span><span class='const'>Mbrao</span><span class='op'>::</span><span class='const'>Content</span><span class='rparen'>)</span>
705
+ <span class='id identifier rubyid_content'>content</span><span class='period'>.</span><span class='id identifier rubyid_get_body'>get_body</span><span class='lparen'>(</span><span class='id identifier rubyid_options'>options</span><span class='period'>.</span><span class='id identifier rubyid_fetch'>fetch</span><span class='lparen'>(</span><span class='symbol'>:locale</span><span class='comma'>,</span> <span class='op'>::</span><span class='const'>Mbrao</span><span class='op'>::</span><span class='const'>Parser</span><span class='period'>.</span><span class='id identifier rubyid_locale'>locale</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_ensure_string'>ensure_string</span><span class='rparen'>)</span>
706
+ <span class='kw'>end</span>
707
+
708
+ <span class='comment'># Creates the pipeline for rendering.
709
+ </span> <span class='comment'>#
710
+ </span> <span class='comment'># @param options [Hash] A list of options for renderer.
711
+ </span> <span class='comment'># @param context [Hash] A context for rendering.
712
+ </span> <span class='comment'># @return [HTML::Pipeline] The pipeline
713
+ </span> <span class='kw'>def</span> <span class='id identifier rubyid_create_pipeline'>create_pipeline</span><span class='lparen'>(</span><span class='id identifier rubyid_options'>options</span><span class='comma'>,</span> <span class='id identifier rubyid_context'>context</span><span class='rparen'>)</span>
714
+ <span class='op'>::</span><span class='const'>HTML</span><span class='op'>::</span><span class='const'>Pipeline</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='id identifier rubyid_options'>options</span><span class='lbracket'>[</span><span class='symbol'>:pipeline</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_collect'>collect</span> <span class='lbrace'>{</span><span class='op'>|</span><span class='id identifier rubyid_f'>f</span><span class='op'>|</span> <span class='op'>::</span><span class='const'>Mbrao</span><span class='op'>::</span><span class='const'>Parser</span><span class='period'>.</span><span class='id identifier rubyid_find_class'>find_class</span><span class='lparen'>(</span><span class='id identifier rubyid_f'>f</span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>::HTML::Pipeline::%CLASS%Filter</span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span> <span class='kw'>true</span><span class='rparen'>)</span> <span class='rbrace'>}</span><span class='comma'>,</span> <span class='id identifier rubyid_options'>options</span><span class='lbracket'>[</span><span class='symbol'>:pipeline_options</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_merge'>merge</span><span class='lparen'>(</span><span class='id identifier rubyid_context'>context</span><span class='rparen'>)</span><span class='rparen'>)</span>
715
+ <span class='kw'>end</span>
716
+
717
+ <span class='comment'># Filters pipeline filters basing on the options provided.
718
+ </span> <span class='comment'>#
719
+ </span> <span class='comment'># @param options [Hash] The original options.
720
+ </span> <span class='comment'># @return [Hash] The options with the new set of filters.
721
+ </span> <span class='kw'>def</span> <span class='id identifier rubyid_filter_filters'>filter_filters</span><span class='lparen'>(</span><span class='id identifier rubyid_options'>options</span><span class='rparen'>)</span>
722
+ <span class='id identifier rubyid_options'>options</span><span class='lbracket'>[</span><span class='symbol'>:pipeline</span><span class='rbracket'>]</span> <span class='op'>=</span> <span class='id identifier rubyid_get_pipeline'>get_pipeline</span><span class='lparen'>(</span><span class='id identifier rubyid_options'>options</span><span class='rparen'>)</span>
723
+
724
+ <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_default_pipeline'>default_pipeline</span><span class='period'>.</span><span class='id identifier rubyid_each'>each</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_f'>f</span><span class='op'>|</span>
725
+ <span class='id identifier rubyid_options'>options</span><span class='lbracket'>[</span><span class='symbol'>:pipeline</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_delete'>delete</span><span class='lparen'>(</span><span class='id identifier rubyid_f'>f</span><span class='period'>.</span><span class='id identifier rubyid_first'>first</span><span class='rparen'>)</span> <span class='kw'>if</span> <span class='op'>!</span><span class='id identifier rubyid_options'>options</span><span class='period'>.</span><span class='id identifier rubyid_fetch'>fetch</span><span class='lparen'>(</span><span class='id identifier rubyid_f'>f</span><span class='period'>.</span><span class='id identifier rubyid_last'>last</span><span class='comma'>,</span> <span class='kw'>true</span><span class='rparen'>)</span>
726
+ <span class='kw'>end</span>
727
+
728
+ <span class='id identifier rubyid_options'>options</span>
729
+ <span class='kw'>end</span>
730
+
731
+ <span class='comment'># Gets the pipeline for the current options.
732
+ </span> <span class='comment'>#
733
+ </span> <span class='comment'># @param options [Hash] The options to parse.
734
+ </span> <span class='comment'># @return [Array] The pipeline to process.
735
+ </span> <span class='kw'>def</span> <span class='id identifier rubyid_get_pipeline'>get_pipeline</span><span class='lparen'>(</span><span class='id identifier rubyid_options'>options</span><span class='rparen'>)</span>
736
+ <span class='id identifier rubyid_options'>options</span><span class='period'>.</span><span class='id identifier rubyid_fetch'>fetch</span><span class='lparen'>(</span><span class='symbol'>:pipeline</span><span class='comma'>,</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_default_pipeline'>default_pipeline</span><span class='period'>.</span><span class='id identifier rubyid_collect'>collect</span><span class='lparen'>(</span><span class='op'>&amp;</span><span class='symbol'>:first</span><span class='rparen'>)</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_collect'>collect</span><span class='lparen'>(</span><span class='op'>&amp;</span><span class='symbol'>:to_sym</span><span class='rparen'>)</span>
737
+ <span class='kw'>end</span>
738
+ <span class='kw'>end</span></pre>
739
+ </td>
740
+ </tr>
741
+ </table>
742
+ </div>
743
+
744
+ </div>
745
+
746
+
747
+ <div id="instance_method_details" class="method_details_list">
748
+ <h2>Instance Method Details</h2>
749
+
750
+
751
+ <div class="method_details first">
752
+ <h3 class="signature first" id="render-instance_method">
753
+
754
+ - (<tt>Object</tt>) <strong>render</strong>(content, options = {}, context = {})
755
+
756
+
757
+
758
+
759
+
760
+ </h3><div class="docstring">
761
+ <div class="discussion">
762
+ <p>Renders a content.</p>
763
+
764
+
765
+ </div>
766
+ </div>
767
+ <div class="tags">
768
+ <p class="tag_title">Parameters:</p>
769
+ <ul class="param">
770
+
771
+ <li>
772
+
773
+ <span class='name'>content</span>
774
+
775
+
776
+ <span class='type'>(<tt><span class='object_link'><a href="../Content.html" title="Mbrao::Content (class)">Content</a></span>|String</tt>)</span>
777
+
778
+
779
+
780
+ &mdash;
781
+ <div class='inline'><p>The content to parse.</p>
782
+ </div>
783
+
784
+ </li>
785
+
786
+ <li>
787
+
788
+ <span class='name'>options</span>
789
+
790
+
791
+ <span class='type'>(<tt>Hash</tt>)</span>
792
+
793
+
794
+ <em class="default">(defaults to: <tt>{}</tt>)</em>
795
+
796
+
797
+ &mdash;
798
+ <div class='inline'><p>A list of options for renderer.</p>
799
+ </div>
800
+
801
+ </li>
802
+
803
+ <li>
804
+
805
+ <span class='name'>context</span>
806
+
807
+
808
+ <span class='type'>(<tt>Hash</tt>)</span>
809
+
810
+
811
+ <em class="default">(defaults to: <tt>{}</tt>)</em>
812
+
813
+
814
+ &mdash;
815
+ <div class='inline'><p>A context for rendering.</p>
816
+ </div>
817
+
818
+ </li>
819
+
820
+ </ul>
821
+
822
+
823
+ </div><table class="source_code">
824
+ <tr>
825
+ <td>
826
+ <pre class="lines">
827
+
828
+
829
+ 51
830
+ 52
831
+ 53
832
+ 54
833
+ 55
834
+ 56
835
+ 57
836
+ 58
837
+ 59
838
+ 60
839
+ 61
840
+ 62</pre>
841
+ </td>
842
+ <td>
843
+ <pre class="code"><span class="info file"># File 'lib/mbrao/rendering_engines/html_pipeline.rb', line 51</span>
844
+
845
+ <span class='kw'>def</span> <span class='id identifier rubyid_render'>render</span><span class='lparen'>(</span><span class='id identifier rubyid_content'>content</span><span class='comma'>,</span> <span class='id identifier rubyid_options'>options</span> <span class='op'>=</span> <span class='lbrace'>{</span><span class='rbrace'>}</span><span class='comma'>,</span> <span class='id identifier rubyid_context'>context</span> <span class='op'>=</span> <span class='lbrace'>{</span><span class='rbrace'>}</span><span class='rparen'>)</span>
846
+ <span class='id identifier rubyid_options'>options</span> <span class='op'>=</span> <span class='id identifier rubyid_sanitize_options'>sanitize_options</span><span class='lparen'>(</span><span class='id identifier rubyid_options'>options</span><span class='rparen'>)</span>
847
+ <span class='id identifier rubyid_context'>context</span> <span class='op'>=</span> <span class='id identifier rubyid_context'>context</span><span class='period'>.</span><span class='id identifier rubyid_is_a?'>is_a?</span><span class='lparen'>(</span><span class='const'>Hash</span><span class='rparen'>)</span> <span class='op'>?</span> <span class='id identifier rubyid_context'>context</span><span class='period'>.</span><span class='id identifier rubyid_symbolize_keys'>symbolize_keys</span> <span class='op'>:</span> <span class='lbrace'>{</span><span class='rbrace'>}</span>
848
+
849
+ <span class='kw'>begin</span>
850
+ <span class='id identifier rubyid_create_pipeline'>create_pipeline</span><span class='lparen'>(</span><span class='id identifier rubyid_options'>options</span><span class='comma'>,</span> <span class='id identifier rubyid_context'>context</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_call'>call</span><span class='lparen'>(</span><span class='id identifier rubyid_get_body'>get_body</span><span class='lparen'>(</span><span class='id identifier rubyid_content'>content</span><span class='comma'>,</span> <span class='id identifier rubyid_options'>options</span><span class='rparen'>)</span><span class='rparen'>)</span><span class='lbracket'>[</span><span class='symbol'>:output</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_to_s'>to_s</span>
851
+ <span class='kw'>rescue</span> <span class='const'>Mbrao</span><span class='op'>::</span><span class='const'>Exceptions</span><span class='op'>::</span><span class='const'>UnavailableLocalization</span> <span class='op'>=&gt;</span> <span class='id identifier rubyid_le'>le</span>
852
+ <span class='id identifier rubyid_raise'>raise</span> <span class='id identifier rubyid_le'>le</span>
853
+ <span class='kw'>rescue</span> <span class='const'>Exception</span> <span class='op'>=&gt;</span> <span class='id identifier rubyid_e'>e</span>
854
+ <span class='id identifier rubyid_raise'>raise</span> <span class='op'>::</span><span class='const'>Mbrao</span><span class='op'>::</span><span class='const'>Exceptions</span><span class='op'>::</span><span class='const'>Rendering</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='id identifier rubyid_e'>e</span><span class='period'>.</span><span class='id identifier rubyid_to_s'>to_s</span><span class='rparen'>)</span>
855
+ <span class='kw'>end</span>
856
+ <span class='kw'>end</span></pre>
857
+ </td>
858
+ </tr>
859
+ </table>
860
+ </div>
861
+
862
+ </div>
863
+
864
+ </div>
865
+
866
+ <div id="footer">
867
+ Generated on Fri Mar 1 09:13:32 2013 by
868
+ <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
869
+ 0.8.5.2 (ruby-1.9.3).
870
+ </div>
871
+
872
+ </body>
873
+ </html>