rdiscountwl 1.0.0.1

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.
data/ext/extconf.rb ADDED
@@ -0,0 +1,49 @@
1
+ require 'mkmf'
2
+
3
+ dir_config('rdiscount')
4
+
5
+ HAVE_RANDOM = have_func('random')
6
+ HAVE_SRANDOM = have_func('srandom')
7
+ HAVE_RAND = have_func('rand')
8
+ HAVE_SRAND = have_func('srand')
9
+
10
+ def sized_int(size, types)
11
+ types.find { |type| check_sizeof(type) == size } ||
12
+ abort("no int with size #{size}")
13
+ end
14
+
15
+ DWORD = sized_int(4, ["unsigned long", "unsigned int"])
16
+ WORD = sized_int(2, ["unsigned int", "unsigned short"])
17
+ BYTE = "unsigned char"
18
+ VERSION = IO.read('VERSION').strip
19
+
20
+ open(File.join(File.dirname(__FILE__), "ruby-config.h"), "wb") do |f|
21
+ f.write <<-EOF
22
+ // These data types may be already defined if building on Windows (using MinGW)
23
+ #ifndef DWORD
24
+ #define DWORD #{DWORD}
25
+ #endif
26
+ #ifndef WORD
27
+ #define WORD #{WORD}
28
+ #endif
29
+ #ifndef BYTE
30
+ #define BYTE #{BYTE}
31
+ #endif
32
+ EOF
33
+ end
34
+
35
+ $defs.push("-DVERSION=\\\"#{VERSION}\\\"")
36
+
37
+ # Post XCode 5.1 the command line tools on OS X treat unrecognised
38
+ # command line options as errors and it's been seen that
39
+ # -multiply_definedsuppress can trickle from ruby build settings.
40
+ # Issue 115
41
+ if /darwin|mac os/.match RbConfig::CONFIG['host_os']
42
+ $DLDFLAGS.gsub!("-multiply_definedsuppress", "")
43
+ end
44
+
45
+ if /mswin/.match RbConfig::CONFIG['host_os']
46
+ $defs.push("-Dinline=__inline")
47
+ end
48
+
49
+ create_makefile('rdiscount')
data/ext/flags.c ADDED
@@ -0,0 +1,91 @@
1
+ #include <stdio.h>
2
+ #include "markdown.h"
3
+
4
+ struct flagnames {
5
+ DWORD flag;
6
+ char *name;
7
+ };
8
+
9
+ static struct flagnames flagnames[] = {
10
+ { MKD_NOLINKS, "!LINKS" },
11
+ { MKD_NOIMAGE, "!IMAGE" },
12
+ { MKD_NOPANTS, "!PANTS" },
13
+ { MKD_NOHTML, "!HTML" },
14
+ { MKD_STRICT, "STRICT" },
15
+ { MKD_TAGTEXT, "TAGTEXT" },
16
+ { MKD_NO_EXT, "!EXT" },
17
+ { MKD_CDATA, "CDATA" },
18
+ { MKD_NOSUPERSCRIPT, "!SUPERSCRIPT" },
19
+ { MKD_NORELAXED, "!RELAXED" },
20
+ { MKD_NOTABLES, "!TABLES" },
21
+ { MKD_NOSTRIKETHROUGH,"!STRIKETHROUGH" },
22
+ { MKD_TOC, "TOC" },
23
+ { MKD_1_COMPAT, "MKD_1_COMPAT" },
24
+ { MKD_AUTOLINK, "AUTOLINK" },
25
+ { MKD_SAFELINK, "SAFELINK" },
26
+ { MKD_NOHEADER, "!HEADER" },
27
+ { MKD_TABSTOP, "TABSTOP" },
28
+ { MKD_NODIVQUOTE, "!DIVQUOTE" },
29
+ { MKD_NOALPHALIST, "!ALPHALIST" },
30
+ { MKD_NODLIST, "!DLIST" },
31
+ { MKD_EXTRA_FOOTNOTE, "FOOTNOTE" },
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" },
39
+ };
40
+ #define NR(x) (sizeof x/sizeof x[0])
41
+
42
+
43
+ void
44
+ mkd_flags_are(FILE *f, DWORD flags, int htmlplease)
45
+ {
46
+ int i;
47
+ int not, set, even=1;
48
+ char *name;
49
+
50
+ if ( htmlplease )
51
+ fprintf(f, "<table class=\"mkd_flags_are\">\n");
52
+ for (i=0; i < NR(flagnames); i++) {
53
+ set = flags & flagnames[i].flag;
54
+ name = flagnames[i].name;
55
+ if ( not = (*name == '!') ) {
56
+ ++name;
57
+ set = !set;
58
+ }
59
+
60
+ if ( htmlplease ) {
61
+ if ( even ) fprintf(f, " <tr>");
62
+ fprintf(f, "<td>");
63
+ }
64
+ else
65
+ fputc(' ', f);
66
+
67
+ if ( !set )
68
+ fprintf(f, htmlplease ? "<s>" : "!");
69
+
70
+ fprintf(f, "%s", name);
71
+
72
+ if ( htmlplease ) {
73
+ if ( !set )
74
+ fprintf(f, "</s>");
75
+ fprintf(f, "</td>");
76
+ if ( !even ) fprintf(f, "</tr>\n");
77
+ }
78
+ even = !even;
79
+ }
80
+ if ( htmlplease ) {
81
+ if ( even ) fprintf(f, "</tr>\n");
82
+ fprintf(f, "</table>\n");
83
+ }
84
+ }
85
+
86
+ void
87
+ mkd_mmiot_flags(FILE *f, MMIOT *m, int htmlplease)
88
+ {
89
+ if ( m )
90
+ mkd_flags_are(f, m->flags, htmlplease);
91
+ }