bluecloth 2.0.11-x86-mswin32 → 2.1.0-x86-mswin32

Sign up to get free protection for your applications and to get access to all the features.
data.tar.gz.sig CHANGED
@@ -1,2 +1 @@
1
- �U�F�:3��Ov�0�~�{��?��W��K�׫b/�Ѷ� vXF����h׮^��{����H�ͅ5�vOu��) o�]�����̿�W�"RbW��q�xA�tR!vq@���F�FD��g�IR��}S4#�bں��ȍ�,A v���S����xQ���g�n|l<�p0
2
- �Ͼи+ �$:�3㡇G<V�P�t9�
1
+ V r��Xew��g����\K�Q���gc�,���rV/���/sU��`�gjb168?�V������r���e�EG"�v�@�^�zza}Q��֔�.�D%��+�LH���W�$����
data/Rakefile CHANGED
@@ -52,8 +52,6 @@ hoespec = Hoe.spec 'bluecloth' do
52
52
  self.require_ruby_version( '>=1.8.7' )
53
53
 
54
54
  self.hg_sign_tags = true if self.respond_to?( :hg_sign_tags= )
55
- self.yard_opts = [ '--protected', '--verbose' ] if self.respond_to?( :yard_opts= )
56
-
57
55
  self.rdoc_locations << "deveiate:/usr/local/www/public/code/#{remote_rdoc_dir}"
58
56
  end
59
57
 
@@ -1 +1 @@
1
- 2.0.5
1
+ 2.0.8
@@ -1,6 +1,6 @@
1
1
  /*
2
2
  * BlueCloth -- a Ruby implementation of Markdown
3
- * $Id: bluecloth.c,v a12b01a92197 2011/01/17 17:13:22 ged $
3
+ * $Id: bluecloth.c,v 463bb88e4d08 2011/03/12 17:58:01 ged $
4
4
  *
5
5
  * = Authors
6
6
  *
@@ -333,7 +333,7 @@ void Init_bluecloth_ext( void ) {
333
333
  mkd_initialize();
334
334
 
335
335
  rb_define_alloc_func( bluecloth_cBlueCloth, bluecloth_s_allocate );
336
- rb_define_singleton_method( bluecloth_cBlueCloth, "discount_version",
336
+ rb_define_singleton_method( bluecloth_cBlueCloth, "discount_version",
337
337
  bluecloth_s_discount_version, 0 );
338
338
 
339
339
  rb_define_method( bluecloth_cBlueCloth, "initialize", bluecloth_initialize, -1 );
@@ -417,6 +417,9 @@ void Init_bluecloth_ext( void ) {
417
417
  /* Forbid definition lists */
418
418
  rb_define_const( bluecloth_cBlueCloth, "MKD_NODLIST", INT2FIX(MKD_NODLIST) );
419
419
 
420
+ /* Markdown-extra Footnotes */
421
+ rb_define_const( bluecloth_cBlueCloth, "MKD_EXTRA_FOOTNOTE", INT2FIX(MKD_EXTRA_FOOTNOTE) );
422
+
420
423
 
421
424
  /* Make sure the Ruby side is loaded */
422
425
  rb_require( "bluecloth" );
@@ -61,6 +61,8 @@
61
61
  #define DL_TAG_EXTENSION 1
62
62
  #define PANDOC_HEADER 1
63
63
  #define ALPHA_LIST 1
64
+ #define USE_DISCOUNT_DL 1
65
+ #define USE_EXTRA_DL 1
64
66
 
65
67
  #endif /* end of include guard: CONFIG_H_RZLE3ADO */
66
68
 
@@ -24,7 +24,6 @@ if ENV['MAINTAINER_MODE']
24
24
  $CFLAGS << ' -ggdb' << ' -DDEBUG'
25
25
  end
26
26
 
27
-
28
27
  # Stuff from configure.sh
29
28
  have_func( "srand" ) || have_func( "srandom" )
30
29
  have_func( "random" ) || have_func( "rand" )
@@ -191,6 +191,7 @@ ___mkd_reparse(char *bfr, int size, int flags, MMIOT *f)
191
191
 
192
192
  sub.flags = f->flags | flags;
193
193
  sub.cb = f->cb;
194
+ sub.ref_prefix = f->ref_prefix;
194
195
 
195
196
  push(bfr, size, &sub);
196
197
  EXPAND(sub.in) = 0;
@@ -564,6 +565,38 @@ printlinkyref(MMIOT *f, linkytype *tag, char *link, int size)
564
565
  } /* printlinkyref */
565
566
 
566
567
 
568
+ /* helper function for php markdown extra footnotes; allow the user to
569
+ * define a prefix tag instead of just `fn`
570
+ */
571
+ static char *
572
+ p_or_nothing(p)
573
+ MMIOT *p;
574
+ {
575
+ return p->ref_prefix ? p->ref_prefix : "fn";
576
+ }
577
+
578
+
579
+ /* php markdown extra/daring fireball style print footnotes
580
+ */
581
+ static int
582
+ extra_linky(MMIOT *f, Cstring text, Footnote *ref)
583
+ {
584
+ if ( ref->flags & REFERENCED )
585
+ return 0;
586
+
587
+ if ( f->flags & IS_LABEL )
588
+ ___mkd_reparse(T(text), S(text), linkt.flags, f);
589
+ else {
590
+ ref->flags |= REFERENCED;
591
+ ref->refnumber = ++ f->reference;
592
+ Qprintf(f, "<sup id=\"%sref:%d\"><a href=\"#%s:%d\" rel=\"footnote\">%d</a></sup>",
593
+ p_or_nothing(f), ref->refnumber,
594
+ p_or_nothing(f), ref->refnumber, ref->refnumber);
595
+ }
596
+ return 1;
597
+ } /* extra_linky */
598
+
599
+
567
600
  /* print out a linky (or fail if it's Not Allowed)
568
601
  */
569
602
  static int
@@ -628,6 +661,7 @@ linkylinky(int image, MMIOT *f)
628
661
  Footnote key, *ref;
629
662
 
630
663
  int status = 0;
664
+ int extra_footnote = 0;
631
665
 
632
666
  CREATE(name);
633
667
  memset(&key, 0, sizeof key);
@@ -654,6 +688,9 @@ linkylinky(int image, MMIOT *f)
654
688
  */
655
689
  mmiotseek(f, implicit_mark);
656
690
  goodlink = !(f->flags & MKD_1_COMPAT);
691
+
692
+ if ( (f->flags & MKD_EXTRA_FOOTNOTE) && (!image) && S(name) && T(name)[0] == '^' )
693
+ extra_footnote = 1;
657
694
  }
658
695
 
659
696
  if ( goodlink ) {
@@ -664,8 +701,12 @@ linkylinky(int image, MMIOT *f)
664
701
  }
665
702
 
666
703
  if ( ref = bsearch(&key, T(*f->footnotes), S(*f->footnotes),
667
- sizeof key, (stfu)__mkd_footsort) )
668
- status = linkyformat(f, name, image, ref);
704
+ sizeof key, (stfu)__mkd_footsort) ) {
705
+ if ( extra_footnote )
706
+ status = extra_linky(f,name,ref);
707
+ else
708
+ status = linkyformat(f, name, image, ref);
709
+ }
669
710
  else if ( f->flags & IS_LABEL )
670
711
  status = linkyformat(f, name, image, 0);
671
712
  }
@@ -922,7 +963,11 @@ maybe_tag_or_link(MMIOT *f)
922
963
  }
923
964
  else if ( isspace(c) )
924
965
  break;
966
+ #if WITH_GITHUB_TAGS
967
+ else if ( ! (c == '/' || c == '-' || c == '_' || isalnum(c) ) )
968
+ #else
925
969
  else if ( ! (c == '/' || isalnum(c) ) )
970
+ #endif
926
971
  maybetag=0;
927
972
  }
928
973
 
@@ -1270,6 +1315,15 @@ text(MMIOT *f)
1270
1315
  Qchar(c, f);
1271
1316
  break;
1272
1317
 
1318
+ case ':': case '|':
1319
+ if ( f->flags & MKD_NOTABLES ) {
1320
+ Qchar('\\', f);
1321
+ shift(f,-1);
1322
+ break;
1323
+ }
1324
+ Qchar(c, f);
1325
+ break;
1326
+
1273
1327
  case '>': case '#': case '.': case '-':
1274
1328
  case '+': case '{': case '}': case ']':
1275
1329
  case '!': case '[': case '*': case '_':
@@ -1312,12 +1366,26 @@ text(MMIOT *f)
1312
1366
  static void
1313
1367
  printheader(Paragraph *pp, MMIOT *f)
1314
1368
  {
1369
+ #if WITH_ID_ANCHOR
1370
+ Qprintf(f, "<h%d", pp->hnumber);
1371
+ if ( f->flags & MKD_TOC ) {
1372
+ Qstring(" id=\"", f);
1373
+ mkd_string_to_anchor(T(pp->text->text),
1374
+ S(pp->text->text),
1375
+ (mkd_sta_function_t)Qchar, f, 1);
1376
+ Qchar('"', f);
1377
+ }
1378
+ Qchar('>', f);
1379
+ #else
1315
1380
  if ( f->flags & MKD_TOC ) {
1316
1381
  Qstring("<a name=\"", f);
1317
- mkd_string_to_anchor(T(pp->text->text), S(pp->text->text), Qchar, f, 1);
1382
+ mkd_string_to_anchor(T(pp->text->text),
1383
+ S(pp->text->text),
1384
+ (mkd_sta_function_t)Qchar, f, 1);
1318
1385
  Qstring("\"></a>\n", f);
1319
1386
  }
1320
1387
  Qprintf(f, "<h%d>", pp->hnumber);
1388
+ #endif
1321
1389
  push(T(pp->text->text), S(pp->text->text), f);
1322
1390
  text(f);
1323
1391
  Qprintf(f, "</h%d>", pp->hnumber);
@@ -1344,8 +1412,11 @@ splat(Line *p, char *block, Istring align, int force, MMIOT *f)
1344
1412
  if ( force && (colno >= S(align)-1) )
1345
1413
  idx = S(p->text);
1346
1414
  else
1347
- while ( (idx < S(p->text)) && (T(p->text)[idx] != '|') )
1415
+ while ( (idx < S(p->text)) && (T(p->text)[idx] != '|') ) {
1416
+ if ( T(p->text)[idx] == '\\' )
1417
+ ++idx;
1348
1418
  ++idx;
1419
+ }
1349
1420
 
1350
1421
  Qprintf(f, "<%s%s>",
1351
1422
  block,
@@ -1393,7 +1464,9 @@ printtable(Paragraph *pp, MMIOT *f)
1393
1464
 
1394
1465
  last=first=0;
1395
1466
  for (end=start ; (end < S(dash->text)) && p[end] != '|'; ++ end ) {
1396
- if ( !isspace(p[end]) ) {
1467
+ if ( p[end] == '\\' )
1468
+ ++ end;
1469
+ else if ( !isspace(p[end]) ) {
1397
1470
  if ( !first) first = p[end];
1398
1471
  last = p[end];
1399
1472
  }
@@ -1615,6 +1688,36 @@ display(Paragraph *p, MMIOT *f)
1615
1688
  }
1616
1689
 
1617
1690
 
1691
+ /* dump out a list of footnotes
1692
+ */
1693
+ static void
1694
+ mkd_extra_footnotes(MMIOT *m)
1695
+ {
1696
+ int j, i;
1697
+ Footnote *t;
1698
+
1699
+ if ( m->reference == 0 )
1700
+ return;
1701
+
1702
+ Csprintf(&m->out, "\n<div class=\"footnotes\">\n<hr/>\n<ol>\n");
1703
+
1704
+ for ( i=1; i <= m->reference; i++ ) {
1705
+ for ( j=0; j < S(*m->footnotes); j++ ) {
1706
+ t = &T(*m->footnotes)[j];
1707
+ if ( (t->refnumber == i) && (t->flags & REFERENCED) ) {
1708
+ Csprintf(&m->out, "<li id=\"%s:%d\">\n<p>",
1709
+ p_or_nothing(m), t->refnumber);
1710
+ Csreparse(&m->out, T(t->title), S(t->title), 0);
1711
+ Csprintf(&m->out, "<a href=\"#%sref:%d\" rev=\"footnote\">&#8617;</a>",
1712
+ p_or_nothing(m), t->refnumber);
1713
+ Csprintf(&m->out, "</p></li>\n");
1714
+ }
1715
+ }
1716
+ }
1717
+ Csprintf(&m->out, "</ol>\n</div>\n");
1718
+ }
1719
+
1720
+
1618
1721
  /* return a pointer to the compiled markdown
1619
1722
  * document.
1620
1723
  */
@@ -1626,6 +1729,8 @@ mkd_document(Document *p, char **res)
1626
1729
  if ( p && p->compiled ) {
1627
1730
  if ( ! p->html ) {
1628
1731
  htmlify(p->code, 0, 0, p->ctx);
1732
+ if ( p->ctx->flags & MKD_EXTRA_FOOTNOTE )
1733
+ mkd_extra_footnotes(p->ctx);
1629
1734
  p->html = 1;
1630
1735
  }
1631
1736
 
@@ -270,25 +270,35 @@ static int
270
270
  istable(Line *t)
271
271
  {
272
272
  char *p;
273
- Line *dashes = t->next;
274
- int contains = 0; /* found character bits; 0x01 is |, 0x02 is - */
273
+ Line *dashes, *body;
274
+ int l;
275
+ int dashed = 0;
275
276
 
276
- /* two lines, first must contain | */
277
- if ( !(dashes && memchr(T(t->text), '|', S(t->text))) )
277
+ /* three lines, first must contain |,
278
+ second must be ---|---,
279
+ third must contain |
280
+ */
281
+ if ( !(t->flags & PIPECHAR) )
282
+ return 0;
283
+
284
+ dashes = t->next;
285
+ if ( !(dashes && (dashes->flags & PIPECHAR)) )
286
+ return 0;
287
+
288
+ body = dashes->next;
289
+ if ( !(body && (body->flags & PIPECHAR)) )
278
290
  return 0;
279
291
 
280
292
  /* second line must contain - or | and nothing
281
293
  * else except for whitespace or :
282
294
  */
283
- for ( p = T(dashes->text)+S(dashes->text)-1; p >= T(dashes->text); --p)
284
- if ( *p == '|' )
285
- contains |= 0x01;
286
- else if ( *p == '-' )
287
- contains |= 0x02;
288
- else if ( ! ((*p == ':') || isspace(*p)) )
295
+ for ( p = T(dashes->text), l = S(dashes->text); l > 0; ++p, --l)
296
+ if ( *p == '-' )
297
+ dashed = 1;
298
+ else if ( ! ((*p == '|') || (*p == ':') || isspace(*p)) )
289
299
  return 0;
290
300
 
291
- return (contains & 0x03);
301
+ return dashed;
292
302
  }
293
303
 
294
304
 
@@ -770,7 +780,7 @@ tableblock(Paragraph *p)
770
780
  Line *t, *q;
771
781
 
772
782
  for ( t = p->text; t && (q = t->next); t = t->next ) {
773
- if ( !memchr(T(q->text), '|', S(q->text)) ) {
783
+ if ( !(t->flags & PIPECHAR) ) {
774
784
  t->next = 0;
775
785
  return q;
776
786
  }
@@ -957,7 +967,7 @@ addfootnote(Line *p, MMIOT* f)
957
967
  CREATE(foot->tag);
958
968
  CREATE(foot->link);
959
969
  CREATE(foot->title);
960
- foot->height = foot->width = 0;
970
+ foot->flags = foot->height = foot->width = 0;
961
971
 
962
972
  for (j=i=p->dle+1; T(p->text)[j] != ']'; j++)
963
973
  EXPAND(foot->tag) = T(p->text)[j];
@@ -966,6 +976,12 @@ addfootnote(Line *p, MMIOT* f)
966
976
  S(foot->tag)--;
967
977
  j = nextnonblank(p, j+2);
968
978
 
979
+ if ( (f->flags & MKD_EXTRA_FOOTNOTE) && (T(foot->tag)[0] == '^') ) {
980
+ while ( j < S(p->text) )
981
+ EXPAND(foot->title) = T(p->text)[j++];
982
+ goto skip_to_end;
983
+ }
984
+
969
985
  while ( (j < S(p->text)) && !isspace(T(p->text)[j]) )
970
986
  EXPAND(foot->link) = T(p->text)[j++];
971
987
  EXPAND(foot->link) = 0;
@@ -1005,6 +1021,7 @@ addfootnote(Line *p, MMIOT* f)
1005
1021
  --S(foot->title);
1006
1022
  }
1007
1023
 
1024
+ skip_to_end:
1008
1025
  ___mkd_freeLine(p);
1009
1026
  return np;
1010
1027
  }
@@ -1201,6 +1218,7 @@ mkd_compile(Document *doc, DWORD flags)
1201
1218
 
1202
1219
  doc->compiled = 1;
1203
1220
  memset(doc->ctx, 0, sizeof(MMIOT) );
1221
+ doc->ctx->ref_prefix= doc->ref_prefix;
1204
1222
  doc->ctx->cb = &(doc->cb);
1205
1223
  doc->ctx->flags = flags & USER_FLAGS;
1206
1224
  CREATE(doc->ctx->in);
@@ -12,6 +12,10 @@ typedef struct footnote {
12
12
  Cstring title; /* what it's called (TITLE= attribute) */
13
13
  int height, width; /* dimensions (for image link) */
14
14
  int dealloc; /* deallocation needed? */
15
+ int refnumber;
16
+ int flags;
17
+ #define EXTRA_BOOKMARK 0x01
18
+ #define REFERENCED 0x02
15
19
  } Footnote;
16
20
 
17
21
  /* each input line is read into a Line, which contains the line,
@@ -22,7 +26,9 @@ typedef struct footnote {
22
26
  typedef struct line {
23
27
  Cstring text;
24
28
  struct line *next;
25
- int dle;
29
+ int dle; /* leading indent on the line */
30
+ int flags; /* special attributes for this line */
31
+ #define PIPECHAR 0x01 /* line contains a | */
26
32
  } Line;
27
33
 
28
34
 
@@ -75,6 +81,8 @@ typedef struct mmiot {
75
81
  Cstring in;
76
82
  Qblock Q;
77
83
  int isp;
84
+ int reference;
85
+ char *ref_prefix;
78
86
  STRING(Footnote) *footnotes;
79
87
  DWORD flags;
80
88
  #define MKD_NOLINKS 0x00000001
@@ -98,6 +106,7 @@ typedef struct mmiot {
98
106
  #define MKD_NODIVQUOTE 0x00040000
99
107
  #define MKD_NOALPHALIST 0x00080000
100
108
  #define MKD_NODLIST 0x00100000
109
+ #define MKD_EXTRA_FOOTNOTE 0x00200000
101
110
  #define IS_LABEL 0x08000000
102
111
  #define USER_FLAGS 0x0FFFFFFF
103
112
  #define INPUT_MASK (MKD_NOHEADER|MKD_TABSTOP)
@@ -124,6 +133,7 @@ typedef struct document {
124
133
  int compiled; /* set after mkd_compile() */
125
134
  int html; /* set after (internal) htmlify() */
126
135
  int tabstop; /* for properly expanding tabs (ick) */
136
+ char *ref_prefix;
127
137
  MMIOT *ctx; /* backend buffers, flags, and structures */
128
138
  Callback_data cb; /* callback functions & private data */
129
139
  } Document;
@@ -143,14 +153,18 @@ extern int mkd_line(char *, int, char **, DWORD);
143
153
  extern int mkd_generateline(char *, int, FILE*, DWORD);
144
154
  #define mkd_text mkd_generateline
145
155
  extern void mkd_basename(Document*, char *);
146
- extern void mkd_string_to_anchor(char*,int, void(*)(int,void*), void*, int);
156
+
157
+ typedef int (*mkd_sta_function_t)(const int,const void*);
158
+ extern void mkd_string_to_anchor(char*,int, mkd_sta_function_t, void*, int);
147
159
 
148
160
  extern Document *mkd_in(FILE *, DWORD);
149
- extern Document *mkd_string(char*,int, DWORD);
161
+ extern Document *mkd_string(const char*,int, DWORD);
150
162
 
151
163
  extern void mkd_initialize();
152
164
  extern void mkd_shlib_destructor();
153
165
 
166
+ extern void mkd_ref_prefix(Document*, char*);
167
+
154
168
  /* internal resource handling functions.
155
169
  */
156
170
  extern void ___mkd_freeLine(Line *);
@@ -34,7 +34,8 @@ new_Document()
34
34
  }
35
35
 
36
36
 
37
- /* add a line to the markdown input chain
37
+ /* add a line to the markdown input chain, expanding tabs and
38
+ * noting the presence of special characters as we go.
38
39
  */
39
40
  static void
40
41
  queue(Document* a, Cstring *line)
@@ -60,6 +61,8 @@ queue(Document* a, Cstring *line)
60
61
  } while ( ++xp % a->tabstop );
61
62
  }
62
63
  else if ( c >= ' ' ) {
64
+ if ( c == '|' )
65
+ p->flags |= PIPECHAR;
63
66
  EXPAND(p->text) = c;
64
67
  ++xp;
65
68
  }
@@ -148,7 +151,7 @@ mkd_in(FILE *f, DWORD flags)
148
151
  /* return a single character out of a buffer
149
152
  */
150
153
  struct string_ctx {
151
- char *data; /* the unread data */
154
+ const char *data; /* the unread data */
152
155
  int size; /* and how much is there? */
153
156
  } ;
154
157
 
@@ -167,7 +170,7 @@ strget(struct string_ctx *in)
167
170
  /* convert a block of text into a linked list
168
171
  */
169
172
  Document *
170
- mkd_string(char *buf, int len, DWORD flags)
173
+ mkd_string(const char *buf, int len, DWORD flags)
171
174
  {
172
175
  struct string_ctx about;
173
176
 
@@ -215,7 +218,7 @@ markdown(Document *document, FILE *out, int flags)
215
218
  /* write out a Cstring, mangled into a form suitable for `<a href=` or `<a id=`
216
219
  */
217
220
  void
218
- mkd_string_to_anchor(char *s, int len, void(*outchar)(int,void*),
221
+ mkd_string_to_anchor(char *s, int len, mkd_sta_function_t outchar,
219
222
  void *out, int labelformat)
220
223
  {
221
224
  unsigned char c;
@@ -233,7 +236,7 @@ mkd_string_to_anchor(char *s, int len, void(*outchar)(int,void*),
233
236
  if ( isalnum(c) || (c == '_') || (c == ':') || (c == '-') || (c == '.' ) )
234
237
  (*outchar)(c, out);
235
238
  else
236
- (*outchar)('.',out);
239
+ (*outchar)('.', out);
237
240
  }
238
241
  else
239
242
  (*outchar)(c,out);
@@ -342,3 +345,13 @@ mkd_e_data(Document *f, void *data)
342
345
  if ( f )
343
346
  f->cb.e_data = data;
344
347
  }
348
+
349
+
350
+ /* set the href prefix for markdown extra style footnotes
351
+ */
352
+ void
353
+ mkd_ref_prefix(Document *f, char *data)
354
+ {
355
+ if ( f )
356
+ f->ref_prefix = data;
357
+ }
@@ -10,11 +10,12 @@ typedef unsigned int mkd_flag_t;
10
10
  /* line builder for markdown()
11
11
  */
12
12
  MMIOT *mkd_in(FILE*,mkd_flag_t); /* assemble input from a file */
13
- MMIOT *mkd_string(char*,int,mkd_flag_t); /* assemble input from a buffer */
13
+ MMIOT *mkd_string(const char*,int,mkd_flag_t); /* assemble input from a buffer */
14
14
 
15
15
  void mkd_basename(MMIOT*,char*);
16
16
 
17
17
  void mkd_initialize();
18
+ void mkd_with_html5_tags();
18
19
  void mkd_shlib_destructor();
19
20
 
20
21
  /* compilation, debugging, cleanup
@@ -27,7 +28,8 @@ int mkd_cleanup(MMIOT*);
27
28
  int mkd_dump(MMIOT*, FILE*, int, char*);
28
29
  int markdown(MMIOT*, FILE*, mkd_flag_t);
29
30
  int mkd_line(char *, int, char **, mkd_flag_t);
30
- void mkd_string_to_anchor(char *, int, int (*)(int,void*), void*, int);
31
+ typedef int (*mkd_sta_function_t)(const int,const void*);
32
+ void mkd_string_to_anchor(char *, int, mkd_sta_function_t, void*, int);
31
33
  int mkd_xhtmlpage(MMIOT*,int,FILE*);
32
34
 
33
35
  /* header block access
@@ -66,6 +68,11 @@ void mkd_e_data(void *, void *);
66
68
  /* version#.
67
69
  */
68
70
  extern char markdown_version[];
71
+ void mkd_mmiot_flags(FILE *, MMIOT *, int);
72
+ void mkd_flags_are(FILE*, mkd_flag_t, int);
73
+
74
+ void mkd_ref_prefix(MMIOT*, char*);
75
+
69
76
 
70
77
  /* special flags for markdown() and mkd_text()
71
78
  */
@@ -91,6 +98,7 @@ extern char markdown_version[];
91
98
  #define MKD_NODIVQUOTE 0x00040000 /* forbid >%class% blocks */
92
99
  #define MKD_NOALPHALIST 0x00080000 /* forbid alphabetic lists */
93
100
  #define MKD_NODLIST 0x00100000 /* forbid definition lists */
101
+ #define MKD_EXTRA_FOOTNOTE 0x00200000 /* enable markdown extra-style footnotes */
94
102
  #define MKD_EMBED MKD_NOLINKS|MKD_NOIMAGE|MKD_TAGTEXT
95
103
 
96
104
  /* special flags for mkd_in() and mkd_string()
@@ -1,28 +1,27 @@
1
1
  #include "config.h"
2
2
 
3
3
  char markdown_version[] = VERSION
4
- #if DL_TAG_EXTENSION
5
- " DL_TAG"
6
- #endif
7
- #if PANDOC_HEADER
8
- " HEADER"
9
- #endif
10
4
  #if 4 != 4
11
5
  " TAB=4"
12
6
  #endif
13
7
  #if USE_AMALLOC
14
8
  " DEBUG"
15
9
  #endif
16
- #if SUPERSCRIPT
17
- " SUPERSCRIPT"
18
- #endif
19
- #if RELAXED_EMPHASIS
20
- " RELAXED"
21
- #endif
22
- #if DIV_QUOTE
23
- " DIV"
24
- #endif
25
- #if ALPHA_LIST
26
- " AL"
10
+ #if USE_DISCOUNT_DL
11
+ # if USE_EXTRA_DL
12
+ " DL=BOTH"
13
+ # else
14
+ " DL=DISCOUNT"
15
+ # endif
16
+ #elif USE_EXTRA_DL
17
+ " DL=EXTRA"
18
+ #else
19
+ " DL=NONE"
20
+ #endif
21
+ #if WITH_ID_ANCHOR
22
+ " ID-ANCHOR"
23
+ #endif
24
+ #if WITH_GITHUB_TAGS
25
+ " GITHUB-TAGS"
27
26
  #endif
28
27
  ;
Binary file
Binary file
@@ -18,18 +18,49 @@
18
18
  #
19
19
  # == Version
20
20
  #
21
- # $Id: bluecloth.rb,v 20ece393cda0 2011/02/10 01:37:48 ged $
21
+ # 2.1.0
22
+ #
23
+ # == Revision
22
24
  #
25
+ # $Revision: 463bb88e4d08 $
26
+ #
23
27
  # == License
24
- #
25
- # :include: LICENSE
26
- #--
27
- # Please see the LICENSE file included in the distribution for copyright and licensing details.
28
- #
28
+ #
29
+ # Copyright (c) 2004-2011, Michael Granger
30
+ # All rights reserved.
31
+ #
32
+ # Redistribution and use in source and binary forms, with or without
33
+ # modification, are permitted provided that the following conditions are met:
34
+ #
35
+ # * Redistributions of source code must retain the above copyright notice,
36
+ # this list of conditions and the following disclaimer.
37
+ #
38
+ # * Redistributions in binary form must reproduce the above copyright notice,
39
+ # this list of conditions and the following disclaimer in the documentation
40
+ # and/or other materials provided with the distribution.
41
+ #
42
+ # * Neither the name of the author/s, nor the names of the project's
43
+ # contributors may be used to endorse or promote products derived from this
44
+ # software without specific prior written permission.
45
+ #
46
+ # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
47
+ # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
48
+ # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
49
+ # DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
50
+ # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
51
+ # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
52
+ # SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
53
+ # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
54
+ # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
55
+ # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
56
+ #
29
57
  class BlueCloth
30
58
 
31
59
  # Release Version
32
- VERSION = '2.0.11'
60
+ VERSION = '2.1.0'
61
+
62
+ # Version control revision
63
+ REVISION = %q$Revision: 463bb88e4d08 $
33
64
 
34
65
  # The defaults for all supported options.
35
66
  DEFAULT_OPTIONS = {
@@ -54,6 +85,7 @@ class BlueCloth
54
85
  :tables => false,
55
86
  :tagtext_mode => false,
56
87
  :xml_cdata => false,
88
+ :footnotes => false,
57
89
  }.freeze
58
90
 
59
91
  # The number of characters of the original markdown source to include in the
@@ -103,6 +135,7 @@ class BlueCloth
103
135
  if ! opthash[:divquotes] then flags |= MKD_NODIVQUOTE; end
104
136
  if ! opthash[:alphalists] then flags |= MKD_NOALPHALIST; end
105
137
  if ! opthash[:definition_lists] then flags |= MKD_NODLIST; end
138
+ if opthash[:footnotes] then flags |= MKD_EXTRA_FOOTNOTE; end
106
139
 
107
140
  return flags
108
141
  end
@@ -134,6 +167,7 @@ class BlueCloth
134
167
  if !( flags & MKD_NODIVQUOTE ).nonzero? then opthash[:divquotes] = true; end
135
168
  if !( flags & MKD_NOALPHALIST ).nonzero? then opthash[:alphalists] = true; end
136
169
  if !( flags & MKD_NODLIST ).nonzero? then opthash[:definition_lists] = true; end
170
+ if ( flags & MKD_EXTRA_FOOTNOTE ).nonzero? then opthash[:footnotes] = true; end
137
171
 
138
172
  return opthash
139
173
  end
@@ -155,25 +189,6 @@ class BlueCloth
155
189
  ]
156
190
  end
157
191
 
158
-
159
- ### Backward-compatible method: return +true+ if the object's :escape_html option was
160
- ### set.
161
- def filter_html
162
- return self.options[:escape_html]
163
- end
164
-
165
-
166
- ### Backward-compatible method: raises an appropriate error notifying the user that
167
- ### BlueCloth2 doesn't support this option.
168
- def filter_html=( arg )
169
- raise NotImplementedError,
170
- "Sorry, this version of BlueCloth no longer supports toggling of HTML filtering" +
171
- "via #filter_html=. You now must create the BlueCloth object with the :escape_html" +
172
- "option set to true instead."
173
- end
174
-
175
-
176
-
177
192
  end # class BlueCloth
178
193
 
179
194
  begin
@@ -4,10 +4,10 @@
4
4
  BEGIN {
5
5
  require 'pathname'
6
6
  basedir = Pathname.new( __FILE__ ).dirname.parent.parent
7
-
7
+
8
8
  libdir = basedir + 'lib'
9
9
  extdir = basedir + 'ext'
10
-
10
+
11
11
  $LOAD_PATH.unshift( basedir ) unless $LOAD_PATH.include?( basedir )
12
12
  $LOAD_PATH.unshift( libdir ) unless $LOAD_PATH.include?( libdir )
13
13
  $LOAD_PATH.unshift( extdir ) unless $LOAD_PATH.include?( extdir )
@@ -57,6 +57,24 @@ describe BlueCloth, "document with entities" do
57
57
  ---
58
58
  end
59
59
 
60
+ it "handles a mix of entities in code spans and not in code spans (issue #73)" do
61
+ the_indented_markdown( <<-"---" ).should be_transformed_into(<<-"---").without_indentation
62
+ # HTML Text is Unicode #
63
+
64
+ * You can either use character entities or character codes for foreign language characters and symbols:
65
+ * ``&eacute;`` or ``&#233;`` is e-acute (&eacute;)
66
+ * ``&copy;`` or ``&#169;`` is the copyright symbol &copy;
67
+ ---
68
+ <h1>HTML Text is Unicode</h1>
69
+
70
+ <ul>
71
+ <li>You can either use character entities or character codes for foreign language characters and symbols:</li>
72
+ <li><code>&amp;eacute;</code> or <code>&amp;#233;</code> is e-acute (&eacute;)</li>
73
+ <li><code>&amp;copy;</code> or <code>&amp;#169;</code> is the copyright symbol &copy;</li>
74
+ </ul>
75
+ ---
76
+ end
77
+
60
78
  end
61
79
 
62
80
 
@@ -43,7 +43,7 @@ describe BlueCloth do
43
43
  end
44
44
 
45
45
  it "knows what version of Discount was used to build it" do
46
- BlueCloth.discount_version.should =~ /^\d+\.\d+\.\d+.*RELAXED/
46
+ BlueCloth.discount_version.should =~ /^\d+\.\d+\.\d+.*DL=BOTH/
47
47
  end
48
48
 
49
49
  it "can build a flags bitmask out of an options hash" do
@@ -3,10 +3,10 @@
3
3
  BEGIN {
4
4
  require 'pathname'
5
5
  basedir = Pathname.new( __FILE__ ).dirname.parent
6
-
6
+
7
7
  libdir = basedir + 'lib'
8
8
  extdir = basedir + 'ext'
9
-
9
+
10
10
  $LOAD_PATH.unshift( basedir ) unless $LOAD_PATH.include?( basedir )
11
11
  $LOAD_PATH.unshift( libdir ) unless $LOAD_PATH.include?( libdir )
12
12
  $LOAD_PATH.unshift( extdir ) unless $LOAD_PATH.include?( extdir )
@@ -44,23 +44,16 @@ describe BlueCloth, "contributed features: " do
44
44
  ### Test the :filter_html restriction
45
45
  it "can be configured with html filtering when created" do
46
46
  bc = BlueCloth.new( 'foo', :filter_html )
47
- bc.filter_html.should be_true()
47
+ bc.options.should include( :escape_html )
48
48
  end
49
-
50
-
49
+
50
+
51
51
  it "can be configured with html filtering (via an Array of options) when created" do
52
52
  bc = BlueCloth.new( 'foo', [:filter_html] )
53
- bc.filter_html.should be_true()
53
+ bc.options.should include( :escape_html )
54
54
  end
55
-
56
-
57
- it "raises an appropriate error when #filter_html= is called" do
58
- lambda {
59
- BlueCloth.new( 'foo' ).filter_html = true
60
- }.should raise_error( NotImplementedError, /sorry/i )
61
- end
62
-
63
-
55
+
56
+
64
57
  it "can escape any existing HTML in the input if configured to do so" do
65
58
  the_markdown( DANGEROUS_HTML, :filter_html ).
66
59
  should be_transformed_into( DANGEROUS_HTML_OUTPUT )
@@ -217,6 +217,208 @@ describe BlueCloth, "implementation of Discount-specific features" do
217
217
 
218
218
  end
219
219
 
220
+
221
+ describe "definition lists" do
222
+
223
+ describe "(discount style)" do
224
+ it "aren't rendered by default" do
225
+ the_indented_markdown( <<-"---" ).should be_transformed_into(<<-"---").without_indentation
226
+ =hey!=
227
+ This is a definition list
228
+ ---
229
+ <p>=hey!=</p>
230
+
231
+ <pre><code>This is a definition list
232
+ </code></pre>
233
+ ---
234
+ end
235
+
236
+ it "are rendered if the :definition_lists option is true" do
237
+ the_indented_markdown( <<-"---", :definition_lists => true ).should be_transformed_into(<<-"---").without_indentation
238
+ =hey!=
239
+ This is a definition list
240
+ ---
241
+ <dl>
242
+ <dt>hey!</dt>
243
+ <dd>This is a definition list</dd>
244
+ </dl>
245
+ ---
246
+ end
247
+
248
+ it "supports multiple-term list items" do
249
+ the_indented_markdown( <<-"---", :definition_lists => true ).should be_transformed_into(<<-"---").without_indentation
250
+ =tag1=
251
+ =tag2=
252
+ data.
253
+ ---
254
+ <dl>
255
+ <dt>tag1</dt>
256
+ <dt>tag2</dt>
257
+ <dd>data.</dd>
258
+ </dl>
259
+ ---
260
+ end
261
+ end
262
+
263
+ describe "(markdown-extra style)" do
264
+ it "aren't rendered by default" do
265
+ the_indented_markdown( <<-"---" ).should be_transformed_into(<<-"---").without_indentation
266
+ Apple
267
+ : Pomaceous fruit of plants of the genus Malus in
268
+ the family Rosaceae.
269
+
270
+ Orange
271
+ : The fruit of an evergreen tree of the genus Citrus.
272
+ ---
273
+ <p>Apple
274
+ : Pomaceous fruit of plants of the genus Malus in</p>
275
+
276
+ <pre><code>the family Rosaceae.
277
+ </code></pre>
278
+
279
+ <p>Orange
280
+ : The fruit of an evergreen tree of the genus Citrus.</p>
281
+ ---
282
+ end
283
+
284
+ it "are rendered if the :definition_lists option is true" do
285
+ the_indented_markdown( <<-"---", :definition_lists => true ).should be_transformed_into(<<-"---").without_indentation
286
+ Apple
287
+ : Pomaceous fruit of plants of the genus Malus in
288
+ the family Rosaceae.
289
+
290
+ Orange
291
+ : The fruit of an evergreen tree of the genus Citrus.
292
+ ---
293
+ <dl>
294
+ <dt>Apple</dt>
295
+ <dd> Pomaceous fruit of plants of the genus Malus in
296
+ the family Rosaceae.</dd>
297
+ <dt>Orange</dt>
298
+ <dd> The fruit of an evergreen tree of the genus Citrus.</dd>
299
+ </dl>
300
+ ---
301
+ end
302
+
303
+ it "are rendered if the :definition_lists option is true" do
304
+ the_indented_markdown( <<-"---", :definition_lists => true ).should be_transformed_into(<<-"---").without_indentation
305
+ Apple
306
+ : Pomaceous fruit of plants of the genus Malus in
307
+ the family Rosaceae.
308
+
309
+ Orange
310
+ : The fruit of an evergreen tree of the genus Citrus.
311
+ ---
312
+ <dl>
313
+ <dt>Apple</dt>
314
+ <dd> Pomaceous fruit of plants of the genus Malus in
315
+ the family Rosaceae.</dd>
316
+ <dt>Orange</dt>
317
+ <dd> The fruit of an evergreen tree of the genus Citrus.</dd>
318
+ </dl>
319
+ ---
320
+ end
321
+ end
322
+
323
+ end
324
+
325
+
326
+ describe "footnotes" do
327
+
328
+ it "aren't rendered by default" do
329
+ the_indented_markdown( <<-"---" ).should be_transformed_into(<<-"---").without_indentation
330
+ That's some text with a footnote.[^1]
331
+
332
+ [^1]: And that's the footnote.
333
+ ---
334
+ <p>That's some text with a footnote.<a href=\"And\">^1</a></p>
335
+ ---
336
+ end
337
+
338
+ it "are rendered if the :footnotes option is true" do
339
+ the_indented_markdown( <<-"---", :footnotes => true ).should be_transformed_into(<<-"---").without_indentation
340
+ That's some text with a footnote.[^1]
341
+
342
+ [^1]: And that's the footnote.
343
+ ---
344
+ <p>That's some text with a footnote.<sup id="fnref:1"><a href="#fn:1" rel="footnote">1</a></sup></p>
345
+ <div class="footnotes">
346
+ <hr/>
347
+ <ol>
348
+ <li id="fn:1">
349
+ <p>And that&rsquo;s the footnote.<a href="#fnref:1" rev="footnote">&#8617;</a></p></li>
350
+ </ol>
351
+ </div>
352
+ ---
353
+ end
354
+
355
+ it "renders a second link to the same footnote as plain text" do
356
+ the_indented_markdown( <<-"---", :footnotes => true ).should be_transformed_into(<<-"---").without_indentation
357
+ That's some text with a footnote.[^afootnote]
358
+ And here's another.[^afootnote]
359
+
360
+ [^afootnote]: And that's the footnote.
361
+ ---
362
+ <p>That's some text with a footnote.<sup id=\"fnref:1\"><a href=\"#fn:1\" rel=\"footnote\">1</a></sup>
363
+ And here's another.[^afootnote]</p>
364
+ <div class=\"footnotes\">
365
+ <hr/>
366
+ <ol>
367
+ <li id=\"fn:1\">
368
+ <p>And that&rsquo;s the footnote.<a href=\"#fnref:1\" rev=\"footnote\">&#8617;</a></p></li>
369
+ </ol>
370
+ </div>
371
+ ---
372
+ end
373
+
374
+ it "support multiple block-level elements via indentation", :pedantic => true do
375
+ pending "not yet implemented by Discount" do
376
+ the_indented_markdown( <<-"---", :footnotes => true ).should be_transformed_into(<<-"---").without_indentation
377
+ That's some text with a footnote.[^1]
378
+
379
+ [^1]: And that's the footnote.
380
+
381
+ That's the second paragraph.
382
+ ---
383
+ <p>That's some text with a footnote.<sup id="fnref:1"><a href="#fn:1" rel="footnote">1</a></sup></p>
384
+ <div class="footnotes">
385
+ <hr/>
386
+ <ol>
387
+ <li id="fn:1">
388
+ <p>And that&rsquo;s the footnote.</p>
389
+ <p>That&rsquo;s the second paragraph.<a href="#fnref:1" rev="footnote">&#8617;</a></p></li>
390
+ </ol>
391
+ </div>
392
+ ---
393
+ end
394
+ end
395
+
396
+ it "support multiple block-level elements with an empty first line", :pedantic => true do
397
+ pending "not yet implemented by Discount" do
398
+ the_indented_markdown( <<-"---", :footnotes => true ).should be_transformed_into(<<-"---").without_indentation
399
+ That's some text with a footnote.[^cows]
400
+
401
+ [^cows]:
402
+ And that's the footnote.
403
+
404
+ That's the second paragraph.
405
+ ---
406
+ <p>That's some text with a footnote.<sup id="fnref:cows"><a href="#fn:cows" rel="footnote">1</a></sup></p>
407
+ <div class="footnotes">
408
+ <hr />
409
+ <ol>
410
+ <li id="fn:cows">
411
+ <p>And that's the footnote.</p>
412
+ <p>That's the second paragraph.&#160;<a href="#fnref:cows" rev="footnote">&#8617;</a></p>
413
+ </li>
414
+ </ol>
415
+ </div>
416
+ ---
417
+ end
418
+ end
419
+
420
+ end
421
+
220
422
  end
221
423
 
222
424
 
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bluecloth
3
3
  version: !ruby/object:Gem::Version
4
- hash: 25
4
+ hash: 11
5
5
  prerelease:
6
6
  segments:
7
7
  - 2
8
+ - 1
8
9
  - 0
9
- - 11
10
- version: 2.0.11
10
+ version: 2.1.0
11
11
  platform: x86-mswin32
12
12
  authors:
13
13
  - Michael Granger
@@ -35,7 +35,7 @@ cert_chain:
35
35
  cmlhXe46pZNJgWKbxZah85jIjx95hR8vOI+NAM5iH9kOqK13DrxacTKPhqj5PjwF
36
36
  -----END CERTIFICATE-----
37
37
 
38
- date: 2011-02-10 00:00:00 -08:00
38
+ date: 2011-03-12 00:00:00 -08:00
39
39
  default_executable:
40
40
  dependencies:
41
41
  - !ruby/object:Gem::Dependency
@@ -279,10 +279,9 @@ licenses:
279
279
  - BSD
280
280
  post_install_message:
281
281
  rdoc_options:
282
- - --protected
283
- - --verbose
284
282
  - --title
285
283
  - Bluecloth Documentation
284
+ - --quiet
286
285
  require_paths:
287
286
  - lib
288
287
  required_ruby_version: !ruby/object:Gem::Requirement
@@ -308,7 +307,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
308
307
  requirements: []
309
308
 
310
309
  rubyforge_project: bluecloth
311
- rubygems_version: 1.4.2
310
+ rubygems_version: 1.5.2
312
311
  signing_key:
313
312
  specification_version: 3
314
313
  summary: BlueCloth is a Ruby implementation of John Gruber's [Markdown][markdown], a text-to-HTML conversion tool for web writers
metadata.gz.sig CHANGED
Binary file