redcarpet 3.5.1 → 3.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3e6ea78031a1e40620168cd57fcbfae06bec5bafabc8f6e600adc552a4fe5b40
4
- data.tar.gz: 658dd33e836daa11effa88e0491d09387963ea349751efd278e9fbdac7026066
3
+ metadata.gz: ff95ccb3cfac7e8785f4e93f3984ee2c86b04008628555b9ab64cbd50886860d
4
+ data.tar.gz: 7daf631354b3e0edb0104387ead39674bdce554dfec90041b0f2c57c4d97621f
5
5
  SHA512:
6
- metadata.gz: b17b0208c25d4e8566fb4a154d0f66e778b702abcf58d1d1227fa2510be421c7496e20fd6402066adba3485778e935b46aff73fd412802eedb89e44470a7ad94
7
- data.tar.gz: 1e1c8dd559979b8bd5f4de2d20e1127b2a964c03a267133c3d9a3703f71bce44a2f4dc2efdb0dc0cc331e0ab779bfad23e9b62af0ffc4ee9078896376bd86865
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/README.markdown CHANGED
@@ -2,8 +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
- [![Dependency Status](https://www.versioneye.com/ruby/redcarpet/badge.svg)](https://www.versioneye.com/ruby/redcarpet)
6
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)
7
7
 
8
8
  Redcarpet is a Ruby library for Markdown processing that smells like
9
9
  butterflies and popcorn.
@@ -258,7 +258,7 @@ end
258
258
  * paragraph(text)
259
259
  * table(header, body)
260
260
  * table_row(content)
261
- * table_cell(content, alignment)
261
+ * table_cell(content, alignment, header)
262
262
 
263
263
  ### Span-level calls
264
264
 
data/ext/redcarpet/html.c CHANGED
@@ -277,6 +277,22 @@ rndr_linebreak(struct buf *ob, void *opaque)
277
277
  return 1;
278
278
  }
279
279
 
280
+ static int html_entity_ahead(const uint8_t *text, size_t start, size_t size) {
281
+ size_t i = start;
282
+
283
+ if (text[i] != '&')
284
+ return 0;
285
+
286
+ for (; i < size; ++i) {
287
+ if (text[i] == ' ')
288
+ return 0;
289
+ else if (text[i] == ';')
290
+ return 1;
291
+ }
292
+
293
+ return 0;
294
+ }
295
+
280
296
  static void
281
297
  rndr_header_anchor(struct buf *out, const struct buf *anchor)
282
298
  {
@@ -293,10 +309,11 @@ rndr_header_anchor(struct buf *out, const struct buf *anchor)
293
309
  while (i < size && a[i] != '>')
294
310
  i++;
295
311
  // skip html entities
296
- } else if (a[i] == '&') {
312
+ } else if (a[i] == '&' && html_entity_ahead(a, i, size)) {
297
313
  while (i < size && a[i] != ';')
298
314
  i++;
299
315
  }
316
+
300
317
  // replace non-ascii or invalid characters with dashes
301
318
  else if (!isascii(a[i]) || strchr(STRIPPED, a[i])) {
302
319
  if (inserted && !stripped)
@@ -0,0 +1,44 @@
1
+ abbr
2
+ address
3
+ article
4
+ aside
5
+ audio
6
+ blockquote
7
+ canvas
8
+ center
9
+ dd
10
+ del
11
+ details
12
+ div
13
+ dl
14
+ fieldset
15
+ figcaption
16
+ figure
17
+ footer
18
+ form
19
+ h1
20
+ h2
21
+ h3
22
+ h4
23
+ h5
24
+ h6
25
+ header
26
+ hgroup
27
+ hr
28
+ iframe
29
+ ins
30
+ math
31
+ nav
32
+ noscript
33
+ ol
34
+ output
35
+ p
36
+ pre
37
+ script
38
+ section
39
+ style
40
+ summary
41
+ table
42
+ tfoot
43
+ ul
44
+ video