rdiscountwl 1.0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/BUILDING +151 -0
- data/COPYING +33 -0
- data/README.markdown +73 -0
- data/Rakefile +224 -0
- data/bin/rdiscount +13 -0
- data/ext/Csio.c +61 -0
- data/ext/VERSION +1 -0
- data/ext/amalloc.c +135 -0
- data/ext/amalloc.h +29 -0
- data/ext/basename.c +43 -0
- data/ext/blocktags +33 -0
- data/ext/config.h +25 -0
- data/ext/css.c +87 -0
- data/ext/cstring.h +77 -0
- data/ext/docheader.c +49 -0
- data/ext/dumptree.c +151 -0
- data/ext/emmatch.c +188 -0
- data/ext/extconf.rb +49 -0
- data/ext/flags.c +91 -0
- data/ext/generate.c +1865 -0
- data/ext/github_flavoured.c +100 -0
- data/ext/html5.c +22 -0
- data/ext/markdown.c +1361 -0
- data/ext/markdown.h +238 -0
- data/ext/mkdio.c +360 -0
- data/ext/mkdio.h +122 -0
- data/ext/mktags.c +89 -0
- data/ext/pgm_options.c +146 -0
- data/ext/pgm_options.h +9 -0
- data/ext/rdiscount.c +150 -0
- data/ext/resource.c +159 -0
- data/ext/setup.c +39 -0
- data/ext/tags.c +94 -0
- data/ext/tags.h +19 -0
- data/ext/toc.c +114 -0
- data/ext/version.c +13 -0
- data/ext/xml.c +82 -0
- data/ext/xmlpage.c +46 -0
- data/lib/markdown.rb +1 -0
- data/lib/rdiscount.rb +108 -0
- data/man/markdown.7 +1020 -0
- data/man/rdiscount.1 +22 -0
- data/man/rdiscount.1.ronn +24 -0
- data/rdiscount.gemspec +71 -0
- data/test/benchmark.rb +56 -0
- data/test/benchmark.txt +306 -0
- data/test/markdown_test.rb +158 -0
- data/test/rdiscount_test.rb +276 -0
- metadata +99 -0
@@ -0,0 +1,100 @@
|
|
1
|
+
|
2
|
+
/*
|
3
|
+
* github_flavoured -- implement the obnoxious "returns are hard newlines"
|
4
|
+
* feature in github flavoured markdown.
|
5
|
+
*
|
6
|
+
* Copyright (C) 2012 David L Parsons.
|
7
|
+
* The redistribution terms are provided in the COPYRIGHT file that must
|
8
|
+
* be distributed with this source code.
|
9
|
+
*/
|
10
|
+
#include "config.h"
|
11
|
+
#include <stdio.h>
|
12
|
+
#include <stdlib.h>
|
13
|
+
#include <ctype.h>
|
14
|
+
|
15
|
+
#include "cstring.h"
|
16
|
+
#include "markdown.h"
|
17
|
+
#include "amalloc.h"
|
18
|
+
|
19
|
+
/* build a Document from any old input.
|
20
|
+
*/
|
21
|
+
typedef int (*getc_func)(void*);
|
22
|
+
|
23
|
+
Document *
|
24
|
+
gfm_populate(getc_func getc, void* ctx, int flags)
|
25
|
+
{
|
26
|
+
Cstring line;
|
27
|
+
Document *a = __mkd_new_Document();
|
28
|
+
int c;
|
29
|
+
int pandoc = 0;
|
30
|
+
|
31
|
+
if ( !a ) return 0;
|
32
|
+
|
33
|
+
a->tabstop = (flags & MKD_TABSTOP) ? 4 : TABSTOP;
|
34
|
+
|
35
|
+
CREATE(line);
|
36
|
+
|
37
|
+
while ( (c = (*getc)(ctx)) != EOF ) {
|
38
|
+
if ( c == '\n' ) {
|
39
|
+
if ( pandoc != EOF && pandoc < 3 ) {
|
40
|
+
if ( S(line) && (T(line)[0] == '%') )
|
41
|
+
pandoc++;
|
42
|
+
else
|
43
|
+
pandoc = EOF;
|
44
|
+
}
|
45
|
+
|
46
|
+
if (pandoc == EOF) {
|
47
|
+
EXPAND(line) = ' ';
|
48
|
+
EXPAND(line) = ' ';
|
49
|
+
}
|
50
|
+
__mkd_enqueue(a, &line);
|
51
|
+
S(line) = 0;
|
52
|
+
}
|
53
|
+
else if ( isprint(c) || isspace(c) || (c & 0x80) )
|
54
|
+
EXPAND(line) = c;
|
55
|
+
}
|
56
|
+
|
57
|
+
if ( S(line) )
|
58
|
+
__mkd_enqueue(a, &line);
|
59
|
+
|
60
|
+
DELETE(line);
|
61
|
+
|
62
|
+
if ( (pandoc == 3) && !(flags & (MKD_NOHEADER|MKD_STRICT)) ) {
|
63
|
+
/* the first three lines started with %, so we have a header.
|
64
|
+
* clip the first three lines out of content and hang them
|
65
|
+
* off header.
|
66
|
+
*/
|
67
|
+
Line *headers = T(a->content);
|
68
|
+
|
69
|
+
a->title = headers; __mkd_header_dle(a->title);
|
70
|
+
a->author= headers->next; __mkd_header_dle(a->author);
|
71
|
+
a->date = headers->next->next; __mkd_header_dle(a->date);
|
72
|
+
|
73
|
+
T(a->content) = headers->next->next->next;
|
74
|
+
}
|
75
|
+
|
76
|
+
return a;
|
77
|
+
}
|
78
|
+
|
79
|
+
|
80
|
+
/* convert a block of text into a linked list
|
81
|
+
*/
|
82
|
+
Document *
|
83
|
+
gfm_string(const char *buf, int len, DWORD flags)
|
84
|
+
{
|
85
|
+
struct string_stream about;
|
86
|
+
|
87
|
+
about.data = buf;
|
88
|
+
about.size = len;
|
89
|
+
|
90
|
+
return gfm_populate((getc_func)__mkd_io_strget, &about, flags & INPUT_MASK);
|
91
|
+
}
|
92
|
+
|
93
|
+
|
94
|
+
/* convert a file into a linked list
|
95
|
+
*/
|
96
|
+
Document *
|
97
|
+
gfm_in(FILE *f, DWORD flags)
|
98
|
+
{
|
99
|
+
return gfm_populate((getc_func)fgetc, f, flags & INPUT_MASK);
|
100
|
+
}
|
data/ext/html5.c
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
/* block-level tags for passing html5 blocks through the blender
|
2
|
+
*/
|
3
|
+
#include "tags.h"
|
4
|
+
|
5
|
+
void
|
6
|
+
mkd_with_html5_tags()
|
7
|
+
{
|
8
|
+
static int populated = 0;
|
9
|
+
|
10
|
+
if ( populated ) return;
|
11
|
+
populated = 1;
|
12
|
+
|
13
|
+
mkd_define_tag("ASIDE", 0);
|
14
|
+
mkd_define_tag("FOOTER", 0);
|
15
|
+
mkd_define_tag("HEADER", 0);
|
16
|
+
mkd_define_tag("HGROUP", 0);
|
17
|
+
mkd_define_tag("NAV", 0);
|
18
|
+
mkd_define_tag("SECTION", 0);
|
19
|
+
mkd_define_tag("ARTICLE", 0);
|
20
|
+
|
21
|
+
mkd_sort_tags();
|
22
|
+
}
|