redcarpet 1.8.2 → 1.9.0

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of redcarpet might be problematic. Click here for more details.

data/ext/markdown.c CHANGED
@@ -1102,13 +1102,11 @@ parse_paragraph(struct buf *ob, struct render *rndr, char *data, size_t size)
1102
1102
  if (is_empty(data + i, size - i) || (level = is_headerline(data + i, size - i)) != 0)
1103
1103
  break;
1104
1104
 
1105
- /* HTML blocks should not nest inside the paragraph, even if they
1106
- * are not separated by a blank line; we run `parse_htmlblock` without
1107
- * actually generating any output, to make sure that this is indeed
1108
- * a HTML block */
1109
- if (data[i] == '<' && rndr->make.blockhtml && parse_htmlblock(ob, rndr, data + i, size - i, 0)) {
1110
- end = i;
1111
- break;
1105
+ if (rndr->ext_flags & MKDEXT_LAX_HTML_BLOCKS) {
1106
+ if (data[i] == '<' && rndr->make.blockhtml && parse_htmlblock(ob, rndr, data + i, size - i, 0)) {
1107
+ end = i;
1108
+ break;
1109
+ }
1112
1110
  }
1113
1111
 
1114
1112
  if (data[i] == '#' || is_hrule(data + i, size - i)) {
@@ -1438,7 +1436,7 @@ parse_atxheader(struct buf *ob, struct render *rndr, char *data, size_t size)
1438
1436
  /* htmlblock_end • checking end of HTML block : </tag>[ \t]*\n[ \t*]\n */
1439
1437
  /* returns the length on match, 0 otherwise */
1440
1438
  static size_t
1441
- htmlblock_end(struct html_tag *tag, char *data, size_t size)
1439
+ htmlblock_end(struct html_tag *tag, struct render *rndr, char *data, size_t size)
1442
1440
  {
1443
1441
  size_t i, w;
1444
1442
 
@@ -1458,14 +1456,13 @@ htmlblock_end(struct html_tag *tag, char *data, size_t size)
1458
1456
  i += w;
1459
1457
  w = 0;
1460
1458
 
1461
-
1462
- #ifdef UPSKIRT_NEWLINE_AFTER_TAGS
1463
- if (i < size && (w = is_empty(data + i, size - i)) == 0)
1464
- return 0; /* non-blank line after tag line */
1465
- #else
1466
- if (i < size)
1467
- w = is_empty(data + i, size - i);
1468
- #endif
1459
+ if (rndr->ext_flags & MKDEXT_LAX_HTML_BLOCKS) {
1460
+ if (i < size)
1461
+ w = is_empty(data + i, size - i);
1462
+ } else {
1463
+ if (i < size && (w = is_empty(data + i, size - i)) == 0)
1464
+ return 0; /* non-blank line after tag line */
1465
+ }
1469
1466
 
1470
1467
  return i + w;
1471
1468
  }
@@ -1533,19 +1530,18 @@ parse_htmlblock(struct buf *ob, struct render *rndr, char *data, size_t size, in
1533
1530
  /* followed by a blank line */
1534
1531
  i = 1;
1535
1532
  found = 0;
1536
- #if 0
1533
+
1537
1534
  while (i < size) {
1538
1535
  i += 1;
1539
1536
  while (i < size && !(data[i - 2] == '\n'
1540
1537
  && data[i - 1] == '<' && data[i] == '/'))
1541
1538
  i += 1;
1542
1539
  if (i + 2 + curtag->size >= size) break;
1543
- j = htmlblock_end(curtag, data + i - 1, size - i + 1);
1540
+ j = htmlblock_end(curtag, rndr, data + i - 1, size - i + 1);
1544
1541
  if (j) {
1545
1542
  i += j - 1;
1546
1543
  found = 1;
1547
1544
  break; } }
1548
- #endif
1549
1545
 
1550
1546
  /* if not found, trying a second pass looking for indented match */
1551
1547
  /* but not if tag is "ins" or "del" (following original Markdown.pl) */
@@ -1559,7 +1555,7 @@ parse_htmlblock(struct buf *ob, struct render *rndr, char *data, size_t size, in
1559
1555
  if (i + 2 + curtag->size >= size)
1560
1556
  break;
1561
1557
 
1562
- j = htmlblock_end(curtag, data + i - 1, size - i + 1);
1558
+ j = htmlblock_end(curtag, rndr, data + i - 1, size - i + 1);
1563
1559
 
1564
1560
  if (j) {
1565
1561
  i += j - 1;
data/ext/markdown.h CHANGED
@@ -21,9 +21,6 @@
21
21
 
22
22
  #include "buffer.h"
23
23
 
24
- /* Require a blank newline after HTML tags */
25
- #define UPSKIRT_NEWLINE_AFTER_TAGS
26
-
27
24
  /********************
28
25
  * TYPE DEFINITIONS *
29
26
  ********************/
@@ -42,6 +39,7 @@ enum mkd_extensions {
42
39
  MKDEXT_FENCED_CODE = (1 << 2),
43
40
  MKDEXT_AUTOLINK = (1 << 3),
44
41
  MKDEXT_STRIKETHROUGH = (1 << 4),
42
+ MKDEXT_LAX_HTML_BLOCKS = (1 << 5),
45
43
  };
46
44
 
47
45
  /* mkd_renderer • functions for rendering parsed data */
data/ext/redcarpet.c CHANGED
@@ -67,6 +67,9 @@ static void rb_redcarpet__get_flags(VALUE ruby_obj,
67
67
  if (rb_funcall(ruby_obj, rb_intern("strikethrough"), 0) == Qtrue)
68
68
  extensions |= MKDEXT_STRIKETHROUGH;
69
69
 
70
+ if (rb_funcall(ruby_obj, rb_intern("lax_htmlblock"), 0) == Qtrue)
71
+ extensions |= MKDEXT_LAX_HTML_BLOCKS;
72
+
70
73
  *enabled_extensions_p = extensions;
71
74
  *render_flags_p = render_flags;
72
75
  }
data/lib/redcarpet.rb CHANGED
@@ -26,7 +26,7 @@
26
26
  # end
27
27
  #
28
28
  class Redcarpet
29
- VERSION = '1.8.2'
29
+ VERSION = '1.9.0'
30
30
 
31
31
  # Original Markdown formatted text.
32
32
  attr_reader :text
@@ -70,6 +70,9 @@ class Redcarpet
70
70
  # Enable PHP-Markdown fenced code extension
71
71
  attr_accessor :fenced_code
72
72
 
73
+ # Allow HTML blocks inside of paragraphs without being surrounded by newlines
74
+ attr_accessor :lax_htmlblock
75
+
73
76
  def initialize(text, *extensions)
74
77
  @text = text
75
78
  extensions.each { |e| send("#{e}=", true) }
data/redcarpet.gemspec CHANGED
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'redcarpet'
3
- s.version = '1.8.2'
3
+ s.version = '1.9.0'
4
4
  s.summary = "Ruby bindings for libupskirt"
5
5
  s.description = 'A fast and safe Markdown to (X)HTML parser'
6
6
  s.date = '2011-04-18'
@@ -131,8 +131,8 @@ class MarkdownTest < Test::Unit::TestCase
131
131
  def test_para_before_block_html_should_not_wrap_in_p_tag
132
132
  markdown = Redcarpet.new(
133
133
  "Things to watch out for\n" +
134
- "<ul>\n<li>Blah</li>\n</ul>\n"
135
- )
134
+ "<ul>\n<li>Blah</li>\n</ul>\n", :lax_htmlblock)
135
+
136
136
  assert_equal "<p>Things to watch out for</p>\n\n" +
137
137
  "<ul>\n<li>Blah</li>\n</ul>\n",
138
138
  markdown.to_html
@@ -168,8 +168,8 @@ EOS
168
168
 
169
169
  def test_strikethrough_flag_works
170
170
  text = "this is ~some~ striked ~~text~~"
171
- assert Redcarpet.new(text).to_html !~ /text-decoration:line-through;/
172
- assert Redcarpet.new(text, :strikethrough).to_html =~ /text-decoration:line-through;/
171
+ assert Redcarpet.new(text).to_html !~ /<del/
172
+ assert Redcarpet.new(text, :strikethrough).to_html =~ /<del/
173
173
  end
174
174
 
175
175
  def test_that_fenced_flag_works
@@ -196,7 +196,7 @@ This is ~~striked through~~ test
196
196
  EOS
197
197
  assert rd.tables
198
198
  assert rd.to_html =~ /<table/
199
- assert rd.to_html =~ /text-decoration:line-through;/
199
+ assert rd.to_html =~ /<del/
200
200
  end
201
201
 
202
202
  def test_that_headers_are_linkable
metadata CHANGED
@@ -5,9 +5,9 @@ version: !ruby/object:Gem::Version
5
5
  prerelease: false
6
6
  segments:
7
7
  - 1
8
- - 8
9
- - 2
10
- version: 1.8.2
8
+ - 9
9
+ - 0
10
+ version: 1.9.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - "Natacha Port\xC3\xA9"