rdiscount 2.1.8 → 2.2.0
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 +4 -4
- data/BUILDING +4 -1
- data/README.markdown +2 -1
- data/ext/VERSION +1 -1
- data/ext/amalloc.c +29 -5
- data/ext/config.h +0 -10
- data/ext/css.c +5 -3
- data/ext/dumptree.c +0 -1
- data/ext/extconf.rb +1 -1
- data/ext/flags.c +6 -0
- data/ext/generate.c +77 -33
- data/ext/markdown.c +83 -68
- data/ext/markdown.h +14 -3
- data/ext/mkdio.c +20 -24
- data/ext/mkdio.h +7 -0
- data/ext/pgm_options.c +7 -1
- data/ext/rdiscount.c +4 -1
- data/ext/toc.c +2 -2
- data/ext/version.c +2 -19
- data/ext/xml.c +2 -2
- data/ext/xmlpage.c +16 -18
- data/lib/rdiscount.rb +1 -1
- data/rdiscount.gemspec +3 -3
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5fa600678c5314e67b7b61b113b1a061ed42f5a8
|
4
|
+
data.tar.gz: c9fef34817017c9be900f6897647471d10dac7fe
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7e29504a28c0dc25eb1a863e48484940c16a05a1ebb1f73046c2ef86f818ab0503e7425f0fa8733b3465b65c54a6592c6ccb58ad263425c61a27ae6ea64ebf0c
|
7
|
+
data.tar.gz: 91f0960039b2e8a9d0f44c7be7cbdecdca768f490bef418e04754d5ecfa9c47fdb336742bbd777fae72bb186d3f2a2febc335097862cb14128efb346d1b66fdd
|
data/BUILDING
CHANGED
@@ -20,7 +20,7 @@ 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
|
23
|
+
$ ./configure.sh
|
24
24
|
$ make # ensure it compiles
|
25
25
|
$ cd ..
|
26
26
|
$ rake gather
|
@@ -52,6 +52,9 @@ ext. This must be done manually. Here's a quick way to get the full list:
|
|
52
52
|
|
53
53
|
$ echo ext/*.c ext/*.h ext/*.rb ext/blocktags ext/VERSION | tr ' ' "\n" | sort
|
54
54
|
|
55
|
+
(There is an old Rakefile target called "rdiscount.gemspec" that looks like it
|
56
|
+
is designed to perform an update of these files, however I haven't tested it.)
|
57
|
+
|
55
58
|
Build the RDiscount gem. If you get errors related to missing files
|
56
59
|
in ext, make sure you updated the gemspec correctly in the previous step.
|
57
60
|
|
data/README.markdown
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
Discount Markdown Processor for Ruby
|
2
2
|
====================================
|
3
|
-
[](https://travis-ci.org/davidfstr/rdiscount)
|
4
|
+
[](https://ci.appveyor.com/project/DavidFoster/rdiscount/branch/master)
|
4
5
|
|
5
6
|
Discount is an implementation of John Gruber's Markdown markup language in C. It
|
6
7
|
implements all of the language described in [the markdown syntax document][1] and
|
data/ext/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.
|
1
|
+
2.2.0
|
data/ext/amalloc.c
CHANGED
@@ -8,7 +8,7 @@
|
|
8
8
|
|
9
9
|
#define MAGIC 0x1f2e3d4c
|
10
10
|
|
11
|
-
struct alist { int magic, size; struct alist *next, *last; };
|
11
|
+
struct alist { int magic, size, index; int *end; struct alist *next, *last; };
|
12
12
|
|
13
13
|
static struct alist list = { 0, 0, 0, 0 };
|
14
14
|
|
@@ -16,14 +16,32 @@ static int mallocs=0;
|
|
16
16
|
static int reallocs=0;
|
17
17
|
static int frees=0;
|
18
18
|
|
19
|
+
static int index = 0;
|
20
|
+
|
21
|
+
static void
|
22
|
+
die(char *msg, int index)
|
23
|
+
{
|
24
|
+
fprintf(stderr, msg, index);
|
25
|
+
abort();
|
26
|
+
}
|
27
|
+
|
28
|
+
|
19
29
|
void *
|
20
|
-
acalloc(int
|
30
|
+
acalloc(int count, int size)
|
21
31
|
{
|
22
|
-
struct alist *ret
|
32
|
+
struct alist *ret;
|
33
|
+
|
34
|
+
if ( size > 1 ) {
|
35
|
+
count *= size;
|
36
|
+
size = 1;
|
37
|
+
}
|
23
38
|
|
24
|
-
if ( ret ) {
|
39
|
+
if ( ret = calloc(count + sizeof(struct alist) + sizeof(int), size) ) {
|
25
40
|
ret->magic = MAGIC;
|
26
41
|
ret->size = size * count;
|
42
|
+
ret->index = index ++;
|
43
|
+
ret->end = (int*)(count + (char*) (ret + 1));
|
44
|
+
*(ret->end) = ~MAGIC;
|
27
45
|
if ( list.next ) {
|
28
46
|
ret->next = list.next;
|
29
47
|
ret->last = &list;
|
@@ -54,6 +72,8 @@ afree(void *ptr)
|
|
54
72
|
struct alist *p2 = ((struct alist*)ptr)-1;
|
55
73
|
|
56
74
|
if ( p2->magic == MAGIC ) {
|
75
|
+
if ( ! (p2->end && *(p2->end) == ~MAGIC) )
|
76
|
+
die("goddam: corrupted memory block %d in free()!\n", p2->index);
|
57
77
|
p2->last->next = p2->next;
|
58
78
|
p2->next->last = p2->last;
|
59
79
|
++frees;
|
@@ -71,12 +91,16 @@ arealloc(void *ptr, int size)
|
|
71
91
|
struct alist save;
|
72
92
|
|
73
93
|
if ( p2->magic == MAGIC ) {
|
94
|
+
if ( ! (p2->end && *(p2->end) == ~MAGIC) )
|
95
|
+
die("goddam: corrupted memory block %d in realloc()!\n", p2->index);
|
74
96
|
save.next = p2->next;
|
75
97
|
save.last = p2->last;
|
76
|
-
p2 = realloc(p2, sizeof(*p2) + size);
|
98
|
+
p2 = realloc(p2, sizeof(int) + sizeof(*p2) + size);
|
77
99
|
|
78
100
|
if ( p2 ) {
|
79
101
|
p2->size = size;
|
102
|
+
p2->end = (int*)(size + (char*) (p2 + 1));
|
103
|
+
*(p2->end) = ~MAGIC;
|
80
104
|
p2->next->last = p2;
|
81
105
|
p2->last->next = p2;
|
82
106
|
++reallocs;
|
data/ext/config.h
CHANGED
@@ -7,16 +7,6 @@
|
|
7
7
|
/* tabs are four spaces */
|
8
8
|
#define TABSTOP 4
|
9
9
|
|
10
|
-
/* enable fenced code blocks */
|
11
|
-
#define WITH_FENCED_CODE 1
|
12
|
-
|
13
|
-
/* include - and _ as acceptable characters in HTML tag names */
|
14
|
-
#define WITH_GITHUB_TAGS 1
|
15
|
-
|
16
|
-
/* enable discount and PHP Markdown Extra definition lists */
|
17
|
-
#define USE_EXTRA_DL 1
|
18
|
-
#define USE_DISCOUNT_DL 1
|
19
|
-
|
20
10
|
/* these are setup by extconf.rb */
|
21
11
|
#if HAVE_RANDOM
|
22
12
|
#define COINTOSS() (random()&1)
|
data/ext/css.c
CHANGED
@@ -75,11 +75,13 @@ int
|
|
75
75
|
mkd_generatecss(Document *d, FILE *f)
|
76
76
|
{
|
77
77
|
char *res;
|
78
|
-
int written
|
78
|
+
int written;
|
79
|
+
int size = mkd_css(d, &res);
|
79
80
|
|
80
|
-
|
81
|
-
|
81
|
+
written = (size > 0) ? fwrite(res,1,size,f) : 0;
|
82
|
+
|
82
83
|
if ( res )
|
83
84
|
free(res);
|
85
|
+
|
84
86
|
return (written == size) ? size : EOF;
|
85
87
|
}
|
data/ext/dumptree.c
CHANGED
data/ext/extconf.rb
CHANGED
data/ext/flags.c
CHANGED
@@ -30,6 +30,12 @@ static struct flagnames flagnames[] = {
|
|
30
30
|
{ MKD_NODLIST, "!DLIST" },
|
31
31
|
{ MKD_EXTRA_FOOTNOTE, "FOOTNOTE" },
|
32
32
|
{ MKD_NOSTYLE, "!STYLE" },
|
33
|
+
{ MKD_NODLDISCOUNT, "!DLDISCOUNT" },
|
34
|
+
{ MKD_DLEXTRA, "DLEXTRA" },
|
35
|
+
{ MKD_FENCEDCODE, "FENCEDCODE" },
|
36
|
+
{ MKD_IDANCHOR, "IDANCHOR" },
|
37
|
+
{ MKD_GITHUBTAGS, "GITHUBTAGS" },
|
38
|
+
{ MKD_URLENCODEDANCHOR, "URLENCODEDANCHOR" },
|
33
39
|
};
|
34
40
|
#define NR(x) (sizeof x/sizeof x[0])
|
35
41
|
|
data/ext/generate.c
CHANGED
@@ -786,7 +786,7 @@ mangle(char *s, int len, MMIOT *f)
|
|
786
786
|
{
|
787
787
|
while ( len-- > 0 ) {
|
788
788
|
#if DEBIAN_GLITCH
|
789
|
-
Qprintf(f, "
|
789
|
+
Qprintf(f, "&#%02d;", *((unsigned char*)(s++)) );
|
790
790
|
#else
|
791
791
|
Qstring("&#", f);
|
792
792
|
Qprintf(f, COINTOSS() ? "x%02x;" : "%02d;", *((unsigned char*)(s++)) );
|
@@ -860,7 +860,6 @@ code(MMIOT *f, char *s, int length)
|
|
860
860
|
cputc(c, f);
|
861
861
|
} /* code */
|
862
862
|
|
863
|
-
|
864
863
|
/* delspan() -- write out a chunk of text, blocking with <del>...</del>
|
865
864
|
*/
|
866
865
|
static void
|
@@ -1009,11 +1008,9 @@ maybe_tag_or_link(MMIOT *f)
|
|
1009
1008
|
}
|
1010
1009
|
else if ( isspace(c) )
|
1011
1010
|
break;
|
1012
|
-
|
1013
|
-
|
1014
|
-
|
1015
|
-
else if ( ! (c == '/' || isalnum(c) ) )
|
1016
|
-
#endif
|
1011
|
+
else if ( ! (c == '/'
|
1012
|
+
|| (f->flags & MKD_GITHUBTAGS && (c == '-' || c == '_'))
|
1013
|
+
|| isalnum(c) ) )
|
1017
1014
|
maybetag=0;
|
1018
1015
|
}
|
1019
1016
|
|
@@ -1064,6 +1061,8 @@ maybe_autolink(MMIOT *f)
|
|
1064
1061
|
if ( peek(f, size+2) != EOF )
|
1065
1062
|
++size;
|
1066
1063
|
}
|
1064
|
+
else if ( c & 0x80 ) /* HACK: ignore utf-8 extended characters */
|
1065
|
+
continue;
|
1067
1066
|
else if ( isspace(c) || strchr("'\"()[]{}<>`", c) || c == MKD_EOLN )
|
1068
1067
|
break;
|
1069
1068
|
}
|
@@ -1208,6 +1207,29 @@ smartypants(int c, int *flags, MMIOT *f)
|
|
1208
1207
|
} /* smartypants */
|
1209
1208
|
|
1210
1209
|
|
1210
|
+
#if WITH_LATEX
|
1211
|
+
/* process latex with arbitrary 2-character ( $$ .. $$, \[ .. \], \( .. \)
|
1212
|
+
* delimiters
|
1213
|
+
*/
|
1214
|
+
static int
|
1215
|
+
mathhandler(MMIOT *f, int e1, int e2)
|
1216
|
+
{
|
1217
|
+
int i = 0;
|
1218
|
+
|
1219
|
+
while(peek(f, ++i) != EOF) {
|
1220
|
+
if (peek(f, i) == e1 && peek(f, i+1) == e2) {
|
1221
|
+
cputc(peek(f,-1), f);
|
1222
|
+
cputc(peek(f, 0), f);
|
1223
|
+
while ( i-- > -1 )
|
1224
|
+
cputc(pull(f), f);
|
1225
|
+
return 1;
|
1226
|
+
}
|
1227
|
+
}
|
1228
|
+
return 0;
|
1229
|
+
}
|
1230
|
+
#endif
|
1231
|
+
|
1232
|
+
|
1211
1233
|
/* process a body of text encased in some sort of tick marks. If it
|
1212
1234
|
* works, generate the output and return 1, otherwise just return 0 and
|
1213
1235
|
* let the caller figure it out.
|
@@ -1283,6 +1305,7 @@ text(MMIOT *f)
|
|
1283
1305
|
else
|
1284
1306
|
Qchar(c, f);
|
1285
1307
|
break;
|
1308
|
+
|
1286
1309
|
case '[': if ( tag_text(f) || !linkylinky(0, f) )
|
1287
1310
|
Qchar(c, f);
|
1288
1311
|
break;
|
@@ -1386,7 +1409,14 @@ text(MMIOT *f)
|
|
1386
1409
|
|
1387
1410
|
case EOF: Qchar('\\', f);
|
1388
1411
|
break;
|
1389
|
-
|
1412
|
+
|
1413
|
+
#if WITH_LATEX
|
1414
|
+
case '[':
|
1415
|
+
case '(': if ( mathhandler(f, '\\', (c =='(')?')':']') )
|
1416
|
+
break;
|
1417
|
+
/* else fall through to default */
|
1418
|
+
#endif
|
1419
|
+
|
1390
1420
|
default: if ( escaped(f,c) ||
|
1391
1421
|
strchr(">#.-+{}]![*_\\()`", c) )
|
1392
1422
|
Qchar(c, f);
|
@@ -1412,6 +1442,16 @@ text(MMIOT *f)
|
|
1412
1442
|
Qchar(c, f);
|
1413
1443
|
break;
|
1414
1444
|
|
1445
|
+
#if WITH_LATEX
|
1446
|
+
case '$': if ( peek(f, 1) == '$' ) {
|
1447
|
+
pull(f);
|
1448
|
+
if ( mathhandler(f, '$', '$') )
|
1449
|
+
break;
|
1450
|
+
Qchar('$', f);
|
1451
|
+
}
|
1452
|
+
/* fall through to default */
|
1453
|
+
#endif
|
1454
|
+
|
1415
1455
|
default: Qchar(c, f);
|
1416
1456
|
break;
|
1417
1457
|
}
|
@@ -1426,26 +1466,26 @@ text(MMIOT *f)
|
|
1426
1466
|
static void
|
1427
1467
|
printheader(Paragraph *pp, MMIOT *f)
|
1428
1468
|
{
|
1429
|
-
|
1430
|
-
|
1431
|
-
|
1432
|
-
|
1433
|
-
|
1434
|
-
|
1435
|
-
|
1436
|
-
|
1437
|
-
|
1438
|
-
|
1439
|
-
|
1440
|
-
|
1441
|
-
|
1442
|
-
|
1443
|
-
|
1444
|
-
|
1445
|
-
|
1469
|
+
if ( f->flags & MKD_IDANCHOR ) {
|
1470
|
+
Qprintf(f, "<h%d", pp->hnumber);
|
1471
|
+
if ( f->flags & MKD_TOC ) {
|
1472
|
+
Qstring(" id=\"", f);
|
1473
|
+
mkd_string_to_anchor(T(pp->text->text),
|
1474
|
+
S(pp->text->text),
|
1475
|
+
(mkd_sta_function_t)Qchar, f, 1, f->flags);
|
1476
|
+
Qchar('"', f);
|
1477
|
+
}
|
1478
|
+
Qchar('>', f);
|
1479
|
+
} else {
|
1480
|
+
if ( f->flags & MKD_TOC ) {
|
1481
|
+
Qstring("<a name=\"", f);
|
1482
|
+
mkd_string_to_anchor(T(pp->text->text),
|
1483
|
+
S(pp->text->text),
|
1484
|
+
(mkd_sta_function_t)Qchar, f, 1, f->flags);
|
1485
|
+
Qstring("\"></a>\n", f);
|
1486
|
+
}
|
1487
|
+
Qprintf(f, "<h%d>", pp->hnumber);
|
1446
1488
|
}
|
1447
|
-
Qprintf(f, "<h%d>", pp->hnumber);
|
1448
|
-
#endif
|
1449
1489
|
push(T(pp->text->text), S(pp->text->text), f);
|
1450
1490
|
text(f);
|
1451
1491
|
Qprintf(f, "</h%d>", pp->hnumber);
|
@@ -1812,15 +1852,19 @@ mkd_document(Document *p, char **res)
|
|
1812
1852
|
if ( p->ctx->flags & MKD_EXTRA_FOOTNOTE )
|
1813
1853
|
mkd_extra_footnotes(p->ctx);
|
1814
1854
|
p->html = 1;
|
1815
|
-
|
1816
|
-
|
1817
|
-
size = S(p->ctx->out);
|
1855
|
+
size = S(p->ctx->out);
|
1818
1856
|
|
1819
|
-
|
1820
|
-
|
1857
|
+
if ( (size == 0) || T(p->ctx->out)[size-1] ) {
|
1858
|
+
/* Add a null byte at the end of the generated html,
|
1859
|
+
* but pretend it doesn't exist.
|
1860
|
+
*/
|
1861
|
+
EXPAND(p->ctx->out) = 0;
|
1862
|
+
--S(p->ctx->out);
|
1863
|
+
}
|
1864
|
+
}
|
1821
1865
|
|
1822
1866
|
*res = T(p->ctx->out);
|
1823
|
-
return
|
1867
|
+
return S(p->ctx->out);
|
1824
1868
|
}
|
1825
1869
|
return EOF;
|
1826
1870
|
}
|
data/ext/markdown.c
CHANGED
@@ -178,20 +178,16 @@ splitline(Line *t, int cutpoint)
|
|
178
178
|
|
179
179
|
#define UNCHECK(l) ((l)->flags &= ~CHECKED)
|
180
180
|
|
181
|
-
#
|
182
|
-
# define UNLESS_FENCED(t) if (fenced) { \
|
181
|
+
#define UNLESS_FENCED(t) if (fenced) { \
|
183
182
|
other = 1; l->count += (c == ' ' ? 0 : -1); \
|
184
183
|
} else { t; }
|
185
|
-
#else
|
186
|
-
# define UNLESS_FENCED(t) t;
|
187
|
-
#endif
|
188
184
|
|
189
185
|
/*
|
190
186
|
* walk a line, seeing if it's any of half a dozen interesting regular
|
191
187
|
* types.
|
192
188
|
*/
|
193
189
|
static void
|
194
|
-
checkline(Line *l)
|
190
|
+
checkline(Line *l, DWORD flags)
|
195
191
|
{
|
196
192
|
int eol, i;
|
197
193
|
int dashes = 0, spaces = 0,
|
@@ -210,6 +206,7 @@ checkline(Line *l)
|
|
210
206
|
|
211
207
|
for (i=l->dle; i<eol; i++) {
|
212
208
|
register int c = T(l->text)[i];
|
209
|
+
int is_fence_char = 0;
|
213
210
|
|
214
211
|
if ( c != ' ' ) l->count++;
|
215
212
|
|
@@ -219,14 +216,20 @@ checkline(Line *l)
|
|
219
216
|
case '=': equals = 1; break;
|
220
217
|
case '_': UNLESS_FENCED(underscores = 1); break;
|
221
218
|
case '*': stars = 1; break;
|
222
|
-
#if WITH_FENCED_CODE
|
223
|
-
case '~': if (other) return; fenced = 1; tildes = 1; break;
|
224
|
-
case '`': if (other) return; fenced = 1; backticks = 1; break;
|
225
|
-
#endif
|
226
219
|
default:
|
227
|
-
|
228
|
-
|
229
|
-
|
220
|
+
if (flags & MKD_FENCEDCODE) {
|
221
|
+
switch (c) {
|
222
|
+
case '~': if (other) return; is_fence_char = 1; tildes = 1; break;
|
223
|
+
case '`': if (other) return; is_fence_char = 1; backticks = 1; break;
|
224
|
+
}
|
225
|
+
if (is_fence_char) {
|
226
|
+
fenced = 1;
|
227
|
+
break;
|
228
|
+
}
|
229
|
+
}
|
230
|
+
other = 1;
|
231
|
+
l->count--;
|
232
|
+
if (!fenced) return;
|
230
233
|
}
|
231
234
|
}
|
232
235
|
|
@@ -242,28 +245,32 @@ checkline(Line *l)
|
|
242
245
|
if ( stars || underscores ) { l->kind = chk_hr; }
|
243
246
|
else if ( dashes ) { l->kind = chk_dash; }
|
244
247
|
else if ( equals ) { l->kind = chk_equal; }
|
245
|
-
#if WITH_FENCED_CODE
|
246
248
|
else if ( tildes ) { l->kind = chk_tilde; }
|
247
249
|
else if ( backticks ) { l->kind = chk_backtick; }
|
248
|
-
#endif
|
249
250
|
}
|
250
251
|
|
251
252
|
|
252
253
|
|
254
|
+
/* markdown only does special handling of comments if the comment end
|
255
|
+
* is at the end of a line
|
256
|
+
*/
|
253
257
|
static Line *
|
254
258
|
commentblock(Paragraph *p, int *unclosed)
|
255
259
|
{
|
256
260
|
Line *t, *ret;
|
257
261
|
char *end;
|
258
262
|
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
263
|
+
for ( t = p->text; t ; t = t->next) {
|
264
|
+
if ( end = strstr(T(t->text), "-->") ) {
|
265
|
+
if ( nextnonblank(t, 3 + (end - T(t->text))) < S(t->text) )
|
266
|
+
continue;
|
267
|
+
/*splitline(t, 3 + (end - T(t->text)) );*/
|
268
|
+
ret = t->next;
|
269
|
+
t->next = 0;
|
270
|
+
return ret;
|
271
|
+
}
|
266
272
|
}
|
273
|
+
|
267
274
|
*unclosed = 1;
|
268
275
|
return t;
|
269
276
|
|
@@ -307,8 +314,8 @@ htmlblock(Paragraph *p, struct kw *tag, int *unclosed)
|
|
307
314
|
else {
|
308
315
|
if ( closing = (c == '/') ) c = flogetc(&f);
|
309
316
|
|
310
|
-
for ( i=0; i < tag->size; c=flogetc(&f) ) {
|
311
|
-
if ( tag->id[i
|
317
|
+
for ( i=0; i < tag->size; i++, c=flogetc(&f) ) {
|
318
|
+
if ( tag->id[i] != toupper(c) )
|
312
319
|
break;
|
313
320
|
}
|
314
321
|
|
@@ -372,10 +379,10 @@ iscode(Line *t)
|
|
372
379
|
|
373
380
|
|
374
381
|
static inline int
|
375
|
-
ishr(Line *t)
|
382
|
+
ishr(Line *t, DWORD flags)
|
376
383
|
{
|
377
384
|
if ( ! (t->flags & CHECKED) )
|
378
|
-
checkline(t);
|
385
|
+
checkline(t, flags);
|
379
386
|
|
380
387
|
if ( t->count > 2 )
|
381
388
|
return t->kind == chk_hr || t->kind == chk_dash || t->kind == chk_equal;
|
@@ -384,7 +391,7 @@ ishr(Line *t)
|
|
384
391
|
|
385
392
|
|
386
393
|
static int
|
387
|
-
issetext(Line *t, int *htyp)
|
394
|
+
issetext(Line *t, int *htyp, DWORD flags)
|
388
395
|
{
|
389
396
|
Line *n;
|
390
397
|
|
@@ -394,7 +401,7 @@ issetext(Line *t, int *htyp)
|
|
394
401
|
|
395
402
|
if ( (n = t->next) ) {
|
396
403
|
if ( !(n->flags & CHECKED) )
|
397
|
-
checkline(n);
|
404
|
+
checkline(n, flags);
|
398
405
|
|
399
406
|
if ( n->kind == chk_dash || n->kind == chk_equal ) {
|
400
407
|
*htyp = SETEXT;
|
@@ -406,7 +413,7 @@ issetext(Line *t, int *htyp)
|
|
406
413
|
|
407
414
|
|
408
415
|
static int
|
409
|
-
ishdr(Line *t, int *htyp)
|
416
|
+
ishdr(Line *t, int *htyp, DWORD flags)
|
410
417
|
{
|
411
418
|
/* ANY leading `#`'s make this into an ETX header
|
412
419
|
*/
|
@@ -417,27 +424,28 @@ ishdr(Line *t, int *htyp)
|
|
417
424
|
|
418
425
|
/* And if not, maybe it's a SETEXT header instead
|
419
426
|
*/
|
420
|
-
return issetext(t, htyp);
|
427
|
+
return issetext(t, htyp, flags);
|
421
428
|
}
|
422
429
|
|
423
430
|
|
424
431
|
static inline int
|
425
|
-
end_of_block(Line *t)
|
432
|
+
end_of_block(Line *t, DWORD flags)
|
426
433
|
{
|
427
434
|
int dummy;
|
428
435
|
|
429
436
|
if ( !t )
|
430
437
|
return 0;
|
431
438
|
|
432
|
-
return ( (S(t->text) <= t->dle) || ishr(t) || ishdr(t, &dummy) );
|
439
|
+
return ( (S(t->text) <= t->dle) || ishr(t, flags) || ishdr(t, &dummy, flags) );
|
433
440
|
}
|
434
441
|
|
435
442
|
|
436
443
|
static Line*
|
437
|
-
is_discount_dt(Line *t, int *clip)
|
444
|
+
is_discount_dt(Line *t, int *clip, DWORD flags)
|
438
445
|
{
|
439
|
-
|
440
|
-
|
446
|
+
if ( !(flags & MKD_NODLDISCOUNT)
|
447
|
+
&& t
|
448
|
+
&& t->next
|
441
449
|
&& (S(t->text) > 2)
|
442
450
|
&& (t->dle == 0)
|
443
451
|
&& (T(t->text)[0] == '=')
|
@@ -447,9 +455,8 @@ is_discount_dt(Line *t, int *clip)
|
|
447
455
|
return t;
|
448
456
|
}
|
449
457
|
else
|
450
|
-
return is_discount_dt(t->next, clip);
|
458
|
+
return is_discount_dt(t->next, clip, flags);
|
451
459
|
}
|
452
|
-
#endif
|
453
460
|
return 0;
|
454
461
|
}
|
455
462
|
|
@@ -463,15 +470,15 @@ is_extra_dd(Line *t)
|
|
463
470
|
|
464
471
|
|
465
472
|
static Line*
|
466
|
-
is_extra_dt(Line *t, int *clip)
|
473
|
+
is_extra_dt(Line *t, int *clip, DWORD flags)
|
467
474
|
{
|
468
|
-
|
469
|
-
|
470
|
-
|
475
|
+
if ( flags & MKD_DLEXTRA
|
476
|
+
&& t
|
477
|
+
&& t->next && S(t->text) && T(t->text)[0] != '='
|
471
478
|
&& T(t->text)[S(t->text)-1] != '=') {
|
472
479
|
Line *x;
|
473
480
|
|
474
|
-
if ( iscode(t) || end_of_block(t) )
|
481
|
+
if ( iscode(t) || end_of_block(t, flags) )
|
475
482
|
return 0;
|
476
483
|
|
477
484
|
if ( (x = skipempty(t->next)) && is_extra_dd(x) ) {
|
@@ -479,25 +486,24 @@ is_extra_dt(Line *t, int *clip)
|
|
479
486
|
return t;
|
480
487
|
}
|
481
488
|
|
482
|
-
if ( x=is_extra_dt(t->next, clip) )
|
489
|
+
if ( x=is_extra_dt(t->next, clip, flags) )
|
483
490
|
return x;
|
484
491
|
}
|
485
|
-
#endif
|
486
492
|
return 0;
|
487
493
|
}
|
488
494
|
|
489
495
|
|
490
496
|
static Line*
|
491
|
-
isdefinition(Line *t, int *clip, int *kind)
|
497
|
+
isdefinition(Line *t, int *clip, int *kind, DWORD flags)
|
492
498
|
{
|
493
499
|
Line *ret;
|
494
500
|
|
495
501
|
*kind = 1;
|
496
|
-
if ( ret = is_discount_dt(t,clip) )
|
502
|
+
if ( ret = is_discount_dt(t,clip,flags) )
|
497
503
|
return ret;
|
498
504
|
|
499
505
|
*kind=2;
|
500
|
-
return is_extra_dt(t,clip);
|
506
|
+
return is_extra_dt(t,clip,flags);
|
501
507
|
}
|
502
508
|
|
503
509
|
|
@@ -507,10 +513,10 @@ islist(Line *t, int *clip, DWORD flags, int *list_type)
|
|
507
513
|
int i, j;
|
508
514
|
char *q;
|
509
515
|
|
510
|
-
if ( end_of_block(t) )
|
516
|
+
if ( end_of_block(t, flags) )
|
511
517
|
return 0;
|
512
518
|
|
513
|
-
if ( !(flags & (MKD_NODLIST|MKD_STRICT)) && isdefinition(t,clip,list_type) )
|
519
|
+
if ( !(flags & (MKD_NODLIST|MKD_STRICT)) && isdefinition(t,clip,list_type,flags) )
|
514
520
|
return DL;
|
515
521
|
|
516
522
|
if ( strchr("*-+", T(t->text)[t->dle]) && isspace(T(t->text)[t->dle+1]) ) {
|
@@ -615,12 +621,14 @@ codeblock(Paragraph *p)
|
|
615
621
|
}
|
616
622
|
|
617
623
|
|
618
|
-
#ifdef WITH_FENCED_CODE
|
619
624
|
static int
|
620
|
-
iscodefence(Line *r, int size, line_type kind)
|
625
|
+
iscodefence(Line *r, int size, line_type kind, DWORD flags)
|
621
626
|
{
|
627
|
+
if ( !(flags & MKD_FENCEDCODE) )
|
628
|
+
return 0;
|
629
|
+
|
622
630
|
if ( !(r->flags & CHECKED) )
|
623
|
-
checkline(r);
|
631
|
+
checkline(r, flags);
|
624
632
|
|
625
633
|
if ( kind )
|
626
634
|
return (r->kind == kind) && (r->count >= size);
|
@@ -629,7 +637,7 @@ iscodefence(Line *r, int size, line_type kind)
|
|
629
637
|
}
|
630
638
|
|
631
639
|
static Paragraph *
|
632
|
-
fencedcodeblock(ParagraphRoot *d, Line **ptr)
|
640
|
+
fencedcodeblock(ParagraphRoot *d, Line **ptr, DWORD flags)
|
633
641
|
{
|
634
642
|
Line *first, *r;
|
635
643
|
Paragraph *ret;
|
@@ -638,14 +646,14 @@ fencedcodeblock(ParagraphRoot *d, Line **ptr)
|
|
638
646
|
|
639
647
|
/* don't allow zero-length code fences
|
640
648
|
*/
|
641
|
-
if ( (first->next == 0) || iscodefence(first->next, first->count, 0) )
|
649
|
+
if ( (first->next == 0) || iscodefence(first->next, first->count, 0, flags) )
|
642
650
|
return 0;
|
643
651
|
|
644
652
|
/* find the closing fence, discard the fences,
|
645
653
|
* return a Paragraph with the contents
|
646
654
|
*/
|
647
655
|
for ( r = first; r && r->next; r = r->next )
|
648
|
-
if ( iscodefence(r->next, first->count, first->kind) ) {
|
656
|
+
if ( iscodefence(r->next, first->count, first->kind, flags) ) {
|
649
657
|
(*ptr) = r->next->next;
|
650
658
|
ret = Pp(d, first->next, CODE);
|
651
659
|
if (S(first->text) - first->count > 0) {
|
@@ -663,7 +671,6 @@ fencedcodeblock(ParagraphRoot *d, Line **ptr)
|
|
663
671
|
}
|
664
672
|
return 0;
|
665
673
|
}
|
666
|
-
#endif
|
667
674
|
|
668
675
|
|
669
676
|
static int
|
@@ -689,7 +696,7 @@ endoftextblock(Line *t, int toplevelblock, DWORD flags)
|
|
689
696
|
{
|
690
697
|
int z;
|
691
698
|
|
692
|
-
if ( end_of_block(t) || isquote(t) )
|
699
|
+
if ( end_of_block(t, flags) || isquote(t) )
|
693
700
|
return 1;
|
694
701
|
|
695
702
|
/* HORRIBLE STANDARDS KLUDGES:
|
@@ -878,9 +885,9 @@ listitem(Paragraph *p, int indent, DWORD flags, linefn check)
|
|
878
885
|
indent = clip ? clip : 2;
|
879
886
|
}
|
880
887
|
|
881
|
-
if ( (q->dle < indent) && (ishr(q) || islist(q,&z,flags,&z)
|
888
|
+
if ( (q->dle < indent) && (ishr(q,flags) || islist(q,&z,flags,&z)
|
882
889
|
|| (check && (*check)(q)))
|
883
|
-
&& !issetext(q,&z) ) {
|
890
|
+
&& !issetext(q,&z,flags) ) {
|
884
891
|
q = t->next;
|
885
892
|
t->next = 0;
|
886
893
|
return q;
|
@@ -902,7 +909,7 @@ definition_block(Paragraph *top, int clip, MMIOT *f, int kind)
|
|
902
909
|
|
903
910
|
while (( labels = q )) {
|
904
911
|
|
905
|
-
if ( (q = isdefinition(labels, &z, &kind)) == 0 )
|
912
|
+
if ( (q = isdefinition(labels, &z, &kind, f->flags)) == 0 )
|
906
913
|
break;
|
907
914
|
|
908
915
|
if ( (text = skipempty(q->next)) == 0 )
|
@@ -1254,11 +1261,9 @@ compile(Line *ptr, int toplevel, MMIOT *f)
|
|
1254
1261
|
|
1255
1262
|
ptr = codeblock(p);
|
1256
1263
|
}
|
1257
|
-
|
1258
|
-
else if ( iscodefence(ptr,3,0) && (p=fencedcodeblock(&d, &ptr)) )
|
1264
|
+
else if ( iscodefence(ptr,3,0,f->flags) && (p=fencedcodeblock(&d, &ptr, f->flags)) )
|
1259
1265
|
/* yay, it's already done */ ;
|
1260
|
-
|
1261
|
-
else if ( ishr(ptr) ) {
|
1266
|
+
else if ( ishr(ptr, f->flags) ) {
|
1262
1267
|
p = Pp(&d, 0, HR);
|
1263
1268
|
r = ptr;
|
1264
1269
|
ptr = ptr->next;
|
@@ -1280,7 +1285,7 @@ compile(Line *ptr, int toplevel, MMIOT *f)
|
|
1280
1285
|
p->down = compile(p->text, 1, f);
|
1281
1286
|
p->text = 0;
|
1282
1287
|
}
|
1283
|
-
else if ( ishdr(ptr, &hdr_type) ) {
|
1288
|
+
else if ( ishdr(ptr, &hdr_type, f->flags) ) {
|
1284
1289
|
p = Pp(&d, ptr, HDR);
|
1285
1290
|
ptr = headerblock(p, hdr_type);
|
1286
1291
|
}
|
@@ -1321,14 +1326,24 @@ mkd_compile(Document *doc, DWORD flags)
|
|
1321
1326
|
if ( !doc )
|
1322
1327
|
return 0;
|
1323
1328
|
|
1324
|
-
|
1325
|
-
|
1329
|
+
flags &= USER_FLAGS;
|
1330
|
+
|
1331
|
+
if ( doc->compiled ) {
|
1332
|
+
if ( doc->ctx->flags == flags )
|
1333
|
+
return 1;
|
1334
|
+
else {
|
1335
|
+
if ( doc->code)
|
1336
|
+
___mkd_freeParagraph(doc->code);
|
1337
|
+
if ( doc->ctx->footnotes )
|
1338
|
+
___mkd_freefootnotes(doc->ctx);
|
1339
|
+
}
|
1340
|
+
}
|
1326
1341
|
|
1327
1342
|
doc->compiled = 1;
|
1328
1343
|
memset(doc->ctx, 0, sizeof(MMIOT) );
|
1329
1344
|
doc->ctx->ref_prefix= doc->ref_prefix;
|
1330
1345
|
doc->ctx->cb = &(doc->cb);
|
1331
|
-
doc->ctx->flags = flags
|
1346
|
+
doc->ctx->flags = flags;
|
1332
1347
|
CREATE(doc->ctx->in);
|
1333
1348
|
doc->ctx->footnotes = malloc(sizeof doc->ctx->footnotes[0]);
|
1334
1349
|
doc->ctx->footnotes->reference = 0;
|
data/ext/markdown.h
CHANGED
@@ -129,8 +129,14 @@ typedef struct mmiot {
|
|
129
129
|
#define MKD_NODLIST 0x00100000
|
130
130
|
#define MKD_EXTRA_FOOTNOTE 0x00200000
|
131
131
|
#define MKD_NOSTYLE 0x00400000
|
132
|
-
#define
|
133
|
-
#define
|
132
|
+
#define MKD_NODLDISCOUNT 0x00800000
|
133
|
+
#define MKD_DLEXTRA 0x01000000
|
134
|
+
#define MKD_FENCEDCODE 0x02000000
|
135
|
+
#define MKD_IDANCHOR 0x04000000
|
136
|
+
#define MKD_GITHUBTAGS 0x08000000
|
137
|
+
#define MKD_URLENCODEDANCHOR 0x10000000
|
138
|
+
#define IS_LABEL 0x20000000
|
139
|
+
#define USER_FLAGS 0x3FFFFFFF
|
134
140
|
#define INPUT_MASK (MKD_NOHEADER|MKD_TABSTOP)
|
135
141
|
|
136
142
|
Callback_data *cb;
|
@@ -190,7 +196,7 @@ extern int mkd_generateline(char *, int, FILE*, DWORD);
|
|
190
196
|
extern void mkd_basename(Document*, char *);
|
191
197
|
|
192
198
|
typedef int (*mkd_sta_function_t)(const int,const void*);
|
193
|
-
extern void mkd_string_to_anchor(char*,int, mkd_sta_function_t, void*, int);
|
199
|
+
extern void mkd_string_to_anchor(char*,int, mkd_sta_function_t, void*, int, DWORD);
|
194
200
|
|
195
201
|
extern Document *mkd_in(FILE *, DWORD);
|
196
202
|
extern Document *mkd_string(const char*,int, DWORD);
|
@@ -224,4 +230,9 @@ extern void __mkd_header_dle(Line *);
|
|
224
230
|
|
225
231
|
extern int __mkd_io_strget(struct string_stream *);
|
226
232
|
|
233
|
+
/* utility function to do some operation and exit the current function
|
234
|
+
* if it fails
|
235
|
+
*/
|
236
|
+
#define DO_OR_DIE(op) if ( (op) == EOF ) return EOF; else 1
|
237
|
+
|
227
238
|
#endif/*_MARKDOWN_D*/
|
data/ext/mkdio.c
CHANGED
@@ -16,6 +16,7 @@
|
|
16
16
|
|
17
17
|
typedef ANCHOR(Line) LineAnchor;
|
18
18
|
|
19
|
+
|
19
20
|
/* create a new blank Document
|
20
21
|
*/
|
21
22
|
Document*
|
@@ -183,15 +184,13 @@ mkd_generatehtml(Document *p, FILE *output)
|
|
183
184
|
char *doc;
|
184
185
|
int szdoc;
|
185
186
|
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
}
|
194
|
-
return -1;
|
187
|
+
DO_OR_DIE( szdoc = mkd_document(p,&doc) );
|
188
|
+
if ( p->ctx->flags & MKD_CDATA )
|
189
|
+
DO_OR_DIE( mkd_generatexml(doc, szdoc, output) );
|
190
|
+
else if ( fwrite(doc, szdoc, 1, output) != 1 )
|
191
|
+
return EOF;
|
192
|
+
DO_OR_DIE( putc('\n', output) );
|
193
|
+
return 0;
|
195
194
|
}
|
196
195
|
|
197
196
|
|
@@ -213,37 +212,33 @@ markdown(Document *document, FILE *out, int flags)
|
|
213
212
|
*/
|
214
213
|
void
|
215
214
|
mkd_string_to_anchor(char *s, int len, mkd_sta_function_t outchar,
|
216
|
-
void *out, int labelformat
|
215
|
+
void *out, int labelformat,
|
216
|
+
DWORD flags)
|
217
217
|
{
|
218
|
-
#if WITH_URLENCODED_ANCHOR
|
219
218
|
static const unsigned char hexchars[] = "0123456789abcdef";
|
220
|
-
#endif
|
221
219
|
unsigned char c;
|
222
220
|
|
223
221
|
int i, size;
|
224
222
|
char *line;
|
225
223
|
|
226
224
|
size = mkd_line(s, len, &line, IS_LABEL);
|
227
|
-
|
228
|
-
|
229
|
-
|
225
|
+
|
226
|
+
if ( !(flags & MKD_URLENCODEDANCHOR)
|
227
|
+
&& labelformat
|
228
|
+
&& (size>0) && !isalpha(line[0]) )
|
230
229
|
(*outchar)('L',out);
|
231
|
-
#endif
|
232
230
|
for ( i=0; i < size ; i++ ) {
|
233
231
|
c = line[i];
|
234
232
|
if ( labelformat ) {
|
235
233
|
if ( isalnum(c) || (c == '_') || (c == ':') || (c == '-') || (c == '.' ) )
|
236
234
|
(*outchar)(c, out);
|
237
|
-
else
|
238
|
-
#if WITH_URLENCODED_ANCHOR
|
239
|
-
{
|
235
|
+
else if ( flags & MKD_URLENCODEDANCHOR ) {
|
240
236
|
(*outchar)('%', out);
|
241
237
|
(*outchar)(hexchars[c >> 4 & 0xf], out);
|
242
238
|
(*outchar)(hexchars[c & 0xf], out);
|
243
239
|
}
|
244
|
-
|
240
|
+
else
|
245
241
|
(*outchar)('.', out);
|
246
|
-
#endif
|
247
242
|
}
|
248
243
|
else
|
249
244
|
(*outchar)(c,out);
|
@@ -302,15 +297,16 @@ int
|
|
302
297
|
mkd_generateline(char *bfr, int size, FILE *output, DWORD flags)
|
303
298
|
{
|
304
299
|
MMIOT f;
|
300
|
+
int status;
|
305
301
|
|
306
302
|
mkd_parse_line(bfr, size, &f, flags);
|
307
303
|
if ( flags & MKD_CDATA )
|
308
|
-
mkd_generatexml(T(f.out), S(f.out), output);
|
304
|
+
status = mkd_generatexml(T(f.out), S(f.out), output) != EOF;
|
309
305
|
else
|
310
|
-
fwrite(T(f.out), S(f.out), 1, output);
|
306
|
+
status = fwrite(T(f.out), S(f.out), 1, output) == S(f.out);
|
311
307
|
|
312
308
|
___mkd_freemmiot(&f, 0);
|
313
|
-
return 0;
|
309
|
+
return status ? 0 : EOF;
|
314
310
|
}
|
315
311
|
|
316
312
|
|
data/ext/mkdio.h
CHANGED
@@ -106,6 +106,13 @@ void mkd_ref_prefix(MMIOT*, char*);
|
|
106
106
|
#define MKD_NODLIST 0x00100000 /* forbid definition lists */
|
107
107
|
#define MKD_EXTRA_FOOTNOTE 0x00200000 /* enable markdown extra-style footnotes */
|
108
108
|
#define MKD_NOSTYLE 0x00400000 /* don't extract <style> blocks */
|
109
|
+
#define MKD_NODLDISCOUNT 0x00800000 /* disable discount-style definition lists */
|
110
|
+
#define MKD_DLEXTRA 0x01000000 /* enable extra-style definition lists */
|
111
|
+
#define MKD_FENCEDCODE 0x02000000 /* enabled fenced code blocks */
|
112
|
+
#define MKD_IDANCHOR 0x04000000 /* use id= anchors for TOC links */
|
113
|
+
#define MKD_GITHUBTAGS 0x08000000 /* allow dash and underscore in element names */
|
114
|
+
#define MKD_URLENCODEDANCHOR 0x10000000 /* urlencode non-identifier chars instead of replacing with dots */
|
115
|
+
|
109
116
|
#define MKD_EMBED MKD_NOLINKS|MKD_NOIMAGE|MKD_TAGTEXT
|
110
117
|
|
111
118
|
/* special flags for mkd_in() and mkd_string()
|
data/ext/pgm_options.c
CHANGED
@@ -25,7 +25,7 @@ static struct _opt {
|
|
25
25
|
char *name;
|
26
26
|
char *desc;
|
27
27
|
int off;
|
28
|
-
int skip;
|
28
|
+
int skip; /* this opt is a synonym */
|
29
29
|
int sayenable;
|
30
30
|
mkd_flag_t flag;
|
31
31
|
} opts[] = {
|
@@ -55,6 +55,12 @@ static struct _opt {
|
|
55
55
|
{ "footnotes", "markdown extra footnotes", 0, 0, 1, MKD_EXTRA_FOOTNOTE },
|
56
56
|
{ "footnote", "markdown extra footnotes", 0, 1, 1, MKD_EXTRA_FOOTNOTE },
|
57
57
|
{ "style", "extract style blocks", 1, 0, 1, MKD_NOSTYLE },
|
58
|
+
{ "dldiscount", "discount-style definition lists", 1, 0, 1, MKD_NODLDISCOUNT },
|
59
|
+
{ "dlextra", "extra-style definition lists", 0, 0, 1, MKD_DLEXTRA },
|
60
|
+
{ "fencedcode", "fenced code blocks", 0, 0, 1, MKD_FENCEDCODE },
|
61
|
+
{ "idanchor", "id= anchors in TOC", 0, 0, 1, MKD_IDANCHOR },
|
62
|
+
{ "githubtags", "permit - and _ in element names", 0, 0, 0, MKD_GITHUBTAGS },
|
63
|
+
{ "urlencodedanchor", "urlencode special chars in TOC links", 0, 0, 0, MKD_URLENCODEDANCHOR },
|
58
64
|
} ;
|
59
65
|
|
60
66
|
#define NR(x) (sizeof x / sizeof x[0])
|
data/ext/rdiscount.c
CHANGED
@@ -14,6 +14,9 @@ typedef struct {
|
|
14
14
|
* The following flags are handled specially:
|
15
15
|
* - MKD_TABSTOP: Always set.
|
16
16
|
* - MKD_NOHEADER: Always set.
|
17
|
+
* - MKD_DLEXTRA: Always set. (For compatibility with RDiscount 2.1.8 and earlier.)
|
18
|
+
* - MKD_FENCEDCODE: Always set. (For compatibility with RDiscount 2.1.8 and earlier.)
|
19
|
+
* - MKD_GITHUBTAGS: Always set. (For compatibility with RDiscount 2.1.8 and earlier.)
|
17
20
|
* - MKD_NOPANTS: Set unless the "smart" accessor returns true.
|
18
21
|
*
|
19
22
|
* See rb_rdiscount__get_flags() for the detailed implementation.
|
@@ -119,7 +122,7 @@ int rb_rdiscount__get_flags(VALUE ruby_obj)
|
|
119
122
|
AccessorFlagPair *entry;
|
120
123
|
|
121
124
|
/* compile flags */
|
122
|
-
int flags = MKD_TABSTOP | MKD_NOHEADER;
|
125
|
+
int flags = MKD_TABSTOP | MKD_NOHEADER | MKD_DLEXTRA | MKD_FENCEDCODE | MKD_GITHUBTAGS;
|
123
126
|
|
124
127
|
/* The "smart" accessor turns OFF the MKD_NOPANTS flag. */
|
125
128
|
if ( rb_funcall(ruby_obj, rb_intern("smart"), 0) != Qtrue ) {
|
data/ext/toc.c
CHANGED
@@ -62,11 +62,11 @@ mkd_toc(Document *p, char **doc)
|
|
62
62
|
Csprintf(&res, "%*s<li><a href=\"#", srcp->hnumber, "");
|
63
63
|
mkd_string_to_anchor(T(srcp->text->text),
|
64
64
|
S(srcp->text->text),
|
65
|
-
(mkd_sta_function_t)Csputc, &res,1);
|
65
|
+
(mkd_sta_function_t)Csputc, &res,1,p->ctx->flags);
|
66
66
|
Csprintf(&res, "\">");
|
67
67
|
mkd_string_to_anchor(T(srcp->text->text),
|
68
68
|
S(srcp->text->text),
|
69
|
-
(mkd_sta_function_t)Csputc, &res,0);
|
69
|
+
(mkd_sta_function_t)Csputc, &res,0,p->ctx->flags);
|
70
70
|
Csprintf(&res, "</a>");
|
71
71
|
|
72
72
|
first = 0;
|
data/ext/version.c
CHANGED
@@ -7,24 +7,7 @@ char markdown_version[] = VERSION
|
|
7
7
|
#if USE_AMALLOC
|
8
8
|
" DEBUG"
|
9
9
|
#endif
|
10
|
-
#if
|
11
|
-
|
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"
|
26
|
-
#endif
|
27
|
-
#if WITH_FENCED_CODE
|
28
|
-
" FENCED-CODE"
|
10
|
+
#if WITH_LATEX
|
11
|
+
" LATEX"
|
29
12
|
#endif
|
30
13
|
;
|
data/ext/xml.c
CHANGED
data/ext/xmlpage.c
CHANGED
@@ -22,27 +22,25 @@ mkd_xhtmlpage(Document *p, int flags, FILE *out)
|
|
22
22
|
extern char *mkd_doc_title(Document *);
|
23
23
|
|
24
24
|
if ( mkd_compile(p, flags) ) {
|
25
|
-
fprintf(out, "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
|
26
|
-
|
27
|
-
|
28
|
-
|
25
|
+
DO_OR_DIE( fprintf(out, "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
|
26
|
+
"<!DOCTYPE html "
|
27
|
+
" PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\""
|
28
|
+
" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">\n"
|
29
|
+
"<html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"en\" lang=\"en\">\n") );
|
29
30
|
|
30
|
-
fprintf(out, "<
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
fprintf(out, "<body>\n");
|
39
|
-
mkd_generatehtml(p, out);
|
40
|
-
fprintf(out, "</body>\n");
|
41
|
-
fprintf(out, "</html>\n");
|
31
|
+
DO_OR_DIE( fprintf(out, "<head>\n") );
|
32
|
+
if ( title = mkd_doc_title(p) ) {
|
33
|
+
DO_OR_DIE( fprintf(out, "<title>%s</title>\n", title) );
|
34
|
+
}
|
35
|
+
DO_OR_DIE( mkd_generatecss(p, out) );
|
36
|
+
DO_OR_DIE( fprintf(out, "</head>\n"
|
37
|
+
"<body>\n") );
|
42
38
|
|
43
|
-
|
39
|
+
DO_OR_DIE( mkd_generatehtml(p, out) );
|
40
|
+
DO_OR_DIE( fprintf(out, "</body>\n"
|
41
|
+
"</html>\n") );
|
44
42
|
|
45
43
|
return 0;
|
46
44
|
}
|
47
|
-
return
|
45
|
+
return EOF;
|
48
46
|
}
|
data/lib/rdiscount.rb
CHANGED
data/rdiscount.gemspec
CHANGED
@@ -1,12 +1,12 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = 'rdiscount'
|
3
|
-
s.version = '2.
|
3
|
+
s.version = '2.2.0'
|
4
4
|
s.summary = "Fast Implementation of Gruber's Markdown in C"
|
5
5
|
s.date = '2015-02-01'
|
6
|
-
s.email = '
|
6
|
+
s.email = 'david@dafoster.net'
|
7
7
|
s.homepage = 'http://dafoster.net/projects/rdiscount/'
|
8
8
|
s.authors = ["Ryan Tomayko", "David Loren Parsons", "Andrew White", "David Foster"]
|
9
|
-
s.license = "BSD"
|
9
|
+
s.license = "BSD-3-Clause"
|
10
10
|
# = MANIFEST =
|
11
11
|
s.files = %w[
|
12
12
|
BUILDING
|
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.
|
4
|
+
version: 2.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ryan Tomayko
|
@@ -14,7 +14,7 @@ cert_chain: []
|
|
14
14
|
date: 2015-02-01 00:00:00.000000000 Z
|
15
15
|
dependencies: []
|
16
16
|
description:
|
17
|
-
email:
|
17
|
+
email: david@dafoster.net
|
18
18
|
executables:
|
19
19
|
- rdiscount
|
20
20
|
extensions:
|
@@ -72,7 +72,7 @@ files:
|
|
72
72
|
- test/rdiscount_test.rb
|
73
73
|
homepage: http://dafoster.net/projects/rdiscount/
|
74
74
|
licenses:
|
75
|
-
- BSD
|
75
|
+
- BSD-3-Clause
|
76
76
|
metadata: {}
|
77
77
|
post_install_message:
|
78
78
|
rdoc_options: []
|
@@ -90,7 +90,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
90
90
|
version: '0'
|
91
91
|
requirements: []
|
92
92
|
rubyforge_project: wink
|
93
|
-
rubygems_version: 2.
|
93
|
+
rubygems_version: 2.5.1
|
94
94
|
signing_key:
|
95
95
|
specification_version: 4
|
96
96
|
summary: Fast Implementation of Gruber's Markdown in C
|