redcarpet 3.4.0 → 3.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/CHANGELOG.md +479 -0
- data/CONTRIBUTING.md +33 -0
- data/Gemfile +2 -2
- data/README.markdown +26 -25
- data/ext/redcarpet/autolink.c +0 -1
- data/ext/redcarpet/buffer.h +0 -1
- data/ext/redcarpet/houdini_html_e.c +0 -1
- data/ext/redcarpet/html.c +34 -7
- data/ext/redcarpet/html.h +1 -2
- data/ext/redcarpet/html_block_names.txt +44 -0
- data/ext/redcarpet/html_blocks.h +30 -35
- data/ext/redcarpet/html_smartypants.c +17 -2
- data/ext/redcarpet/markdown.c +51 -20
- data/ext/redcarpet/rc_markdown.c +13 -3
- data/ext/redcarpet/rc_render.c +42 -9
- data/lib/redcarpet/compat.rb +0 -2
- data/lib/redcarpet/render_strip.rb +1 -1
- data/lib/redcarpet.rb +1 -1
- data/redcarpet.gemspec +9 -21
- metadata +17 -45
- data/test/benchmark.rb +0 -24
- data/test/custom_render_test.rb +0 -57
- data/test/fixtures/benchmark.md +0 -232
- data/test/html5_test.rb +0 -82
- data/test/html_render_test.rb +0 -268
- data/test/html_toc_render_test.rb +0 -82
- data/test/markdown_test.rb +0 -406
- data/test/pathological_inputs_test.rb +0 -34
- data/test/redcarpet_bin_test.rb +0 -80
- data/test/redcarpet_compat_test.rb +0 -38
- data/test/safe_render_test.rb +0 -35
- data/test/smarty_html_test.rb +0 -45
- data/test/smarty_pants_test.rb +0 -58
- data/test/stripdown_render_test.rb +0 -61
- data/test/test_helper.rb +0 -47
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: ff95ccb3cfac7e8785f4e93f3984ee2c86b04008628555b9ab64cbd50886860d
|
4
|
+
data.tar.gz: 7daf631354b3e0edb0104387ead39674bdce554dfec90041b0f2c57c4d97621f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b2829bb96f83da4db1e81ab8ff8e22678fc73b2c0a073a84d789d04cb88b84e39da2a2ad4de1ac6229b370368a69828e635af5020a094b73773477fcad118283
|
7
|
+
data.tar.gz: 4ee41dbbb347d5125478d1bca1fc9820bf825fc210bd27b1d2183934a23e7b0acbf5a72bc04445787c4129c73fd3d8d9bb612db1758c14d21b6df21f20752f20
|
data/CHANGELOG.md
ADDED
@@ -0,0 +1,479 @@
|
|
1
|
+
# Changelog
|
2
|
+
|
3
|
+
## Version 3.6.0
|
4
|
+
|
5
|
+
* Avoid warnings running on Ruby 3.2+.
|
6
|
+
|
7
|
+
Refs #721.
|
8
|
+
|
9
|
+
*Jean Boussier*
|
10
|
+
|
11
|
+
* Match fence char and length when matching closing fence in fenced code blocks.
|
12
|
+
|
13
|
+
Fixes #208.
|
14
|
+
|
15
|
+
*Martin Cizek, Orchitech*
|
16
|
+
|
17
|
+
* Consider `<center>` as a block-level element.
|
18
|
+
|
19
|
+
Refs #702.
|
20
|
+
|
21
|
+
*momijizukamori*
|
22
|
+
|
23
|
+
* Properly provide a third argument to the `table_cell` callback indicating
|
24
|
+
whether the current cell is part of the header or not.
|
25
|
+
|
26
|
+
The previous implementation with two parameters is still supported.
|
27
|
+
|
28
|
+
Fixes #604, Refs #605.
|
29
|
+
|
30
|
+
*Mark Lambley*
|
31
|
+
|
32
|
+
* Fix anchor generation on titles with ampersands.
|
33
|
+
|
34
|
+
Fixes #696.
|
35
|
+
|
36
|
+
## Version 3.5.1 (Security)
|
37
|
+
|
38
|
+
* Fix a security vulnerability using `:quote` in combination with the
|
39
|
+
`:escape_html` option.
|
40
|
+
|
41
|
+
Reported by *Johan Smits*.
|
42
|
+
|
43
|
+
|
44
|
+
## Version 3.5.0
|
45
|
+
|
46
|
+
* Avoid mutating the options hash passed to a render object.
|
47
|
+
|
48
|
+
Refs #663.
|
49
|
+
|
50
|
+
*Max Schwenk*
|
51
|
+
|
52
|
+
* Fix a segfault rendering quotes using `StripDown` and the `:quote`
|
53
|
+
option.
|
54
|
+
|
55
|
+
Fixes #639.
|
56
|
+
|
57
|
+
* Fix `warning: instance variable @options not initialized` when
|
58
|
+
running under verbose mode (`-w`, `$VERBOSE = true`).
|
59
|
+
|
60
|
+
* Fix SmartyPants single quotes right after a link. For example:
|
61
|
+
|
62
|
+
~~~markdown
|
63
|
+
[John](http://john.doe)'s cat
|
64
|
+
~~~
|
65
|
+
|
66
|
+
Will now properly converts `'` to a right single quote (i.e. `’`).
|
67
|
+
|
68
|
+
Fixes #624.
|
69
|
+
|
70
|
+
* Remove the `rel` and `rev` attributes from the output generated
|
71
|
+
for footnotes as they don't pass the HTML 5 validation.
|
72
|
+
|
73
|
+
Fixes #536.
|
74
|
+
|
75
|
+
* Automatically enable the `fenced_code_blocks` option passing a
|
76
|
+
`HTML_TOC` object to the `Markdown` object's constructor since
|
77
|
+
some languages rely on the sharp to comment code.
|
78
|
+
|
79
|
+
Fixes #451.
|
80
|
+
|
81
|
+
* Allow passing `Range` objects to the `nesting_level` option to have
|
82
|
+
a higher level of customization for table of contents:
|
83
|
+
|
84
|
+
~~~ruby
|
85
|
+
Redcarpet::Render::HTML_TOC.new(nesting_level: 2..5)
|
86
|
+
~~~
|
87
|
+
|
88
|
+
Fixes #519.
|
89
|
+
|
90
|
+
## Version 3.4.0
|
91
|
+
|
92
|
+
* Rely on djb2 hashing generating anchors with non-ASCII chars.
|
93
|
+
|
94
|
+
Fix issue [#538](https://github.com/vmg/redcarpet/issues/538).
|
95
|
+
|
96
|
+
*Alexey Kopytko*, *namusyaka*
|
97
|
+
|
98
|
+
* Added suppport for HTML 5 `details` and `summary` tags.
|
99
|
+
|
100
|
+
Fix issue [#578](https://github.com/vmg/redcarpet/issues/578).
|
101
|
+
|
102
|
+
*James Edwards-Jones*
|
103
|
+
|
104
|
+
* Multiple single quote pairs are parsed correctly with SmartyPants.
|
105
|
+
|
106
|
+
Fix issue [#549](https://github.com/vmg/redcarpet/issues/549).
|
107
|
+
|
108
|
+
*Jan Jędrychowski*
|
109
|
+
|
110
|
+
* Table headers don't require a minimum of three dashes anymore; a
|
111
|
+
single one can be used for each row.
|
112
|
+
|
113
|
+
* Remove escaped entities from `HTML` render table of contents'
|
114
|
+
ids to be consistent with the `HTML_TOC` render.
|
115
|
+
|
116
|
+
Fix issue [#529](https://github.com/vmg/redcarpet/issues/529).
|
117
|
+
|
118
|
+
* Remove periods at the end of URLs when autolinking to make sure
|
119
|
+
that links at the end of a sentence get properly generated.
|
120
|
+
|
121
|
+
Fix issue [#465](https://github.com/vmg/redcarpet/issues/465).
|
122
|
+
|
123
|
+
* Expose the Markdown and rendering options through a `Hash` inside
|
124
|
+
the `@options` instance variable for custom render objects.
|
125
|
+
|
126
|
+
* Avoid escaping ampersands in href links.
|
127
|
+
|
128
|
+
*Nolan Evans*
|
129
|
+
|
130
|
+
## Version 3.3.4
|
131
|
+
|
132
|
+
* Fix `bufprintf` to correctly work on Windows MinGW-w64 so strings
|
133
|
+
are properly written to the buffer.
|
134
|
+
|
135
|
+
*Kenichi Saita*
|
136
|
+
|
137
|
+
* Fix the header anchor normalization by skipping non-ASCII chars
|
138
|
+
and not calling tolower because this leads to invalid UTF-8 byte
|
139
|
+
sequences in the HTML output. (tolower is not locale-aware)
|
140
|
+
|
141
|
+
*Clemens Gruber*
|
142
|
+
|
143
|
+
## Version 3.3.3
|
144
|
+
|
145
|
+
* Fix a memory leak instantiating a `Redcarpet::Render::Base` object.
|
146
|
+
|
147
|
+
*Oleg Dashevskii*
|
148
|
+
|
149
|
+
* Fix the `StripDown` renderer to handle the `:highlight` option.
|
150
|
+
|
151
|
+
*Itay Grudev*
|
152
|
+
|
153
|
+
* The `StripDown` renderer handles tables if the `tables` extension is
|
154
|
+
enabled.
|
155
|
+
|
156
|
+
*amnesia7*
|
157
|
+
|
158
|
+
* Fix Smarty Pants to avoid fraction conversions when there are several
|
159
|
+
numbers separated with slashes (e.g. for a date).
|
160
|
+
|
161
|
+
*Sam Saffron*
|
162
|
+
|
163
|
+
## Version 3.3.2
|
164
|
+
|
165
|
+
* Fix a potential security issue in the HTML renderer
|
166
|
+
(Thanks to Giancarlo Canales Barreto for the heads up)
|
167
|
+
|
168
|
+
## Version 3.3.1
|
169
|
+
|
170
|
+
* Include the `Redcarpet::CLI`'s file in the gemspec to make it
|
171
|
+
available when downloading.
|
172
|
+
|
173
|
+
## Version 3.3.0
|
174
|
+
|
175
|
+
* Fix the stripping of surrounding characters that should be removed
|
176
|
+
during anchor generation.
|
177
|
+
|
178
|
+
* Provide a `Redcarpet::CLI` class to create custom binary files.
|
179
|
+
|
180
|
+
Relying on Ruby's OptionParser, it's now straightforward to add new
|
181
|
+
options, rely on custom render objects or handle differently the
|
182
|
+
rendering of the provided files.
|
183
|
+
|
184
|
+
* Undeprecate the compatibility layer for the old RedCloth API.
|
185
|
+
|
186
|
+
This layer actually ease the support of libraries supporting different
|
187
|
+
Markdown processors.
|
188
|
+
|
189
|
+
* Strip out `style` tags at the HTML-block rendering level when the
|
190
|
+
`:no_styles` options is enabled ; previously they were only removed
|
191
|
+
inside paragraphs.
|
192
|
+
|
193
|
+
* Avoid parsing images when the given URL isn't safe and the
|
194
|
+
`:safe_links_only` option is enabled.
|
195
|
+
|
196
|
+
*Alex Serban*
|
197
|
+
|
198
|
+
* Avoid parsing references inside fenced code blocks so they are
|
199
|
+
now kept in the code snippet.
|
200
|
+
|
201
|
+
*David Waller*
|
202
|
+
|
203
|
+
* Avoid escaping table-of-contents' headers by default. A new
|
204
|
+
`:escape_html` option is now available for the `HTML_TOC` object
|
205
|
+
if there are security concerns.
|
206
|
+
|
207
|
+
* Add the `lang-` prefix in front of the language's name when using
|
208
|
+
`:prettify` along with `:fenced_code_blocks`.
|
209
|
+
|
210
|
+
* Non-alphanumeric chars are now stripped out from generated anchors
|
211
|
+
(along the lines of Active Support's `#parameterize` method).
|
212
|
+
|
213
|
+
## Version 3.2.3
|
214
|
+
|
215
|
+
* Avoid rewinding content of a previous inline when autolinking is
|
216
|
+
enabled.
|
217
|
+
|
218
|
+
*Daniel LeCheminant*
|
219
|
+
|
220
|
+
* Fix escaping of forward slashes with the `Safe` render object (add a
|
221
|
+
missing semi-colon).
|
222
|
+
|
223
|
+
## Version 3.2.2
|
224
|
+
|
225
|
+
* Consider `script` as a block-level element so it doesn't get included
|
226
|
+
inside a paragraph.
|
227
|
+
|
228
|
+
## Version 3.2.1
|
229
|
+
|
230
|
+
* Load `RedcarpetCompat` when requiring Redcarpet for the sake of
|
231
|
+
backward compatibility.
|
232
|
+
|
233
|
+
*Loren Segal*
|
234
|
+
|
235
|
+
## Version 3.2.0
|
236
|
+
|
237
|
+
* Add a `Safe` renderer to deal with users' input. The `escape_html`
|
238
|
+
and `safe_links_only` options are turned on by default.
|
239
|
+
|
240
|
+
Moreover, the `block_code` callback removes the tag's class since
|
241
|
+
the user can basically set anything with the vanilla one.
|
242
|
+
|
243
|
+
*Robin Dupret*
|
244
|
+
|
245
|
+
* HTML5 block-level tags are now recognized
|
246
|
+
|
247
|
+
*silverhammermba*
|
248
|
+
|
249
|
+
* The `StripDown` render object now displays the URL of links
|
250
|
+
along with the text.
|
251
|
+
|
252
|
+
*Robin Dupret*
|
253
|
+
|
254
|
+
* The RedCloth API compatibility layer is now deprecated.
|
255
|
+
|
256
|
+
*Robin Dupret*
|
257
|
+
|
258
|
+
* A hyphen and an equal should not be converted to heading.
|
259
|
+
|
260
|
+
*namusyaka*
|
261
|
+
|
262
|
+
* Fix emphasis character escape sequence detection while mid-emphasis.
|
263
|
+
|
264
|
+
*jcheatham*
|
265
|
+
|
266
|
+
* Add `=` to the whitelist of escaped chars so it can be used inside
|
267
|
+
highlighted snippets.
|
268
|
+
|
269
|
+
*jcheatham*
|
270
|
+
|
271
|
+
* Convert trailing single quotes to curly quotes. For example,
|
272
|
+
`Road Trippin'` now converts to `Road Trippin’`.
|
273
|
+
|
274
|
+
*Kevin Chen*
|
275
|
+
|
276
|
+
* Allow in-page links (e.g. `[headline](#headline)`) when `:safe_links_only` is set.
|
277
|
+
|
278
|
+
*jomo*
|
279
|
+
|
280
|
+
* Enable emphasis inside of sentences in multi-byte languages when
|
281
|
+
`:no_intra_emphasis` is set.
|
282
|
+
|
283
|
+
*Chun-wei Kuo*
|
284
|
+
|
285
|
+
* Avoid making `:no_intra_emphasis` only match spaces. This allows
|
286
|
+
using emphasizes inside quotes when the option is enabled for
|
287
|
+
instance.
|
288
|
+
|
289
|
+
*Jason Webb* and *BJ Homer*
|
290
|
+
|
291
|
+
* The StripDown renderer handles image tags now.
|
292
|
+
|
293
|
+
## Version 3.1.2
|
294
|
+
|
295
|
+
* Remove the yielding of anchors in the `header` callback. This was
|
296
|
+
a breaking change between 3.0 and 3.1 as the method's arity changed.
|
297
|
+
|
298
|
+
## Version 3.1.1
|
299
|
+
|
300
|
+
* Fix a segfault when parsing text with headers.
|
301
|
+
|
302
|
+
## Version 3.1.0
|
303
|
+
|
304
|
+
* Yield the anchor of the headers
|
305
|
+
|
306
|
+
Using the `header` callback, it's now possible to get access to the
|
307
|
+
humanized generated id to easily keep tracking of the tree of headers
|
308
|
+
or simply handle the duplicate values easily.
|
309
|
+
|
310
|
+
Since the `HTML_TOC` and `HTML` objects both have this callback, it's
|
311
|
+
advisable to define a module and mix it in these objects to avoid
|
312
|
+
code duplication.
|
313
|
+
|
314
|
+
*Robin Dupret*
|
315
|
+
|
316
|
+
* Allow using tabs between a reference's colon and its link
|
317
|
+
|
318
|
+
Fix issue [#337](https://github.com/vmg/redcarpet/issues/337)
|
319
|
+
|
320
|
+
*Juan Guerrero*
|
321
|
+
|
322
|
+
* Make ordered lists preceded by paragraph parsed with `:lax_spacing`
|
323
|
+
|
324
|
+
Previously, enabling the `:lax_spacing` option, if a paragraph was
|
325
|
+
followed by an ordered list it was unparsed and was part of the
|
326
|
+
paragraph but this is no more the case.
|
327
|
+
|
328
|
+
*Robin Dupret*
|
329
|
+
|
330
|
+
* Feed the gemspec into ExtensionTask so that we can pre-compile.
|
331
|
+
ie. `rake native gem`
|
332
|
+
|
333
|
+
*Todd Edwards*
|
334
|
+
|
335
|
+
* Revert lax indent of less than 4 characters after list items
|
336
|
+
|
337
|
+
Follow the standard to detect when new paragraph is outside last item.
|
338
|
+
Fixes [issue #111](https://github.com/vmg/redcarpet/issues/111).
|
339
|
+
|
340
|
+
*Eric Bréchemier*
|
341
|
+
|
342
|
+
* Fix code blocks' classes when using Google code prettify
|
343
|
+
|
344
|
+
When using the the `:prettify` option and specifying the
|
345
|
+
language name, the generated code block's class had a missing
|
346
|
+
space.
|
347
|
+
|
348
|
+
*Simonini*
|
349
|
+
|
350
|
+
* Add `-v`/`--version` and `-h` flags to commandline redcarpet
|
351
|
+
|
352
|
+
*Lukas Stabe*
|
353
|
+
|
354
|
+
* Add optional quote support through the `:quote` option. Render
|
355
|
+
quotations marks to `q` HTML tag.
|
356
|
+
|
357
|
+
This is a `"quote"`.
|
358
|
+
|
359
|
+
*Anatol Broder*
|
360
|
+
|
361
|
+
* Ensure inline markup in titles is correctly stripped when generating
|
362
|
+
headers' anchor.
|
363
|
+
|
364
|
+
*Robin Dupret*
|
365
|
+
|
366
|
+
* Revert the unescaping behavior on comments
|
367
|
+
|
368
|
+
This behavior doesn't follow the conformance suite.
|
369
|
+
|
370
|
+
*Robin Dupret*
|
371
|
+
|
372
|
+
* Add optional footnotes support
|
373
|
+
|
374
|
+
Add PHP-Markdown style footnotes through the `:footnotes` option.
|
375
|
+
|
376
|
+
*Ben Dolman, Adam Florin, microjo, brief*
|
377
|
+
|
378
|
+
* Enable GitHub style anchors for headers
|
379
|
+
|
380
|
+
Passing the `with_toc_data` option to a `HTML` render object now
|
381
|
+
generates GitHub style anchors.
|
382
|
+
|
383
|
+
*Matt Rogers*
|
384
|
+
|
385
|
+
* Allow to set a maximum rendering level for HTML_TOC
|
386
|
+
|
387
|
+
Allow the user to pass a `nesting_level` option when instantiating a
|
388
|
+
new HTML_TOC render object in order to limit the nesting level in the
|
389
|
+
generated table of content. For example:
|
390
|
+
|
391
|
+
~~~ruby
|
392
|
+
Redcarpet::Markdown.new(Redcarpet::Render::HTML_TOC.new(nesting_level: 2))
|
393
|
+
~~~
|
394
|
+
|
395
|
+
*Robin Dupret*
|
396
|
+
|
397
|
+
## Version 3.0.0
|
398
|
+
|
399
|
+
* Remove support for Ruby 1.8.x *Matt Rogers & Robin Dupret*
|
400
|
+
|
401
|
+
* Avoid escaping for HTML comments *Robin Dupret*
|
402
|
+
|
403
|
+
* Make emphasis wrapped inside parenthesis parsed *Robin Dupret*
|
404
|
+
|
405
|
+
* Remove the Sundown submodule *Robin Dupret*
|
406
|
+
|
407
|
+
* Fix FTP uris identified as emails *Robin Dupret*
|
408
|
+
|
409
|
+
* Add optional highlight support *Sam Soffes*
|
410
|
+
|
411
|
+
This is `==highlighted==`.
|
412
|
+
|
413
|
+
* Ensure nested parenthesis are handled into links *Robin Dupret*
|
414
|
+
|
415
|
+
* Ensure nested code spans put in emphasis work correctly *Robin Dupret*
|
416
|
+
|
417
|
+
## Version 2.3.0
|
418
|
+
|
419
|
+
* Add a `:disable_indented_code_blocks` option *Dmitriy Kiriyenko*
|
420
|
+
|
421
|
+
* Fix issue [#57](https://github.com/vmg/redcarpet/issues/57) *Mike Morearty*
|
422
|
+
|
423
|
+
* Ensure new lines characters are inserted when using the StripDown
|
424
|
+
render. *Robin Dupret*
|
425
|
+
|
426
|
+
* Mark all symbols as hidden except the main entry point *Tom Hughes*
|
427
|
+
|
428
|
+
This avoids conflicts with other gems that may have some of the
|
429
|
+
same symbols, such as escape_utils which also uses houdini.
|
430
|
+
|
431
|
+
* Remove unnecessary function pointer *Sam Soffes*
|
432
|
+
|
433
|
+
* Add optional underline support *Sam Soffes*
|
434
|
+
|
435
|
+
This is `*italic*` and this is `_underline_` when enabled.
|
436
|
+
|
437
|
+
* Test that links with quotes work *Michael Grosser*
|
438
|
+
|
439
|
+
* Adding a prettyprint class for google-code-prettify *Joel Rosenberg*
|
440
|
+
|
441
|
+
* Remove unused C macros *Matt Rogers*
|
442
|
+
|
443
|
+
* Remove 'extern' definition for Init_redcarpet_rndr() *Matt Rogers*
|
444
|
+
|
445
|
+
* Remove Gemfile.lock from the gemspec *Matt Rogers*
|
446
|
+
|
447
|
+
* Removed extra unused test statement. *Slipp D. Thompson*
|
448
|
+
|
449
|
+
* Use test-unit gem to get some red/green output when running tests
|
450
|
+
*Michael Grosser*
|
451
|
+
|
452
|
+
* Remove a deprecation warning and update Gemfile.lock *Robin Dupret*
|
453
|
+
|
454
|
+
* Added contributing file *Brent Beer*
|
455
|
+
|
456
|
+
* For tests for libxml2 > 2.8 *strzibny*
|
457
|
+
|
458
|
+
* SmartyPants: Preserve single `backticks` in HTML *Mike Morearty*
|
459
|
+
|
460
|
+
When SmartyPants is processing HTML, single `backticks` should be left
|
461
|
+
intact. Previously they were being deleted.
|
462
|
+
|
463
|
+
* Removed and ignored Gemfile.lock *Ryan McGeary*
|
464
|
+
|
465
|
+
* Added support for org-table syntax *Ryan McGeary*
|
466
|
+
|
467
|
+
Adds support for using a plus (+) as an intersection character instead of
|
468
|
+
requiring pipes (|). The emacs org-mode table syntax automatically manages
|
469
|
+
ascii tables, but uses pluses for line intersections.
|
470
|
+
|
471
|
+
* Ignore /tmp directory *Ryan McGeary*
|
472
|
+
|
473
|
+
* Add redcarpet_ prefix for `stack_*` functions *Kenta Murata*
|
474
|
+
|
475
|
+
* Mark any html_attributes has held by a renderer as used *Tom Hughes*
|
476
|
+
|
477
|
+
* Add Rubinius to the list of tested implementations *Gibheer*
|
478
|
+
|
479
|
+
* Add a changelog file
|
data/CONTRIBUTING.md
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
## Submitting a Pull Request
|
2
|
+
|
3
|
+
1. [Fork the repository.][fork]
|
4
|
+
2. [Create a topic branch.][branch]
|
5
|
+
3. Check which version of Ruby is installed on your machine with `ruby -v`.
|
6
|
+
The list of supported Ruby versions is listed in [.travis.yml][travis_yml].
|
7
|
+
Set up one of these versions; use of [RVM][rvm] is recommended to switch
|
8
|
+
easily between different versions.
|
9
|
+
4. [Install bundler.][bundler]
|
10
|
+
5. Make sure to have the `tidy` command on your system:
|
11
|
+
|
12
|
+
* `apt-get install tidy`
|
13
|
+
* `yum install tidy`
|
14
|
+
* `pacman -S tidyhtml`
|
15
|
+
|
16
|
+
6. Check that unit tests pass with `rake test`.
|
17
|
+
7. Write a failing test to capture existing bug or lack of feature.
|
18
|
+
8. Run `rake test` to verify that test fails.
|
19
|
+
9. Implement your feature or bug fix.
|
20
|
+
10. Ensure tests pass.
|
21
|
+
11. If it's a new feature or a bug fix, please add an entry to the changelog file.
|
22
|
+
12. Add, commit, and push your changes.
|
23
|
+
13. [Submit a pull request.][pr]
|
24
|
+
14. You will get some feedback and may need to push additional commits
|
25
|
+
with more fixes to the same branch; this will update your pull request
|
26
|
+
automatically.
|
27
|
+
|
28
|
+
[branch]: http://git-scm.com/book/en/Git-Branching-Branching-Workflows#Topic-Branches
|
29
|
+
[bundler]: http://bundler.io
|
30
|
+
[fork]: https://help.github.com/articles/fork-a-repo
|
31
|
+
[pr]: https://help.github.com/articles/using-pull-requests
|
32
|
+
[rvm]: https://rvm.io
|
33
|
+
[travis_yml]: https://github.com/vmg/redcarpet/blob/master/.travis.yml
|
data/Gemfile
CHANGED
data/README.markdown
CHANGED
@@ -2,7 +2,8 @@ Redcarpet is written with sugar, spice and everything nice
|
|
2
2
|
============================================================
|
3
3
|
|
4
4
|
[![Build Status](https://travis-ci.org/vmg/redcarpet.svg?branch=master)](https://travis-ci.org/vmg/redcarpet)
|
5
|
-
[![
|
5
|
+
[![Help Contribute to Open Source](https://www.codetriage.com/vmg/redcarpet/badges/users.svg)](https://www.codetriage.com/vmg/redcarpet)
|
6
|
+
[![Gem Version](https://badge.fury.io/rb/redcarpet.svg)](https://badge.fury.io/rb/redcarpet)
|
6
7
|
|
7
8
|
Redcarpet is a Ruby library for Markdown processing that smells like
|
8
9
|
butterflies and popcorn.
|
@@ -45,10 +46,10 @@ output.
|
|
45
46
|
The `Redcarpet::Markdown` object is encouraged to be instantiated once with the
|
46
47
|
required settings, and reused between parses.
|
47
48
|
|
48
|
-
|
49
|
+
~~~~ ruby
|
49
50
|
# Initializes a Markdown parser
|
50
51
|
markdown = Redcarpet::Markdown.new(renderer, extensions = {})
|
51
|
-
|
52
|
+
~~~~
|
52
53
|
|
53
54
|
Here, the `renderer` variable refers to a renderer object, inheriting
|
54
55
|
from `Redcarpet::Render::Base`. If the given object has not been
|
@@ -59,10 +60,10 @@ Unlike in the RedCloth API, the text to render is passed as an argument
|
|
59
60
|
and not stored inside the `Markdown` instance, to encourage reusability.
|
60
61
|
Example:
|
61
62
|
|
62
|
-
|
63
|
+
~~~~ ruby
|
63
64
|
markdown.render("This is *bongos*, indeed.")
|
64
65
|
# => "<p>This is <em>bongos</em>, indeed.</p>"
|
65
|
-
|
66
|
+
~~~~
|
66
67
|
|
67
68
|
You can also specify a hash containing the Markdown extensions which the
|
68
69
|
parser will identify. The following extensions are accepted:
|
@@ -119,9 +120,9 @@ within the document (e.g. `[^1]: This is a footnote.`).
|
|
119
120
|
|
120
121
|
Example:
|
121
122
|
|
122
|
-
|
123
|
+
~~~~ ruby
|
123
124
|
markdown = Redcarpet::Markdown.new(Redcarpet::Render::HTML, autolink: true, tables: true)
|
124
|
-
|
125
|
+
~~~~
|
125
126
|
|
126
127
|
Darling, I packed you a couple renderers for lunch
|
127
128
|
--------------------------------------------------
|
@@ -136,9 +137,9 @@ All the rendering flags that previously applied only to HTML output have
|
|
136
137
|
now been moved to the `Redcarpet::Render::HTML` class, and may be enabled when
|
137
138
|
instantiating the renderer:
|
138
139
|
|
139
|
-
|
140
|
+
~~~~ ruby
|
140
141
|
Redcarpet::Render::HTML.new(render_options = {})
|
141
|
-
|
142
|
+
~~~~
|
142
143
|
|
143
144
|
Initializes an HTML renderer. The following flags are available:
|
144
145
|
|
@@ -172,9 +173,9 @@ Markdown document had newlines (by default, Markdown ignores these newlines).
|
|
172
173
|
|
173
174
|
Example:
|
174
175
|
|
175
|
-
|
176
|
+
~~~~ ruby
|
176
177
|
renderer = Redcarpet::Render::HTML.new(no_links: true, hard_wrap: true)
|
177
|
-
|
178
|
+
~~~~
|
178
179
|
|
179
180
|
|
180
181
|
The `HTML` renderer has an alternate version, `Redcarpet::Render::HTML_TOC`,
|
@@ -182,8 +183,8 @@ which will output a table of contents in HTML based on the headers of the
|
|
182
183
|
Markdown document.
|
183
184
|
|
184
185
|
When instantiating this render object, you can optionally pass a `nesting_level`
|
185
|
-
option which takes an integer and allows you to make it render only
|
186
|
-
|
186
|
+
option which takes an integer or a range and allows you to make it render only
|
187
|
+
headers at certain levels.
|
187
188
|
|
188
189
|
Redcarpet also includes a plaintext renderer, `Redcarpet::Render::StripDown`, that
|
189
190
|
strips out all the formatting:
|
@@ -205,7 +206,7 @@ And you can even cook your own
|
|
205
206
|
Custom renderers are created by inheriting from an existing renderer. The
|
206
207
|
built-in renderers, `HTML` and `XHTML` may be extended as such:
|
207
208
|
|
208
|
-
|
209
|
+
~~~~ ruby
|
209
210
|
# Create a custom renderer that sets a custom class for block-quotes.
|
210
211
|
class CustomRender < Redcarpet::Render::HTML
|
211
212
|
def block_quote(quote)
|
@@ -213,18 +214,18 @@ class CustomRender < Redcarpet::Render::HTML
|
|
213
214
|
end
|
214
215
|
end
|
215
216
|
|
216
|
-
markdown = Redcarpet::Markdown.new(
|
217
|
-
|
217
|
+
markdown = Redcarpet::Markdown.new(CustomRender, fenced_code_blocks: true)
|
218
|
+
~~~~
|
218
219
|
|
219
220
|
But new renderers can also be created from scratch by extending the abstract
|
220
221
|
base class `Redcarpet::Render::Base` (see `lib/redcarpet/render_man.rb` for
|
221
222
|
an example implementation of a Manpage renderer):
|
222
223
|
|
223
|
-
|
224
|
+
~~~~ ruby
|
224
225
|
class ManPage < Redcarpet::Render::Base
|
225
226
|
# you get the drill -- keep going from here
|
226
227
|
end
|
227
|
-
|
228
|
+
~~~~
|
228
229
|
|
229
230
|
The following instance methods may be implemented by the renderer:
|
230
231
|
|
@@ -257,7 +258,7 @@ end
|
|
257
258
|
* paragraph(text)
|
258
259
|
* table(header, body)
|
259
260
|
* table_row(content)
|
260
|
-
* table_cell(content, alignment)
|
261
|
+
* table_cell(content, alignment, header)
|
261
262
|
|
262
263
|
### Span-level calls
|
263
264
|
|
@@ -312,7 +313,7 @@ or after the rendering process begins:
|
|
312
313
|
* postprocess(full_document)
|
313
314
|
|
314
315
|
You can look at
|
315
|
-
["How to extend the Redcarpet 2 Markdown library?"](http://dev.af83.com/2012/02/27/howto-extend-the-redcarpet2-markdown-lib.html)
|
316
|
+
["How to extend the Redcarpet 2 Markdown library?"](https://web.archive.org/web/20170505231254/http://dev.af83.com/2012/02/27/howto-extend-the-redcarpet2-markdown-lib.html)
|
316
317
|
for some more explanations.
|
317
318
|
|
318
319
|
Also, now our Pants are much smarter
|
@@ -337,7 +338,7 @@ end
|
|
337
338
|
|
338
339
|
# Standalone
|
339
340
|
Redcarpet::Render::SmartyPants.render("<p>Oh SmartyPants, you're so crazy...</p>")
|
340
|
-
|
341
|
+
~~~~
|
341
342
|
|
342
343
|
SmartyPants works on top of already-rendered HTML, and will ignore replacements
|
343
344
|
inside the content of HTML tags and inside specific HTML blocks such as
|
@@ -362,16 +363,16 @@ renderer-independent, the results will be completely unreliable!
|
|
362
363
|
Still, if major forces (let's say, tornadoes or other natural disasters) force you
|
363
364
|
to keep a Markdown-compatibility layer, Redcarpet also supports this:
|
364
365
|
|
365
|
-
|
366
|
+
~~~~ ruby
|
366
367
|
require 'redcarpet/compat'
|
367
|
-
|
368
|
+
~~~~
|
368
369
|
|
369
370
|
Requiring the compatibility library will declare a `Markdown` class with the
|
370
371
|
classical RedCloth API, e.g.
|
371
372
|
|
372
|
-
|
373
|
+
~~~~ ruby
|
373
374
|
Markdown.new('this is my text').to_html
|
374
|
-
|
375
|
+
~~~~
|
375
376
|
|
376
377
|
This class renders 100% standards compliant Markdown with 0 extensions. Nada.
|
377
378
|
Don't even try to enable extensions with a compatibility layer, because
|
data/ext/redcarpet/autolink.c
CHANGED
data/ext/redcarpet/buffer.h
CHANGED