bluecloth 2.0.6.pre120-x86-mswin32
Sign up to get free protection for your applications and to get access to all the features.
- data/ChangeLog +363 -0
- data/LICENSE +27 -0
- data/LICENSE.discount +47 -0
- data/README +81 -0
- data/Rakefile +349 -0
- data/Rakefile.local +43 -0
- data/bin/bluecloth +84 -0
- data/ext/Csio.c +61 -0
- data/ext/VERSION +1 -0
- data/ext/amalloc.h +29 -0
- data/ext/bluecloth.c +391 -0
- data/ext/bluecloth.h +19 -0
- data/ext/config.h +55 -0
- data/ext/css.c +76 -0
- data/ext/cstring.h +75 -0
- data/ext/docheader.c +43 -0
- data/ext/extconf.rb +52 -0
- data/ext/generate.c +1602 -0
- data/ext/markdown.c +1078 -0
- data/ext/markdown.h +146 -0
- data/ext/mkdio.c +303 -0
- data/ext/mkdio.h +79 -0
- data/ext/resource.c +155 -0
- data/ext/version.c +28 -0
- data/ext/xml.c +82 -0
- data/ext/xmlpage.c +48 -0
- data/lib/1.8/bluecloth_ext.so +0 -0
- data/lib/1.9/bluecloth_ext.so +0 -0
- data/lib/bluecloth.rb +164 -0
- data/rake/191_compat.rb +26 -0
- data/rake/dependencies.rb +76 -0
- data/rake/helpers.rb +434 -0
- data/rake/hg.rb +273 -0
- data/rake/manual.rb +782 -0
- data/rake/packaging.rb +126 -0
- data/rake/publishing.rb +269 -0
- data/rake/rdoc.rb +30 -0
- data/rake/style.rb +62 -0
- data/rake/svn.rb +668 -0
- data/rake/testing.rb +187 -0
- data/rake/verifytask.rb +64 -0
- data/rake/win32.rb +190 -0
- data/spec/bluecloth/101_changes_spec.rb +141 -0
- data/spec/bluecloth/autolinks_spec.rb +49 -0
- data/spec/bluecloth/blockquotes_spec.rb +145 -0
- data/spec/bluecloth/code_spans_spec.rb +164 -0
- data/spec/bluecloth/emphasis_spec.rb +164 -0
- data/spec/bluecloth/entities_spec.rb +65 -0
- data/spec/bluecloth/hrules_spec.rb +90 -0
- data/spec/bluecloth/images_spec.rb +92 -0
- data/spec/bluecloth/inline_html_spec.rb +238 -0
- data/spec/bluecloth/links_spec.rb +171 -0
- data/spec/bluecloth/lists_spec.rb +294 -0
- data/spec/bluecloth/paragraphs_spec.rb +75 -0
- data/spec/bluecloth/titles_spec.rb +305 -0
- data/spec/bluecloth_spec.rb +281 -0
- data/spec/bugfix_spec.rb +172 -0
- data/spec/contributions_spec.rb +85 -0
- data/spec/data/antsugar.txt +34 -0
- data/spec/data/markdowntest/Amps and angle encoding.html +17 -0
- data/spec/data/markdowntest/Amps and angle encoding.text +21 -0
- data/spec/data/markdowntest/Auto links.html +18 -0
- data/spec/data/markdowntest/Auto links.text +13 -0
- data/spec/data/markdowntest/Backslash escapes.html +118 -0
- data/spec/data/markdowntest/Backslash escapes.text +120 -0
- data/spec/data/markdowntest/Blockquotes with code blocks.html +15 -0
- data/spec/data/markdowntest/Blockquotes with code blocks.text +11 -0
- data/spec/data/markdowntest/Code Blocks.html +18 -0
- data/spec/data/markdowntest/Code Blocks.text +14 -0
- data/spec/data/markdowntest/Code Spans.html +5 -0
- data/spec/data/markdowntest/Code Spans.text +5 -0
- data/spec/data/markdowntest/Hard-wrapped paragraphs with list-like lines.html +8 -0
- data/spec/data/markdowntest/Hard-wrapped paragraphs with list-like lines.text +8 -0
- data/spec/data/markdowntest/Horizontal rules.html +71 -0
- data/spec/data/markdowntest/Horizontal rules.text +67 -0
- data/spec/data/markdowntest/Inline HTML (Advanced).html +15 -0
- data/spec/data/markdowntest/Inline HTML (Advanced).text +15 -0
- data/spec/data/markdowntest/Inline HTML (Simple).html +72 -0
- data/spec/data/markdowntest/Inline HTML (Simple).text +69 -0
- data/spec/data/markdowntest/Inline HTML comments.html +13 -0
- data/spec/data/markdowntest/Inline HTML comments.text +13 -0
- data/spec/data/markdowntest/Links, inline style.html +11 -0
- data/spec/data/markdowntest/Links, inline style.text +12 -0
- data/spec/data/markdowntest/Links, reference style.html +52 -0
- data/spec/data/markdowntest/Links, reference style.text +71 -0
- data/spec/data/markdowntest/Links, shortcut references.html +9 -0
- data/spec/data/markdowntest/Links, shortcut references.text +20 -0
- data/spec/data/markdowntest/Literal quotes in titles.html +3 -0
- data/spec/data/markdowntest/Literal quotes in titles.text +7 -0
- data/spec/data/markdowntest/Markdown Documentation - Basics.html +314 -0
- data/spec/data/markdowntest/Markdown Documentation - Basics.text +306 -0
- data/spec/data/markdowntest/Markdown Documentation - Syntax.html +942 -0
- data/spec/data/markdowntest/Markdown Documentation - Syntax.text +888 -0
- data/spec/data/markdowntest/Nested blockquotes.html +9 -0
- data/spec/data/markdowntest/Nested blockquotes.text +5 -0
- data/spec/data/markdowntest/Ordered and unordered lists.html +148 -0
- data/spec/data/markdowntest/Ordered and unordered lists.text +131 -0
- data/spec/data/markdowntest/Strong and em together.html +7 -0
- data/spec/data/markdowntest/Strong and em together.text +7 -0
- data/spec/data/markdowntest/Tabs.html +25 -0
- data/spec/data/markdowntest/Tabs.text +21 -0
- data/spec/data/markdowntest/Tidyness.html +8 -0
- data/spec/data/markdowntest/Tidyness.text +5 -0
- data/spec/data/ml-announce.txt +17 -0
- data/spec/data/re-overflow.txt +67 -0
- data/spec/data/re-overflow2.txt +281 -0
- data/spec/discount_spec.rb +184 -0
- data/spec/lib/constants.rb +5 -0
- data/spec/lib/helpers.rb +137 -0
- data/spec/lib/matchers.rb +235 -0
- data/spec/markdowntest_spec.rb +79 -0
- metadata +205 -0
data/ext/Csio.c
ADDED
@@ -0,0 +1,61 @@
|
|
1
|
+
#include <stdio.h>
|
2
|
+
#include <string.h>
|
3
|
+
#include <stdarg.h>
|
4
|
+
#include "cstring.h"
|
5
|
+
#include "markdown.h"
|
6
|
+
#include "amalloc.h"
|
7
|
+
|
8
|
+
|
9
|
+
/* putc() into a cstring
|
10
|
+
*/
|
11
|
+
void
|
12
|
+
Csputc(int c, Cstring *iot)
|
13
|
+
{
|
14
|
+
EXPAND(*iot) = c;
|
15
|
+
}
|
16
|
+
|
17
|
+
|
18
|
+
/* printf() into a cstring
|
19
|
+
*/
|
20
|
+
int
|
21
|
+
Csprintf(Cstring *iot, char *fmt, ...)
|
22
|
+
{
|
23
|
+
va_list ptr;
|
24
|
+
int siz=100;
|
25
|
+
|
26
|
+
do {
|
27
|
+
RESERVE(*iot, siz);
|
28
|
+
va_start(ptr, fmt);
|
29
|
+
siz = vsnprintf(T(*iot)+S(*iot), ALLOCATED(*iot)-S(*iot), fmt, ptr);
|
30
|
+
va_end(ptr);
|
31
|
+
} while ( siz > (ALLOCATED(*iot)-S(*iot)) );
|
32
|
+
|
33
|
+
S(*iot) += siz;
|
34
|
+
return siz;
|
35
|
+
}
|
36
|
+
|
37
|
+
|
38
|
+
/* write() into a cstring
|
39
|
+
*/
|
40
|
+
int
|
41
|
+
Cswrite(Cstring *iot, char *bfr, int size)
|
42
|
+
{
|
43
|
+
RESERVE(*iot, size);
|
44
|
+
memcpy(T(*iot)+S(*iot), bfr, size);
|
45
|
+
S(*iot) += size;
|
46
|
+
return size;
|
47
|
+
}
|
48
|
+
|
49
|
+
|
50
|
+
/* reparse() into a cstring
|
51
|
+
*/
|
52
|
+
void
|
53
|
+
Csreparse(Cstring *iot, char *buf, int size, int flags)
|
54
|
+
{
|
55
|
+
MMIOT f;
|
56
|
+
___mkd_initmmiot(&f, 0);
|
57
|
+
___mkd_reparse(buf, size, 0, &f);
|
58
|
+
___mkd_emblock(&f);
|
59
|
+
SUFFIX(*iot, T(f.out), S(f.out));
|
60
|
+
___mkd_freemmiot(&f, 0);
|
61
|
+
}
|
data/ext/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
1.5.8
|
data/ext/amalloc.h
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
/*
|
2
|
+
* debugging malloc()/realloc()/calloc()/free() that attempts
|
3
|
+
* to keep track of just what's been allocated today.
|
4
|
+
*/
|
5
|
+
#ifndef AMALLOC_D
|
6
|
+
#define AMALLOC_D
|
7
|
+
|
8
|
+
#include "config.h"
|
9
|
+
|
10
|
+
#ifdef USE_AMALLOC
|
11
|
+
|
12
|
+
extern void *amalloc(int);
|
13
|
+
extern void *acalloc(int,int);
|
14
|
+
extern void *arealloc(void*,int);
|
15
|
+
extern void afree(void*);
|
16
|
+
extern void adump();
|
17
|
+
|
18
|
+
#define malloc amalloc
|
19
|
+
#define calloc acalloc
|
20
|
+
#define realloc arealloc
|
21
|
+
#define free afree
|
22
|
+
|
23
|
+
#else
|
24
|
+
|
25
|
+
#define adump() (void)1
|
26
|
+
|
27
|
+
#endif
|
28
|
+
|
29
|
+
#endif/*AMALLOC_D*/
|
data/ext/bluecloth.c
ADDED
@@ -0,0 +1,391 @@
|
|
1
|
+
/*
|
2
|
+
* BlueCloth -- a Ruby implementation of Markdown
|
3
|
+
* $Id$
|
4
|
+
*
|
5
|
+
* = Authors
|
6
|
+
*
|
7
|
+
* - Michael Granger <ged@FaerieMUD.org>
|
8
|
+
*
|
9
|
+
* BlueCloth 2 is mostly just a wrapper around the Discount library
|
10
|
+
* written by David Loren Parsons <http://www.pell.portland.or.us/~orc>.
|
11
|
+
*
|
12
|
+
* = License
|
13
|
+
*
|
14
|
+
* Discount:
|
15
|
+
* Copyright (C) 2007 David Loren Parsons. All rights reserved.
|
16
|
+
*
|
17
|
+
* The Discount library is used under the licensing terms outlined in the
|
18
|
+
* COPYRIGHT.discount file included in the distribution.
|
19
|
+
*
|
20
|
+
* Ruby bits:
|
21
|
+
* See the LICENSE file included in the distribution.
|
22
|
+
*
|
23
|
+
*/
|
24
|
+
|
25
|
+
#include "bluecloth.h"
|
26
|
+
|
27
|
+
VALUE bluecloth_cBlueCloth;
|
28
|
+
VALUE bluecloth_default_opthash;
|
29
|
+
|
30
|
+
|
31
|
+
/* Get a Discount document for the specified text */
|
32
|
+
static MMIOT *
|
33
|
+
bluecloth_alloc( VALUE text, int flags ) {
|
34
|
+
MMIOT *document;
|
35
|
+
|
36
|
+
document = mkd_string( RSTRING_PTR(text), RSTRING_LEN(text), flags );
|
37
|
+
if ( !document )
|
38
|
+
rb_raise( rb_eRuntimeError, "Failed to create a BlueCloth object for: %s", RSTRING_PTR(text) );
|
39
|
+
|
40
|
+
return document;
|
41
|
+
}
|
42
|
+
|
43
|
+
|
44
|
+
/*
|
45
|
+
* GC Free function
|
46
|
+
*/
|
47
|
+
static void
|
48
|
+
bluecloth_gc_free( MMIOT *document ) {
|
49
|
+
if ( document ) {
|
50
|
+
mkd_cleanup( document );
|
51
|
+
document = NULL;
|
52
|
+
}
|
53
|
+
}
|
54
|
+
|
55
|
+
|
56
|
+
/* --------------------------------------------------------------
|
57
|
+
* Utility functions
|
58
|
+
* -------------------------------------------------------------- */
|
59
|
+
|
60
|
+
#ifdef HAVE_STDARG_PROTOTYPES
|
61
|
+
#include <stdarg.h>
|
62
|
+
void
|
63
|
+
bluecloth_debug(const char *fmt, ...)
|
64
|
+
#else
|
65
|
+
#include <varargs.h>
|
66
|
+
void
|
67
|
+
bluecloth_debug( fmt, va_alist )
|
68
|
+
const char *fmt;
|
69
|
+
va_dcl
|
70
|
+
#endif
|
71
|
+
{
|
72
|
+
char buf[BUFSIZ], buf2[BUFSIZ];
|
73
|
+
va_list args;
|
74
|
+
|
75
|
+
if (!RTEST(ruby_debug)) return;
|
76
|
+
|
77
|
+
snprintf( buf, BUFSIZ, "Debug>>> %s", fmt );
|
78
|
+
|
79
|
+
#ifdef HAVE_STDARG_PROTOTYPES
|
80
|
+
va_start( args, fmt );
|
81
|
+
#else
|
82
|
+
va_start( args );
|
83
|
+
#endif
|
84
|
+
vsnprintf( buf2, BUFSIZ, buf, args );
|
85
|
+
fputs( buf2, stderr );
|
86
|
+
fputs( "\n", stderr );
|
87
|
+
fflush( stderr );
|
88
|
+
va_end( args );
|
89
|
+
}
|
90
|
+
|
91
|
+
|
92
|
+
/*
|
93
|
+
* Object validity checker. Returns the data pointer.
|
94
|
+
*/
|
95
|
+
static MMIOT *
|
96
|
+
bluecloth_check_ptr( VALUE self ) {
|
97
|
+
Check_Type( self, T_DATA );
|
98
|
+
|
99
|
+
if ( !rb_obj_is_kind_of(self, bluecloth_cBlueCloth) ) {
|
100
|
+
rb_raise( rb_eTypeError, "wrong argument type %s (expected BlueCloth object)",
|
101
|
+
rb_class2name(CLASS_OF( self )) );
|
102
|
+
}
|
103
|
+
|
104
|
+
return DATA_PTR( self );
|
105
|
+
}
|
106
|
+
|
107
|
+
|
108
|
+
/*
|
109
|
+
* Fetch the data pointer and check it for sanity.
|
110
|
+
*/
|
111
|
+
static MMIOT *
|
112
|
+
bluecloth_get_ptr( VALUE self ) {
|
113
|
+
MMIOT *ptr = bluecloth_check_ptr( self );
|
114
|
+
|
115
|
+
if ( !ptr )
|
116
|
+
rb_fatal( "Use of uninitialized BlueCloth object" );
|
117
|
+
|
118
|
+
return ptr;
|
119
|
+
}
|
120
|
+
|
121
|
+
|
122
|
+
/* --------------------------------------------------------------
|
123
|
+
* Class methods
|
124
|
+
* -------------------------------------------------------------- */
|
125
|
+
|
126
|
+
/*
|
127
|
+
* call-seq:
|
128
|
+
* BlueCloth.allocate -> object
|
129
|
+
*
|
130
|
+
* Allocate a new BlueCloth object.
|
131
|
+
*
|
132
|
+
*/
|
133
|
+
static VALUE
|
134
|
+
bluecloth_s_allocate( VALUE klass ) {
|
135
|
+
return Data_Wrap_Struct( klass, NULL, bluecloth_gc_free, 0 );
|
136
|
+
}
|
137
|
+
|
138
|
+
|
139
|
+
/*
|
140
|
+
* call-seq:
|
141
|
+
* BlueCloth.discount_version -> string
|
142
|
+
*
|
143
|
+
* Return the version string of the Discount library BlueCloth was built on.
|
144
|
+
*
|
145
|
+
*/
|
146
|
+
static VALUE
|
147
|
+
bluecloth_s_discount_version( VALUE klass ) {
|
148
|
+
#ifdef HAVE_RUBY_ENCODING_H
|
149
|
+
return rb_external_str_new_with_enc( markdown_version, strlen(markdown_version),
|
150
|
+
rb_default_external_encoding() );
|
151
|
+
#else
|
152
|
+
return rb_str_new2( markdown_version );
|
153
|
+
#endif
|
154
|
+
}
|
155
|
+
|
156
|
+
/* --------------------------------------------------------------
|
157
|
+
* Instance methods
|
158
|
+
* -------------------------------------------------------------- */
|
159
|
+
|
160
|
+
/*
|
161
|
+
* call-seq:
|
162
|
+
* BlueCloth.new( string='', options=DEFAULT_OPTIONS ) -> object
|
163
|
+
*
|
164
|
+
* Create a new BlueCloth object that will process the given +string+. The +options+
|
165
|
+
* argument is a Hash that can be used to control the generated markup, and to
|
166
|
+
* enable/disable extensions. The supported options are:
|
167
|
+
*
|
168
|
+
* [:remove_links]
|
169
|
+
* Ignore links in Markdown, and escape A tags in the output. Defaults to +false+.
|
170
|
+
* [:remove_images]
|
171
|
+
* Ignore images in Markdown, and escape IMG tags in the output. Defaults to +false+.
|
172
|
+
* [:smartypants]
|
173
|
+
* Do Smartypants-style mangling of quotes, dashes, or ellipses. Defaults to +true+.
|
174
|
+
* [:pseudoprotocols]
|
175
|
+
* Support Discount's pseudo-protocol links. Defaults to +false+.
|
176
|
+
* [:pandoc_headers]
|
177
|
+
* Support the extraction of
|
178
|
+
* {Pandoc headers}[http://johnmacfarlane.net/pandoc/README.html#title-blocks], which
|
179
|
+
* can be fetched as a Hash via the #header method. Defaults to +false+.
|
180
|
+
* [:header_labels]
|
181
|
+
* Generate ID attributes for all headers. Defaults to +false+.
|
182
|
+
* [:escape_html]
|
183
|
+
* Escape all HTML in the input string. Defaults to +false+.
|
184
|
+
* [:strict_mode]
|
185
|
+
* Disables Discount's relaxed emphasis (ignores underscores in the middle of words) and
|
186
|
+
* superscript notation. Defaults to +true+.
|
187
|
+
*
|
188
|
+
*/
|
189
|
+
static VALUE
|
190
|
+
bluecloth_initialize( int argc, VALUE *argv, VALUE self ) {
|
191
|
+
if ( !bluecloth_check_ptr(self) ) {
|
192
|
+
MMIOT *document;
|
193
|
+
VALUE text, textcopy, optflags, fullhash, opthash = Qnil;
|
194
|
+
int flags = 0;
|
195
|
+
|
196
|
+
rb_scan_args( argc, argv, "02", &text, &opthash );
|
197
|
+
|
198
|
+
/* Default empty string and options */
|
199
|
+
if ( argc == 0 ) {
|
200
|
+
text = rb_str_new( "", 0 );
|
201
|
+
}
|
202
|
+
|
203
|
+
/* One arg could be either the text or the opthash, so shift the args if appropriate */
|
204
|
+
else if ( argc == 1 && (TYPE(text) == T_HASH || TYPE(text) == T_FIXNUM) ) {
|
205
|
+
opthash = text;
|
206
|
+
text = rb_str_new( "", 0 );
|
207
|
+
}
|
208
|
+
else {
|
209
|
+
text = rb_obj_as_string( text );
|
210
|
+
}
|
211
|
+
|
212
|
+
/* Merge the options hash with the defaults and turn it into a flags int */
|
213
|
+
if ( NIL_P(opthash) ) opthash = rb_hash_new();
|
214
|
+
optflags = rb_funcall( bluecloth_cBlueCloth, rb_intern("flags_from_opthash"), 1, opthash );
|
215
|
+
fullhash = rb_funcall( bluecloth_cBlueCloth, rb_intern("opthash_from_flags"), 1, optflags );
|
216
|
+
|
217
|
+
flags = NUM2INT( optflags );
|
218
|
+
DATA_PTR( self ) = document = bluecloth_alloc( text, flags );
|
219
|
+
if ( !mkd_compile(document, flags) )
|
220
|
+
rb_raise( rb_eRuntimeError, "Failed to compile markdown" );
|
221
|
+
|
222
|
+
textcopy = rb_str_dup( text );
|
223
|
+
OBJ_FREEZE( textcopy );
|
224
|
+
rb_iv_set( self, "@text", textcopy );
|
225
|
+
OBJ_FREEZE( fullhash );
|
226
|
+
rb_iv_set( self, "@options", fullhash );
|
227
|
+
#ifdef HAVE_RUBY_ENCODING_H
|
228
|
+
rb_enc_copy( self, text );
|
229
|
+
#endif
|
230
|
+
|
231
|
+
OBJ_INFECT( self, text );
|
232
|
+
}
|
233
|
+
|
234
|
+
return self;
|
235
|
+
}
|
236
|
+
|
237
|
+
|
238
|
+
/*
|
239
|
+
* call-seq:
|
240
|
+
* bluecloth.to_html -> string
|
241
|
+
*
|
242
|
+
* Transform the document into HTML.
|
243
|
+
*
|
244
|
+
*/
|
245
|
+
static VALUE
|
246
|
+
bluecloth_to_html( VALUE self ) {
|
247
|
+
MMIOT *document = bluecloth_get_ptr( self );
|
248
|
+
char *output;
|
249
|
+
int length;
|
250
|
+
VALUE result = Qnil;
|
251
|
+
|
252
|
+
bluecloth_debug( "Compiling document %p", document );
|
253
|
+
|
254
|
+
if ( (length = mkd_document( document, &output )) != EOF ) {
|
255
|
+
bluecloth_debug( "Pointer to results: %p, length = %d", output, length );
|
256
|
+
result = rb_str_new( output, length );
|
257
|
+
|
258
|
+
#ifdef HAVE_RUBY_ENCODING_H
|
259
|
+
rb_enc_copy( result, self );
|
260
|
+
#endif
|
261
|
+
OBJ_INFECT( result, self );
|
262
|
+
return result;
|
263
|
+
} else {
|
264
|
+
return Qnil;
|
265
|
+
}
|
266
|
+
}
|
267
|
+
|
268
|
+
|
269
|
+
char * (*header_functions[3])(MMIOT *) = {
|
270
|
+
mkd_doc_title,
|
271
|
+
mkd_doc_author,
|
272
|
+
mkd_doc_date
|
273
|
+
};
|
274
|
+
|
275
|
+
/*
|
276
|
+
* call-seq:
|
277
|
+
* bluecloth.header -> hash
|
278
|
+
*
|
279
|
+
* Return the hash of
|
280
|
+
* {Pandoc-style headers}[http://johnmacfarlane.net/pandoc/README.html#title-blocks]
|
281
|
+
* from the parsed document. If there were no headers, or the BlueCloth object was not
|
282
|
+
* constructed with the :pandoc_headers option enabled, an empty Hash is returned.
|
283
|
+
*
|
284
|
+
* markdown = "%title My Essay\n%author Me\n%date Today\n\nSome stuff..."
|
285
|
+
* bc = BlueCloth.new( markdown, :pandoc_headers => true )
|
286
|
+
* # =>
|
287
|
+
* bc.header
|
288
|
+
* # =>
|
289
|
+
*/
|
290
|
+
static VALUE
|
291
|
+
bluecloth_header( VALUE self ) {
|
292
|
+
MMIOT *document = bluecloth_get_ptr( self );
|
293
|
+
char *field;
|
294
|
+
VALUE fieldstring, headers = rb_hash_new();
|
295
|
+
|
296
|
+
bluecloth_debug( "Fetching pandoc headers for document %p", document );
|
297
|
+
|
298
|
+
if ( (field = mkd_doc_title(document)) ) {
|
299
|
+
fieldstring = rb_str_new2( field );
|
300
|
+
OBJ_INFECT( fieldstring, self );
|
301
|
+
rb_hash_aset( headers, ID2SYM(rb_intern("title")), fieldstring );
|
302
|
+
}
|
303
|
+
if ( (field = mkd_doc_author(document)) ) {
|
304
|
+
fieldstring = rb_str_new2( field );
|
305
|
+
OBJ_INFECT( fieldstring, self );
|
306
|
+
rb_hash_aset( headers, ID2SYM(rb_intern("author")), fieldstring );
|
307
|
+
}
|
308
|
+
if ( (field = mkd_doc_date(document)) ) {
|
309
|
+
fieldstring = rb_str_new2( field );
|
310
|
+
OBJ_INFECT( fieldstring, self );
|
311
|
+
rb_hash_aset( headers, ID2SYM(rb_intern("date")), fieldstring );
|
312
|
+
}
|
313
|
+
|
314
|
+
return headers;
|
315
|
+
}
|
316
|
+
|
317
|
+
|
318
|
+
|
319
|
+
/* --------------------------------------------------------------
|
320
|
+
* Initializer
|
321
|
+
* -------------------------------------------------------------- */
|
322
|
+
|
323
|
+
void Init_bluecloth_ext( void ) {
|
324
|
+
bluecloth_cBlueCloth = rb_define_class( "BlueCloth", rb_cObject );
|
325
|
+
|
326
|
+
rb_define_alloc_func( bluecloth_cBlueCloth, bluecloth_s_allocate );
|
327
|
+
rb_define_singleton_method( bluecloth_cBlueCloth, "discount_version",
|
328
|
+
bluecloth_s_discount_version, 0 );
|
329
|
+
|
330
|
+
rb_define_method( bluecloth_cBlueCloth, "initialize", bluecloth_initialize, -1 );
|
331
|
+
|
332
|
+
rb_define_method( bluecloth_cBlueCloth, "to_html", bluecloth_to_html, 0 );
|
333
|
+
rb_define_method( bluecloth_cBlueCloth, "header", bluecloth_header, 0 );
|
334
|
+
rb_define_alias( bluecloth_cBlueCloth, "pandoc_header", "header" );
|
335
|
+
|
336
|
+
/* The original Markdown text the object was constructed with */
|
337
|
+
rb_define_attr( bluecloth_cBlueCloth, "text", 1, 0 );
|
338
|
+
|
339
|
+
/* The options hash that describes the options in effect when the object was created */
|
340
|
+
rb_define_attr( bluecloth_cBlueCloth, "options", 1, 0 );
|
341
|
+
|
342
|
+
|
343
|
+
/* --- Constants ----- */
|
344
|
+
|
345
|
+
/* Do not process `[]' and remove A tags from the output. */
|
346
|
+
rb_define_const( bluecloth_cBlueCloth, "MKD_NOLINKS", INT2FIX(MKD_NOLINKS) );
|
347
|
+
|
348
|
+
/* Do not process `![]' and remove IMG tags from the output. */
|
349
|
+
rb_define_const( bluecloth_cBlueCloth, "MKD_NOIMAGE", INT2FIX(MKD_NOIMAGE) );
|
350
|
+
|
351
|
+
/* Do not do Smartypants-style mangling of quotes, dashes, or ellipses. */
|
352
|
+
rb_define_const( bluecloth_cBlueCloth, "MKD_NOPANTS", INT2FIX(MKD_NOPANTS) );
|
353
|
+
|
354
|
+
/* Escape all opening angle brackets in the input text instead of allowing block-level HTML */
|
355
|
+
rb_define_const( bluecloth_cBlueCloth, "MKD_NOHTML", INT2FIX(MKD_NOHTML) );
|
356
|
+
|
357
|
+
/* disable SUPERSCRIPT, RELAXED_EMPHASIS */
|
358
|
+
rb_define_const( bluecloth_cBlueCloth, "MKD_STRICT", INT2FIX(MKD_STRICT) );
|
359
|
+
|
360
|
+
/* process text inside an html tag; no <em>, no <bold>, no html or [] expansion */
|
361
|
+
rb_define_const( bluecloth_cBlueCloth, "MKD_TAGTEXT", INT2FIX(MKD_TAGTEXT) );
|
362
|
+
|
363
|
+
/* don't allow pseudo-protocols */
|
364
|
+
rb_define_const( bluecloth_cBlueCloth, "MKD_NO_EXT", INT2FIX(MKD_NO_EXT) );
|
365
|
+
|
366
|
+
/* do table-of-contents processing */
|
367
|
+
rb_define_const( bluecloth_cBlueCloth, "MKD_TOC", INT2FIX(MKD_TOC) );
|
368
|
+
|
369
|
+
/* MarkdownTest 1.0 Compatibility Mode */
|
370
|
+
rb_define_const( bluecloth_cBlueCloth, "MKD_1_COMPAT", INT2FIX(MKD_1_COMPAT) );
|
371
|
+
|
372
|
+
/* MKD_NOLINKS|MKD_NOIMAGE|MKD_TAGTEXT */
|
373
|
+
rb_define_const( bluecloth_cBlueCloth, "MKD_EMBED", INT2FIX(MKD_EMBED) );
|
374
|
+
|
375
|
+
/* Create links for inline URIs */
|
376
|
+
rb_define_const( bluecloth_cBlueCloth, "MKD_AUTOLINK", INT2FIX(MKD_AUTOLINK) );
|
377
|
+
|
378
|
+
/* Be paranoid about link protocols */
|
379
|
+
rb_define_const( bluecloth_cBlueCloth, "MKD_SAFELINK", INT2FIX(MKD_SAFELINK) );
|
380
|
+
|
381
|
+
|
382
|
+
/* don't process header blocks */
|
383
|
+
rb_define_const( bluecloth_cBlueCloth, "MKD_NOHEADER", INT2FIX(MKD_NOHEADER) );
|
384
|
+
|
385
|
+
|
386
|
+
/* Make sure the Ruby side is loaded */
|
387
|
+
rb_require( "bluecloth" );
|
388
|
+
|
389
|
+
bluecloth_default_opthash = rb_const_get( bluecloth_cBlueCloth, rb_intern("DEFAULT_OPTIONS") );
|
390
|
+
}
|
391
|
+
|