redcarpet 3.5.1 → 3.6.1

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