rdiscount 2.1.7.1 → 2.1.8

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ce73e86e0c677aec5b90f677554315d1f41360fb
4
- data.tar.gz: 43f35ed25f2f76ed84658b14906ce6992da09adc
3
+ metadata.gz: 405bc946f3603de05c87ad440e64d3b22f111991
4
+ data.tar.gz: f6dcc0125d0eb194721a3f4979bccad2b6afc69e
5
5
  SHA512:
6
- metadata.gz: 66d53cd220bb328d307080b70c1ff1396621f7aeec66bc4322700f0b13c6ece1939661d0b3c1a3d8eac326253eadb713453677b6435e2561c0f6b78c3b76c308
7
- data.tar.gz: 8d96c19be797605273e153b05fa71d6ba9e9867f6312e4372239dde6f4bda6f7f2f6e8d81a6404fbe717f395ecaf0321cb6aeb1b5be20dbfc33b8930e3b6e699
6
+ metadata.gz: b7573a6ccf9a830cff5f4768bc3d21625d189f88f93f7b1ed35bcc9c1cb1636b22013c8354d19f4b2d135568f96e4bd7072a0462eef28aa64c94566933f03305
7
+ data.tar.gz: 4b88d0299ed378916b70b5159a96092062c22760ebb8fdd3fd98a519d5a528a7f40d652a29f450a9c6c4c006b380d944b234303267620eb6493b3f6be9a71589
data/Rakefile CHANGED
@@ -8,7 +8,7 @@ task :default => :test
8
8
  # Ruby Extension
9
9
  # ==========================================================
10
10
 
11
- DLEXT = Config::MAKEFILE_CONFIG['DLEXT']
11
+ DLEXT = RbConfig::MAKEFILE_CONFIG['DLEXT']
12
12
  RUBYDIGEST = Digest::MD5.hexdigest(`ruby --version`)
13
13
 
14
14
  file "ext/ruby-#{RUBYDIGEST}" do |f|
@@ -1 +1 @@
1
- 2.1.7
1
+ 2.1.8
@@ -22,7 +22,7 @@
22
22
  * of html has been generated.
23
23
  *
24
24
  * It should create MarkdownTest_1.0 (and _1.0.3)
25
- * compatable emphasis for non-pathological cases
25
+ * compatible emphasis for non-pathological cases
26
26
  * and it should fail in a standards-compliant way
27
27
  * when someone attempts to feed it junk.
28
28
  *
@@ -38,6 +38,16 @@ push(char *bfr, int size, MMIOT *f)
38
38
  }
39
39
 
40
40
 
41
+ /*
42
+ * push a character into the generator input buffer
43
+ */
44
+ static void
45
+ pushc(char c, MMIOT *f)
46
+ {
47
+ EXPAND(f->in) = c;
48
+ }
49
+
50
+
41
51
  /* look <i> characters ahead of the cursor.
42
52
  */
43
53
  static inline int
@@ -207,7 +217,7 @@ ___mkd_reparse(char *bfr, int size, int flags, MMIOT *f, char *esc)
207
217
  sub.esc = f->esc;
208
218
 
209
219
  push(bfr, size, &sub);
210
- EXPAND(sub.in) = 0;
220
+ pushc(0, &sub);
211
221
  S(sub.in)--;
212
222
 
213
223
  text(&sub);
@@ -262,7 +272,7 @@ puturl(char *s, int size, MMIOT *f, int display)
262
272
  Qstring("%22", f);
263
273
  else if ( isalnum(c) || ispunct(c) || (display && isspace(c)) )
264
274
  Qchar(c, f);
265
- else if ( c == 003 ) /* untokenize ^C */
275
+ else if ( c == MKD_EOLN ) /* untokenize hard return */
266
276
  Qstring(" ", f);
267
277
  else
268
278
  Qprintf(f, "%%%02X", c);
@@ -618,7 +628,7 @@ extra_linky(MMIOT *f, Cstring text, Footnote *ref)
618
628
  ___mkd_reparse(T(text), S(text), linkt.flags, f, 0);
619
629
  else {
620
630
  ref->flags |= REFERENCED;
621
- ref->refnumber = ++ f->reference;
631
+ ref->refnumber = ++ f->footnotes->reference;
622
632
  Qprintf(f, "<sup id=\"%sref:%d\"><a href=\"#%s:%d\" rel=\"footnote\">%d</a></sup>",
623
633
  p_or_nothing(f), ref->refnumber,
624
634
  p_or_nothing(f), ref->refnumber, ref->refnumber);
@@ -731,8 +741,9 @@ linkylinky(int image, MMIOT *f)
731
741
  S(key.tag) = S(name);
732
742
  }
733
743
 
734
- if ( ref = bsearch(&key, T(*f->footnotes), S(*f->footnotes),
735
- sizeof key, (stfu)__mkd_footsort) ) {
744
+ if ( ref = bsearch(&key, T(f->footnotes->note),
745
+ S(f->footnotes->note),
746
+ sizeof key, (stfu)__mkd_footsort) ) {
736
747
  if ( extra_footnote )
737
748
  status = extra_linky(f,name,ref);
738
749
  else
@@ -774,8 +785,12 @@ static void
774
785
  mangle(char *s, int len, MMIOT *f)
775
786
  {
776
787
  while ( len-- > 0 ) {
788
+ #if DEBIAN_GLITCH
789
+ Qprintf(f, "&#02d;", *((unsigned char*)(s++)) );
790
+ #else
777
791
  Qstring("&#", f);
778
792
  Qprintf(f, COINTOSS() ? "x%02x;" : "%02d;", *((unsigned char*)(s++)) );
793
+ #endif
779
794
  }
780
795
  }
781
796
 
@@ -837,7 +852,7 @@ code(MMIOT *f, char *s, int length)
837
852
  int i,c;
838
853
 
839
854
  for ( i=0; i < length; i++ )
840
- if ( (c = s[i]) == 003) /* ^C: expand back to 2 spaces */
855
+ if ( (c = s[i]) == MKD_EOLN) /* ^C: expand back to 2 spaces */
841
856
  Qstring(" ", f);
842
857
  else if ( c == '\\' && (i < length-1) && escaped(f, s[i+1]) )
843
858
  cputc(s[++i], f);
@@ -1044,13 +1059,14 @@ maybe_autolink(MMIOT *f)
1044
1059
 
1045
1060
  /* greedily scan forward for the end of a legitimate link.
1046
1061
  */
1047
- for ( size=0; (c=peek(f, size+1)) != EOF; size++ )
1062
+ for ( size=0; (c=peek(f, size+1)) != EOF; size++ ) {
1048
1063
  if ( c == '\\' ) {
1049
1064
  if ( peek(f, size+2) != EOF )
1050
1065
  ++size;
1051
1066
  }
1052
- else if ( isspace(c) || strchr("'\"()[]{}<>`", c) )
1067
+ else if ( isspace(c) || strchr("'\"()[]{}<>`", c) || c == MKD_EOLN )
1053
1068
  break;
1069
+ }
1054
1070
 
1055
1071
  if ( (size > 1) && process_possible_link(f, size) ) {
1056
1072
  shift(f, size);
@@ -1243,7 +1259,8 @@ text(MMIOT *f)
1243
1259
  switch (c) {
1244
1260
  case 0: break;
1245
1261
 
1246
- case 3: Qstring(tag_text(f) ? " " : "<br/>", f);
1262
+ case MKD_EOLN:
1263
+ Qstring(tag_text(f) ? " " : "<br/>", f);
1247
1264
  break;
1248
1265
 
1249
1266
  case '>': if ( tag_text(f) )
@@ -1567,13 +1584,14 @@ printblock(Paragraph *pp, MMIOT *f)
1567
1584
  && T(t->text)[S(t->text)-2] == ' '
1568
1585
  && T(t->text)[S(t->text)-1] == ' ' ) {
1569
1586
  push(T(t->text), S(t->text)-2, f);
1570
- push("\003\n", 2, f);
1587
+ pushc(MKD_EOLN, f);
1588
+ pushc('\n', f);
1571
1589
  }
1572
1590
  else {
1573
1591
  ___mkd_tidy(&t->text);
1574
1592
  push(T(t->text), S(t->text), f);
1575
1593
  if ( t->next )
1576
- push("\n", 1, f);
1594
+ pushc('\n', f);
1577
1595
  }
1578
1596
  }
1579
1597
  t = t->next;
@@ -1758,14 +1776,14 @@ mkd_extra_footnotes(MMIOT *m)
1758
1776
  int j, i;
1759
1777
  Footnote *t;
1760
1778
 
1761
- if ( m->reference == 0 )
1779
+ if ( m->footnotes->reference == 0 )
1762
1780
  return;
1763
1781
 
1764
1782
  Csprintf(&m->out, "\n<div class=\"footnotes\">\n<hr/>\n<ol>\n");
1765
1783
 
1766
- for ( i=1; i <= m->reference; i++ ) {
1767
- for ( j=0; j < S(*m->footnotes); j++ ) {
1768
- t = &T(*m->footnotes)[j];
1784
+ for ( i=1; i <= m->footnotes->reference; i++ ) {
1785
+ for ( j=0; j < S(m->footnotes->note); j++ ) {
1786
+ t = &T(m->footnotes->note)[j];
1769
1787
  if ( (t->refnumber == i) && (t->flags & REFERENCED) ) {
1770
1788
  Csprintf(&m->out, "<li id=\"%s:%d\">\n<p>",
1771
1789
  p_or_nothing(m), t->refnumber);
@@ -177,9 +177,14 @@ splitline(Line *t, int cutpoint)
177
177
  }
178
178
 
179
179
  #define UNCHECK(l) ((l)->flags &= ~CHECKED)
180
- #define UNLESS_FENCED(t) if (fenced) { \
180
+
181
+ #ifdef WITH_FENCED_CODE
182
+ # define UNLESS_FENCED(t) if (fenced) { \
181
183
  other = 1; l->count += (c == ' ' ? 0 : -1); \
182
184
  } else { t; }
185
+ #else
186
+ # define UNLESS_FENCED(t) t;
187
+ #endif
183
188
 
184
189
  /*
185
190
  * walk a line, seeing if it's any of half a dozen interesting regular
@@ -530,8 +535,7 @@ islist(Line *t, int *clip, DWORD flags, int *list_type)
530
535
  strtoul(T(t->text)+t->dle, &q, 10);
531
536
  if ( (q > T(t->text)+t->dle) && (q == T(t->text) + (j-1)) ) {
532
537
  j = nextnonblank(t,j);
533
- /* *clip = j; */
534
- *clip = (j > 4) ? 4 : j;
538
+ *clip = j;
535
539
  *list_type = OL;
536
540
  return AL;
537
541
  }
@@ -847,6 +851,12 @@ listitem(Paragraph *p, int indent, DWORD flags, linefn check)
847
851
  UNCHECK(t);
848
852
  t->dle = mkd_firstnonblank(t);
849
853
 
854
+ /* even though we had to trim a long leader off this item,
855
+ * the indent for trailing paragraphs is still 4...
856
+ */
857
+ if (indent > 4) {
858
+ indent = 4;
859
+ }
850
860
  if ( (q = skipempty(t->next)) == 0 ) {
851
861
  ___mkd_freeLineRange(t,q);
852
862
  return 0;
@@ -998,7 +1008,7 @@ addfootnote(Line *p, MMIOT* f)
998
1008
  int c;
999
1009
  Line *np = p->next;
1000
1010
 
1001
- Footnote *foot = &EXPAND(*f->footnotes);
1011
+ Footnote *foot = &EXPAND(f->footnotes->note);
1002
1012
 
1003
1013
  CREATE(foot->tag);
1004
1014
  CREATE(foot->link);
@@ -1013,6 +1023,7 @@ addfootnote(Line *p, MMIOT* f)
1013
1023
  j = nextnonblank(p, j+2);
1014
1024
 
1015
1025
  if ( (f->flags & MKD_EXTRA_FOOTNOTE) && (T(foot->tag)[0] == '^') ) {
1026
+ /* need to consume all lines until non-indented block? */
1016
1027
  while ( j < S(p->text) )
1017
1028
  EXPAND(foot->title) = T(p->text)[j++];
1018
1029
  goto skip_to_end;
@@ -1320,13 +1331,14 @@ mkd_compile(Document *doc, DWORD flags)
1320
1331
  doc->ctx->flags = flags & USER_FLAGS;
1321
1332
  CREATE(doc->ctx->in);
1322
1333
  doc->ctx->footnotes = malloc(sizeof doc->ctx->footnotes[0]);
1323
- CREATE(*doc->ctx->footnotes);
1334
+ doc->ctx->footnotes->reference = 0;
1335
+ CREATE(doc->ctx->footnotes->note);
1324
1336
 
1325
1337
  mkd_initialize();
1326
1338
 
1327
1339
  doc->code = compile_document(T(doc->content), doc->ctx);
1328
- qsort(T(*doc->ctx->footnotes), S(*doc->ctx->footnotes),
1329
- sizeof T(*doc->ctx->footnotes)[0],
1340
+ qsort(T(doc->ctx->footnotes->note), S(doc->ctx->footnotes->note),
1341
+ sizeof T(doc->ctx->footnotes->note)[0],
1330
1342
  (stfu)__mkd_footsort);
1331
1343
  memset(&doc->content, 0, sizeof doc->content);
1332
1344
  return 1;
@@ -88,6 +88,12 @@ struct escaped {
88
88
  } ;
89
89
 
90
90
 
91
+ struct footnote_list {
92
+ int reference;
93
+ STRING(Footnote) note;
94
+ } ;
95
+
96
+
91
97
  /* a magic markdown io thing holds all the data structures needed to
92
98
  * do the backend processing of a markdown document
93
99
  */
@@ -96,10 +102,9 @@ typedef struct mmiot {
96
102
  Cstring in;
97
103
  Qblock Q;
98
104
  int isp;
99
- int reference;
100
105
  struct escaped *esc;
101
106
  char *ref_prefix;
102
- STRING(Footnote) *footnotes;
107
+ struct footnote_list *footnotes;
103
108
  DWORD flags;
104
109
  #define MKD_NOLINKS 0x00000001
105
110
  #define MKD_NOIMAGE 0x00000002
@@ -132,6 +137,9 @@ typedef struct mmiot {
132
137
  } MMIOT;
133
138
 
134
139
 
140
+ #define MKD_EOLN 3
141
+
142
+
135
143
  /*
136
144
  * the mkdio text input functions return a document structure,
137
145
  * which contains a header (retrieved from the document if
@@ -215,6 +215,9 @@ void
215
215
  mkd_string_to_anchor(char *s, int len, mkd_sta_function_t outchar,
216
216
  void *out, int labelformat)
217
217
  {
218
+ #if WITH_URLENCODED_ANCHOR
219
+ static const unsigned char hexchars[] = "0123456789abcdef";
220
+ #endif
218
221
  unsigned char c;
219
222
 
220
223
  int i, size;
@@ -222,15 +225,25 @@ mkd_string_to_anchor(char *s, int len, mkd_sta_function_t outchar,
222
225
 
223
226
  size = mkd_line(s, len, &line, IS_LABEL);
224
227
 
228
+ #if !WITH_URLENCODED_ANCHOR
225
229
  if ( labelformat && (size>0) && !isalpha(line[0]) )
226
230
  (*outchar)('L',out);
231
+ #endif
227
232
  for ( i=0; i < size ; i++ ) {
228
233
  c = line[i];
229
234
  if ( labelformat ) {
230
235
  if ( isalnum(c) || (c == '_') || (c == ':') || (c == '-') || (c == '.' ) )
231
236
  (*outchar)(c, out);
232
237
  else
238
+ #if WITH_URLENCODED_ANCHOR
239
+ {
240
+ (*outchar)('%', out);
241
+ (*outchar)(hexchars[c >> 4 & 0xf], out);
242
+ (*outchar)(hexchars[c & 0xf], out);
243
+ }
244
+ #else
233
245
  (*outchar)('.', out);
246
+ #endif
234
247
  }
235
248
  else
236
249
  (*outchar)(c,out);
@@ -76,9 +76,9 @@ ___mkd_freefootnotes(MMIOT *f)
76
76
  int i;
77
77
 
78
78
  if ( f->footnotes ) {
79
- for (i=0; i < S(*f->footnotes); i++)
80
- ___mkd_freefootnote( &T(*f->footnotes)[i] );
81
- DELETE(*f->footnotes);
79
+ for (i=0; i < S(f->footnotes->note); i++)
80
+ ___mkd_freefootnote( &T(f->footnotes->note)[i] );
81
+ DELETE(f->footnotes->note);
82
82
  free(f->footnotes);
83
83
  }
84
84
  }
@@ -98,7 +98,7 @@ ___mkd_initmmiot(MMIOT *f, void *footnotes)
98
98
  f->footnotes = footnotes;
99
99
  else {
100
100
  f->footnotes = malloc(sizeof f->footnotes[0]);
101
- CREATE(*f->footnotes);
101
+ CREATE(f->footnotes->note);
102
102
  }
103
103
  }
104
104
  }
@@ -24,7 +24,7 @@
24
24
  # end
25
25
  #
26
26
  class RDiscount
27
- VERSION = '2.1.7'
27
+ VERSION = '2.1.8'
28
28
 
29
29
  # Original Markdown formatted text.
30
30
  attr_reader :text
@@ -1,8 +1,8 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'rdiscount'
3
- s.version = '2.1.7.1'
3
+ s.version = '2.1.8'
4
4
  s.summary = "Fast Implementation of Gruber's Markdown in C"
5
- s.date = '2014-04-12'
5
+ s.date = '2015-02-01'
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"]
@@ -153,6 +153,15 @@ EOS
153
153
  rd = RDiscount.new(<<EOS, :footnotes)
154
154
  Obtuse text.[^1]
155
155
 
156
+ [^1]: Clarification
157
+ EOS
158
+ assert rd.to_html.include?('<a href="#fn:1" rel="footnote">1</a>')
159
+ end
160
+
161
+ def test_that_footnotes_in_span_works
162
+ rd = RDiscount.new(<<EOS, :footnotes)
163
+ [Obtuse text.[^1]](class:someclass)
164
+
156
165
  [^1]: Clarification
157
166
  EOS
158
167
  assert rd.to_html.include?('<a href="#fn:1" rel="footnote">1</a>')
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.7.1
4
+ version: 2.1.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryan Tomayko
@@ -11,7 +11,7 @@ authors:
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2014-04-12 00:00:00.000000000 Z
14
+ date: 2015-02-01 00:00:00.000000000 Z
15
15
  dependencies: []
16
16
  description:
17
17
  email: davidfstr@gmail.com
@@ -80,12 +80,12 @@ require_paths:
80
80
  - lib
81
81
  required_ruby_version: !ruby/object:Gem::Requirement
82
82
  requirements:
83
- - - '!='
83
+ - - "!="
84
84
  - !ruby/object:Gem::Version
85
85
  version: 1.9.2
86
86
  required_rubygems_version: !ruby/object:Gem::Requirement
87
87
  requirements:
88
- - - '>='
88
+ - - ">="
89
89
  - !ruby/object:Gem::Version
90
90
  version: '0'
91
91
  requirements: []