rdiscount 2.1.6 → 2.1.7

Sign up to get free protection for your applications and to get access to all the features.
data/BUILDING CHANGED
@@ -20,7 +20,8 @@ the rake gather task to copy discount source files into the ext/ directory:
20
20
  Submodule 'discount' (git://github.com/davidfstr/discount.git) registered for path 'discount'
21
21
  Cloning into discount...
22
22
  $ cd discount
23
- $ ./configure.sh --with-fenced-code --with-github-tags
23
+ $ ./configure.sh --with-fenced-code --with-github-tags --with-dl=both
24
+ $ make # ensure it compiles
24
25
  $ cd ..
25
26
  $ rake gather
26
27
  $ rake build
@@ -88,7 +89,7 @@ You should also look for RDiscount-specific bugs & feature requests in the
88
89
  GitHub tracker and fix a few.
89
90
 
90
91
  If any bugs were fixed or features added, be sure to rerun the
91
- release tests mentioned above.
92
+ release tests mentioned above. And don't forget to add new tests!
92
93
 
93
94
  Update the CHANGELOG.
94
95
 
@@ -8,7 +8,7 @@ passes the [Markdown 1.0 test suite][2].
8
8
 
9
9
  CODE: `git clone git://github.com/davidfstr/rdiscount.git`
10
10
  HOME: <http://dafoster.net/projects/rdiscount/>
11
- DOCS: <http://rdoc.info/github/davidfstr/rdiscount/RDiscount>
11
+ DOCS: <http://rdoc.info/github/davidfstr/rdiscount/master/RDiscount>
12
12
  BUGS: <http://github.com/davidfstr/rdiscount/issues>
13
13
 
14
14
  Discount was developed by [David Loren Parsons][3]. The Ruby extension
@@ -1 +1 @@
1
- 2.1.6
1
+ 2.1.7
@@ -13,6 +13,10 @@
13
13
  /* include - and _ as acceptable characters in HTML tag names */
14
14
  #define WITH_GITHUB_TAGS 1
15
15
 
16
+ /* enable discount and PHP Markdown Extra definition lists */
17
+ #define USE_EXTRA_DL 1
18
+ #define USE_DISCOUNT_DL 1
19
+
16
20
  /* these are setup by extconf.rb */
17
21
  #if HAVE_RANDOM
18
22
  #define COINTOSS() (random()&1)
@@ -73,6 +73,10 @@ isthisspace(MMIOT *f, int i)
73
73
  {
74
74
  int c = peek(f, i);
75
75
 
76
+ if ( c == EOF )
77
+ return 1;
78
+ if ( c & 0x80 )
79
+ return 0;
76
80
  return isspace(c) || (c < ' ');
77
81
  }
78
82
 
@@ -1582,11 +1586,17 @@ printblock(Paragraph *pp, MMIOT *f)
1582
1586
 
1583
1587
 
1584
1588
  static void
1585
- printcode(Line *t, MMIOT *f)
1589
+ printcode(Line *t, char *lang, MMIOT *f)
1586
1590
  {
1587
1591
  int blanks;
1588
1592
 
1589
- Qstring("<pre><code>", f);
1593
+ Qstring("<pre><code", f);
1594
+ if (lang) {
1595
+ Qstring(" class=\"", f);
1596
+ Qstring(lang, f);
1597
+ Qstring("\"", f);
1598
+ }
1599
+ Qstring(">", f);
1590
1600
  for ( blanks = 0; t ; t = t->next ) {
1591
1601
  if ( S(t->text) > t->dle ) {
1592
1602
  while ( blanks ) {
@@ -1699,7 +1709,7 @@ display(Paragraph *p, MMIOT *f)
1699
1709
  break;
1700
1710
 
1701
1711
  case CODE:
1702
- printcode(p->text, f);
1712
+ printcode(p->text, p->lang, f);
1703
1713
  break;
1704
1714
 
1705
1715
  case QUOTE:
@@ -177,6 +177,9 @@ splitline(Line *t, int cutpoint)
177
177
  }
178
178
 
179
179
  #define UNCHECK(l) ((l)->flags &= ~CHECKED)
180
+ #define UNLESS_FENCED(t) if (fenced) { \
181
+ other = 1; l->count += (c == ' ' ? 0 : -1); \
182
+ } else { t; }
180
183
 
181
184
  /*
182
185
  * walk a line, seeing if it's any of half a dozen interesting regular
@@ -188,8 +191,8 @@ checkline(Line *l)
188
191
  int eol, i;
189
192
  int dashes = 0, spaces = 0,
190
193
  equals = 0, underscores = 0,
191
- stars = 0, tildes = 0,
192
- backticks = 0;
194
+ stars = 0, tildes = 0, other = 0,
195
+ backticks = 0, fenced = 0;
193
196
 
194
197
  l->flags |= CHECKED;
195
198
  l->kind = chk_text;
@@ -206,16 +209,19 @@ checkline(Line *l)
206
209
  if ( c != ' ' ) l->count++;
207
210
 
208
211
  switch (c) {
209
- case '-': dashes = 1; break;
210
- case ' ': spaces = 1; break;
212
+ case '-': UNLESS_FENCED(dashes = 1); break;
213
+ case ' ': UNLESS_FENCED(spaces = 1); break;
211
214
  case '=': equals = 1; break;
212
- case '_': underscores = 1; break;
215
+ case '_': UNLESS_FENCED(underscores = 1); break;
213
216
  case '*': stars = 1; break;
214
217
  #if WITH_FENCED_CODE
215
- case '~': tildes = 1; break;
216
- case '`': backticks = 1; break;
218
+ case '~': if (other) return; fenced = 1; tildes = 1; break;
219
+ case '`': if (other) return; fenced = 1; backticks = 1; break;
217
220
  #endif
218
- default: return;
221
+ default:
222
+ other = 1;
223
+ l->count--;
224
+ if (!fenced) return;
219
225
  }
220
226
  }
221
227
 
@@ -638,6 +644,14 @@ fencedcodeblock(ParagraphRoot *d, Line **ptr)
638
644
  if ( iscodefence(r->next, first->count, first->kind) ) {
639
645
  (*ptr) = r->next->next;
640
646
  ret = Pp(d, first->next, CODE);
647
+ if (S(first->text) - first->count > 0) {
648
+ char *lang_attr = T(first->text) + first->count;
649
+ while ( *lang_attr != 0 && *lang_attr == ' ' ) lang_attr++;
650
+ ret->lang = strdup(lang_attr);
651
+ }
652
+ else {
653
+ ret->lang = 0;
654
+ }
641
655
  ___mkd_freeLine(first);
642
656
  ___mkd_freeLine(r->next);
643
657
  r->next = 0;
@@ -49,6 +49,7 @@ typedef struct paragraph {
49
49
  struct paragraph *down; /* recompiled contents of this paragraph */
50
50
  struct line *text; /* all the text in this paragraph */
51
51
  char *ident; /* %id% tag for QUOTE */
52
+ char *lang; /* lang attribute for CODE */
52
53
  enum { WHITESPACE=0, CODE, QUOTE, MARKUP,
53
54
  HTML, STYLE, DL, UL, OL, AL, LISTITEM,
54
55
  HDR, HR, TABLE, SOURCE } typ;
@@ -51,6 +51,8 @@ ___mkd_freeParagraph(Paragraph *p)
51
51
  ___mkd_freeLines(p->text);
52
52
  if (p->ident)
53
53
  free(p->ident);
54
+ if (p->lang)
55
+ free(p->lang);
54
56
  free(p);
55
57
  }
56
58
 
data/ext/tags.c CHANGED
@@ -26,6 +26,9 @@ mkd_define_tag(char *id, int selfclose)
26
26
  * either the standard or extra tag tables.
27
27
  */
28
28
  if ( !(p = mkd_search_tags(id, strlen(id))) ) {
29
+ /* extratags could be deallocated */
30
+ if ( S(extratags) == 0 )
31
+ CREATE(extratags);
29
32
  p = &EXPAND(extratags);
30
33
  p->id = id;
31
34
  p->size = strlen(id);
@@ -24,7 +24,7 @@
24
24
  # end
25
25
  #
26
26
  class RDiscount
27
- VERSION = '2.1.6'
27
+ VERSION = '2.1.7'
28
28
 
29
29
  # Original Markdown formatted text.
30
30
  attr_reader :text
@@ -93,6 +93,8 @@ class RDiscount
93
93
  # * <tt>:autolink</tt> - Greedily urlify links.
94
94
  # * <tt>:safelink</tt> - Do not make links for unknown URL types.
95
95
  # * <tt>:no_pseudo_protocols</tt> - Do not process pseudo-protocols.
96
+ # * <tt>:no_superscript</tt> - Disable superscript processing.
97
+ # * <tt>:no_strikethrough</tt> - Disable strikethrough processing.
96
98
  #
97
99
  def initialize(text, *extensions)
98
100
  @text = text
@@ -1,8 +1,8 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'rdiscount'
3
- s.version = '2.1.6'
3
+ s.version = '2.1.7'
4
4
  s.summary = "Fast Implementation of Gruber's Markdown in C"
5
- s.date = '2013-05-28'
5
+ s.date = '2013-10-13'
6
6
  s.email = 'davidfstr@gmail.com'
7
7
  s.homepage = 'http://dafoster.net/projects/rdiscount/'
8
8
  s.authors = ["Ryan Tomayko", "David Loren Parsons", "Andrew White", "David Foster"]
@@ -204,7 +204,7 @@ EOS
204
204
  assert_equal "<pre><code>line 1\n\nline 2\n</code></pre>\n", rd.to_html
205
205
  end
206
206
 
207
- def test_that_pandoc_code_blocks_work
207
+ def test_that_pandoc_code_blocks_work
208
208
  rd = RDiscount.new(<<EOS)
209
209
  ~~~
210
210
  line 1
@@ -214,4 +214,32 @@ line 2
214
214
  EOS
215
215
  assert_equal "<pre><code>line 1\n\nline 2\n</code></pre>\n", rd.to_html
216
216
  end
217
+
218
+ def test_that_discount_definition_lists_work
219
+ rd = RDiscount.new(<<EOS)
220
+ =tag1=
221
+ =tag2=
222
+ data.
223
+ EOS
224
+ assert_equal <<EOS, rd.to_html
225
+ <dl>
226
+ <dt>tag1</dt>
227
+ <dt>tag2</dt>
228
+ <dd>data.</dd>
229
+ </dl>
230
+ EOS
231
+ end
232
+
233
+ def test_that_php_definition_lists_work
234
+ rd = RDiscount.new(<<EOS)
235
+ tag1
236
+ : data
237
+ EOS
238
+ assert_equal <<EOS, rd.to_html
239
+ <dl>
240
+ <dt>tag1</dt>
241
+ <dd>data</dd>
242
+ </dl>
243
+ EOS
244
+ end
217
245
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rdiscount
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.6
4
+ version: 2.1.7
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -12,7 +12,7 @@ authors:
12
12
  autorequire:
13
13
  bindir: bin
14
14
  cert_chain: []
15
- date: 2013-05-28 00:00:00.000000000 Z
15
+ date: 2013-10-13 00:00:00.000000000 Z
16
16
  dependencies: []
17
17
  description:
18
18
  email: davidfstr@gmail.com