RedCloth 4.1.1-x86-mswin32-60 → 4.1.9-x86-mswin32-60
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of RedCloth might be problematic. Click here for more details.
- data/CHANGELOG +36 -0
- data/COPYING +1 -1
- data/README +32 -17
- data/Rakefile +1 -0
- data/RedCloth.gemspec +4 -7
- data/ext/redcloth_scan/redcloth.h +53 -22
- data/ext/redcloth_scan/redcloth_attributes.c.rl +2 -3
- data/ext/redcloth_scan/redcloth_attributes.java.rl +5 -6
- data/ext/redcloth_scan/redcloth_attributes.rl +2 -2
- data/ext/redcloth_scan/redcloth_common.rl +5 -1
- data/ext/redcloth_scan/redcloth_inline.c.rl +48 -14
- data/ext/redcloth_scan/redcloth_inline.java.rl +36 -4
- data/ext/redcloth_scan/redcloth_inline.rl +11 -12
- data/ext/redcloth_scan/redcloth_scan.c.rl +12 -14
- data/ext/redcloth_scan/redcloth_scan.java.rl +25 -3
- data/ext/redcloth_scan/redcloth_scan.rl +7 -12
- data/lib/redcloth/formatters/base.rb +26 -20
- data/lib/redcloth/formatters/html.rb +22 -30
- data/lib/redcloth/formatters/latex.rb +45 -17
- data/lib/redcloth/textile_doc.rb +1 -3
- data/lib/redcloth/version.rb +1 -1
- data/lib/redcloth_scan.so +0 -0
- data/test/basic.yml +16 -2
- data/test/code.yml +6 -7
- data/test/html.yml +15 -1
- data/test/images.yml +23 -0
- data/test/links.yml +27 -1
- data/test/lists.yml +19 -1
- data/test/table.yml +73 -4
- data/test/test_custom_tags.rb +13 -1
- data/test/test_erb.rb +1 -1
- data/test/test_extensions.rb +1 -1
- data/test/test_formatters.rb +1 -1
- data/test/test_parser.rb +1 -1
- data/test/test_restrictions.rb +1 -1
- data/test/textism.yml +1 -1
- data/test/threshold.yml +1 -3
- data/test/validate_fixtures.rb +2 -1
- metadata +6 -15
data/CHANGELOG
CHANGED
@@ -1,3 +1,39 @@
|
|
1
|
+
=== 4.1.9 / February 20, 2009
|
2
|
+
|
3
|
+
* Make compatible with Ruby 1.9.
|
4
|
+
|
5
|
+
* Image URLs and image titles can now contain parentheses. #71
|
6
|
+
|
7
|
+
* Handle caps properly in link titles. #77
|
8
|
+
|
9
|
+
* Remove extra preformatted line breaks after extended block code. #79
|
10
|
+
|
11
|
+
* Fix inline <notextile> being recognized as block <notextile>. #81
|
12
|
+
|
13
|
+
* Allow leading spaces on lists for backward compatibility with RedCloth 3.x. #89
|
14
|
+
|
15
|
+
* Recognize deleted phrases when they start at the beginning of a line. #83
|
16
|
+
|
17
|
+
* Fix escaped <code> tag when it has the class attribute and is in a <pre> tag. #95
|
18
|
+
|
19
|
+
* Fix dimensions and primes for LaTeX. #103
|
20
|
+
|
21
|
+
* Don't allow square brackets inside lang attribute so double square brackets are interpreted like Textile 2 and RedCloth 3. #101
|
22
|
+
|
23
|
+
* Improve LaTeX output for tables. #96
|
24
|
+
|
25
|
+
* Fix bad parsing of bracketed image links (which would hang the interpreter in some cases). #97
|
26
|
+
|
27
|
+
* Handle links containing parentheses. Brackets are no longer required. #82 [Ryan Alyea]
|
28
|
+
|
29
|
+
* Made italics use the correct LaTeX tag: textit rather than emph. #98
|
30
|
+
|
31
|
+
* Fixed custom block signatures calling built-in Ruby String methods. #92
|
32
|
+
|
33
|
+
* Mentioned the three supported platforms and what's necessary to build RedCloth in the README file.
|
34
|
+
|
35
|
+
* Fixed a require problem that caused an error when you would gem check --test RedCloth. #91
|
36
|
+
|
1
37
|
=== 4.1.1 / November 19, 2008
|
2
38
|
|
3
39
|
* Added 'lib/case_sensitive_require' back into gemspec. It got left out in the conversion to echoe, so "require 'RedCloth'" didn't work. #88
|
data/COPYING
CHANGED
data/README
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
Homepage:: http://redcloth.org
|
4
4
|
Author:: Jason Garber
|
5
|
-
Copyright:: (c)
|
5
|
+
Copyright:: (c) 2009 Jason Garber
|
6
6
|
License:: MIT
|
7
7
|
|
8
8
|
(See http://redcloth.org/textile/ for a Textile reference.)
|
@@ -15,10 +15,38 @@ RedCloth is a Ruby library for converting Textile into HTML.
|
|
15
15
|
|
16
16
|
RedCloth can be installed via RubyGems:
|
17
17
|
|
18
|
-
|
18
|
+
gem install RedCloth
|
19
|
+
|
20
|
+
It will install the appropriate Ruby, JRuby, or Win32 gem. If using JRuby, version 1.1.5 or greater is required.
|
21
|
+
|
22
|
+
== Compiling
|
23
|
+
|
24
|
+
If you just want to use RedCloth, you do NOT need to build/compile it. It is compiled from C sources automatically when you install the gem on the ruby platform. Binary gems are provided for JRuby and Win32 platforms.
|
25
|
+
|
26
|
+
RedCloth can be compiled with <tt>rake compile</tt>. Ragel 6.3 or greater and the
|
27
|
+
echoe gem are needed to build, compile, and package RedCloth. Again, Ragel and echoe are NOT needed to simply use RedCloth.
|
28
|
+
|
29
|
+
You can cross-compile for JRuby with rake java compile and for Win32 with rake mingw compile.
|
30
|
+
|
31
|
+
== Using RedCloth
|
32
|
+
|
33
|
+
RedCloth is simply an extension of the String class, which can handle
|
34
|
+
Textile formatting. Use it like a String and output HTML with its
|
35
|
+
RedCloth#to_html method.
|
36
|
+
|
37
|
+
Simple use:
|
38
|
+
text = "This is *my* text."
|
39
|
+
RedCloth.new(text).to_html
|
40
|
+
|
41
|
+
Multi-line example:
|
42
|
+
|
43
|
+
doc = RedCloth.new <<EOD
|
44
|
+
h2. Test document
|
45
|
+
|
46
|
+
Just a simple test.
|
47
|
+
EOD
|
48
|
+
puts doc.to_html
|
19
49
|
|
20
|
-
Or can be compiled from its Ragel source with <tt>rake compile</tt>. Ragel 6.2
|
21
|
-
or greater is required to build RedCloth.
|
22
50
|
|
23
51
|
== What is Textile?
|
24
52
|
|
@@ -140,17 +168,4 @@ Styles are applied with curly braces.
|
|
140
168
|
table{border:1px solid black}.
|
141
169
|
{background:#ddd;color:red}. |a|red|row|
|
142
170
|
|
143
|
-
== Using RedCloth
|
144
|
-
|
145
|
-
RedCloth is simply an extension of the String class, which can handle
|
146
|
-
Textile formatting. Use it like a String and output HTML with its
|
147
|
-
RedCloth#to_html method.
|
148
|
-
|
149
|
-
doc = RedCloth.new "
|
150
|
-
|
151
|
-
h2. Test document
|
152
|
-
|
153
|
-
Just a simple test."
|
154
|
-
|
155
|
-
puts doc.to_html
|
156
171
|
|
data/Rakefile
CHANGED
@@ -14,6 +14,7 @@ e = Echoe.new('RedCloth', RedCloth::VERSION.to_s) do |p|
|
|
14
14
|
p.ignore_pattern = /^(pkg|site|projects|doc|log)|CVS|\.log/
|
15
15
|
p.ruby_version = '>=1.8.4'
|
16
16
|
p.extension_pattern = nil
|
17
|
+
p.development_dependencies = [] # remove echoe from development dependencies
|
17
18
|
|
18
19
|
if Platform.gcc?
|
19
20
|
p.platform = 'x86-mswin32-60'
|
data/RedCloth.gemspec
CHANGED
@@ -2,14 +2,14 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.name = %q{RedCloth}
|
5
|
-
s.version = "4.1.
|
5
|
+
s.version = "4.1.9"
|
6
6
|
s.platform = %q{x86-mswin32-60}
|
7
7
|
|
8
8
|
s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
|
9
9
|
s.authors = ["Jason Garber"]
|
10
|
-
s.date = %q{
|
10
|
+
s.date = %q{2009-02-20}
|
11
11
|
s.default_executable = %q{redcloth}
|
12
|
-
s.description = %q{RedCloth-4.1.
|
12
|
+
s.description = %q{RedCloth-4.1.9 - Textile parser for Ruby. http://redcloth.org/}
|
13
13
|
s.email = %q{redcloth-upwards@rubyforge.org}
|
14
14
|
s.executables = ["redcloth"]
|
15
15
|
s.extra_rdoc_files = ["CHANGELOG", "lib/case_sensitive_require/RedCloth.rb", "lib/redcloth/erb_extension.rb", "lib/redcloth/formatters/base.rb", "lib/redcloth/formatters/html.rb", "lib/redcloth/formatters/latex.rb", "lib/redcloth/textile_doc.rb", "lib/redcloth/version.rb", "lib/redcloth.rb", "README"]
|
@@ -21,7 +21,7 @@ Gem::Specification.new do |s|
|
|
21
21
|
s.required_ruby_version = Gem::Requirement.new(">= 1.8.4")
|
22
22
|
s.rubyforge_project = %q{redcloth}
|
23
23
|
s.rubygems_version = %q{1.3.1}
|
24
|
-
s.summary = %q{RedCloth-4.1.
|
24
|
+
s.summary = %q{RedCloth-4.1.9 - Textile parser for Ruby. http://redcloth.org/}
|
25
25
|
s.test_files = ["test/test_custom_tags.rb", "test/test_erb.rb", "test/test_extensions.rb", "test/test_formatters.rb", "test/test_parser.rb", "test/test_restrictions.rb"]
|
26
26
|
|
27
27
|
if s.respond_to? :specification_version then
|
@@ -29,11 +29,8 @@ Gem::Specification.new do |s|
|
|
29
29
|
s.specification_version = 2
|
30
30
|
|
31
31
|
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
32
|
-
s.add_development_dependency(%q<echoe>, [">= 0"])
|
33
32
|
else
|
34
|
-
s.add_dependency(%q<echoe>, [">= 0"])
|
35
33
|
end
|
36
34
|
else
|
37
|
-
s.add_dependency(%q<echoe>, [">= 0"])
|
38
35
|
end
|
39
36
|
end
|
@@ -1,14 +1,30 @@
|
|
1
1
|
#ifndef redcloth_h
|
2
2
|
#define redcloth_h
|
3
3
|
|
4
|
-
|
5
|
-
#
|
6
|
-
#define RSTRING_LEN(
|
4
|
+
#ifndef RARRAY_LEN
|
5
|
+
#define RARRAY_LEN(arr) RARRAY(arr)->len
|
6
|
+
#define RSTRING_LEN(str) RSTRING(str)->len
|
7
|
+
#define RSTRING_PTR(str) RSTRING(str)->ptr
|
7
8
|
#endif
|
8
|
-
|
9
|
-
|
9
|
+
|
10
|
+
|
11
|
+
// Different string conversions for ruby 1.8 and ruby 1.9. For 1.9,
|
12
|
+
// we need to set the encoding of the string.
|
13
|
+
|
14
|
+
// For Ruby 1.9
|
15
|
+
#ifdef HAVE_RUBY_ENCODING_H
|
16
|
+
#include "ruby/encoding.h"
|
17
|
+
#define STR_NEW(p,n) rb_enc_str_new((p),(n),rb_utf8_encoding())
|
18
|
+
#define STR_NEW2(p) rb_enc_str_new((p),strlen(p),rb_utf8_encoding())
|
19
|
+
|
20
|
+
// For Ruby 1.8
|
21
|
+
#else
|
22
|
+
#define STR_NEW(p,n) rb_str_new((p),(n))
|
23
|
+
#define STR_NEW2(p) rb_str_new2((p))
|
24
|
+
|
10
25
|
#endif
|
11
26
|
|
27
|
+
|
12
28
|
/* variable defs */
|
13
29
|
#ifndef redcloth_scan_c
|
14
30
|
extern VALUE super_ParseError, mRedCloth, super_RedCloth;
|
@@ -23,6 +39,7 @@ VALUE redcloth_inline2(VALUE, VALUE, VALUE);
|
|
23
39
|
VALUE redcloth_attribute_parser(int, VALUE, char *, char *);
|
24
40
|
VALUE redcloth_attributes(VALUE, VALUE);
|
25
41
|
VALUE redcloth_link_attributes(VALUE, VALUE);
|
42
|
+
VALUE red_parse_title(VALUE, VALUE);
|
26
43
|
VALUE redcloth_transform(VALUE, char *, char *, VALUE);
|
27
44
|
VALUE redcloth_transform2(VALUE, VALUE);
|
28
45
|
void red_inc(VALUE, VALUE);
|
@@ -35,14 +52,16 @@ VALUE red_pass_code(VALUE, VALUE, VALUE, ID);
|
|
35
52
|
#define CLEAR_REGS() regs = rb_hash_new();
|
36
53
|
#define RESET_REG() reg = NULL
|
37
54
|
#define CAT(H) rb_str_cat(H, ts, te-ts)
|
38
|
-
#define CLEAR(H) H =
|
39
|
-
#define
|
55
|
+
#define CLEAR(H) H = STR_NEW2("")
|
56
|
+
#define RSTRIP_BANG(H) rb_funcall(H, rb_intern("rstrip!"), 0)
|
57
|
+
#define SET_PLAIN_BLOCK(T) plain_block = STR_NEW2(T)
|
40
58
|
#define RESET_TYPE(T) rb_hash_aset(regs, ID2SYM(rb_intern("type")), plain_block)
|
41
59
|
#define INLINE(H, T) rb_str_append(H, rb_funcall(self, rb_intern(T), 1, regs))
|
42
60
|
#define DONE(H) rb_str_append(html, H); CLEAR(H); CLEAR_REGS()
|
43
61
|
#define PASS(H, A, T) rb_str_append(H, red_pass(self, regs, ID2SYM(rb_intern(A)), rb_intern(T), refs))
|
44
62
|
#define PARSE_ATTR(A) red_parse_attr(self, regs, ID2SYM(rb_intern(A)))
|
45
63
|
#define PARSE_LINK_ATTR(A) red_parse_link_attr(self, regs, ID2SYM(rb_intern(A)))
|
64
|
+
#define PARSE_IMAGE_ATTR(A) red_parse_image_attr(self, regs, ID2SYM(rb_intern(A)))
|
46
65
|
#define PASS_CODE(H, A, T, O) rb_str_append(H, red_pass_code(self, regs, ID2SYM(rb_intern(A)), rb_intern(T)))
|
47
66
|
#define ADD_BLOCK() \
|
48
67
|
rb_str_append(html, red_block(self, regs, block, refs)); \
|
@@ -54,38 +73,36 @@ VALUE red_pass_code(VALUE, VALUE, VALUE, ID);
|
|
54
73
|
#define IS_NOT_EXTENDED() NIL_P(extend)
|
55
74
|
#define ADD_BLOCKCODE() rb_str_append(html, red_blockcode(self, regs, block)); CLEAR(block); CLEAR_REGS()
|
56
75
|
#define ADD_EXTENDED_BLOCKCODE() rb_str_append(html, red_blockcode(self, regs, block)); CLEAR(block);
|
57
|
-
#define ASET(T, V) rb_hash_aset(regs, ID2SYM(rb_intern(T)),
|
76
|
+
#define ASET(T, V) rb_hash_aset(regs, ID2SYM(rb_intern(T)), STR_NEW2(V));
|
58
77
|
#define AINC(T) red_inc(regs, ID2SYM(rb_intern(T)));
|
59
78
|
#define SET_ATTRIBUTES() \
|
60
|
-
VALUE buf = Qnil; \
|
61
79
|
SET_ATTRIBUTE("class_buf", "class"); \
|
62
80
|
SET_ATTRIBUTE("id_buf", "id"); \
|
63
81
|
SET_ATTRIBUTE("lang_buf", "lang"); \
|
64
82
|
SET_ATTRIBUTE("style_buf", "style");
|
65
83
|
#define SET_ATTRIBUTE(B, A) \
|
66
|
-
|
67
|
-
if (buf != Qnil) rb_hash_aset(regs, ID2SYM(rb_intern(A)), buf);
|
84
|
+
if (rb_hash_aref(regs, ID2SYM(rb_intern(B))) != Qnil) rb_hash_aset(regs, ID2SYM(rb_intern(A)), rb_hash_aref(regs, ID2SYM(rb_intern(B))));
|
68
85
|
#define TRANSFORM(T) \
|
69
86
|
if (p > reg && reg >= ts) { \
|
70
87
|
VALUE str = redcloth_transform(self, reg, p, refs); \
|
71
88
|
rb_hash_aset(regs, ID2SYM(rb_intern(T)), str); \
|
72
|
-
|
89
|
+
/*printf("TRANSFORM(" T ") '%s' (p:'%s' reg:'%s')\n", RSTRING_PTR(str), p, reg);*/ \
|
73
90
|
} else { \
|
74
91
|
rb_hash_aset(regs, ID2SYM(rb_intern(T)), Qnil); \
|
75
92
|
}
|
76
93
|
#define STORE(T) \
|
77
94
|
if (p > reg && reg >= ts) { \
|
78
|
-
VALUE str =
|
95
|
+
VALUE str = STR_NEW(reg, p-reg); \
|
79
96
|
rb_hash_aset(regs, ID2SYM(rb_intern(T)), str); \
|
80
|
-
|
97
|
+
/*printf("STORE(" T ") '%s' (p:'%s' reg:'%s')\n", RSTRING_PTR(str), p, reg);*/ \
|
81
98
|
} else { \
|
82
99
|
rb_hash_aset(regs, ID2SYM(rb_intern(T)), Qnil); \
|
83
100
|
}
|
84
101
|
#define STORE_B(T) \
|
85
102
|
if (p > bck && bck >= ts) { \
|
86
|
-
VALUE str =
|
103
|
+
VALUE str = STR_NEW(bck, p-bck); \
|
87
104
|
rb_hash_aset(regs, ID2SYM(rb_intern(T)), str); \
|
88
|
-
|
105
|
+
/*printf("STORE_B(" T ") '%s' (p:'%s' reg:'%s')\n", RSTRING_PTR(str), p, reg);*/ \
|
89
106
|
} else { \
|
90
107
|
rb_hash_aset(regs, ID2SYM(rb_intern(T)), Qnil); \
|
91
108
|
}
|
@@ -94,8 +111,22 @@ VALUE red_pass_code(VALUE, VALUE, VALUE, ID);
|
|
94
111
|
char punct = 1; \
|
95
112
|
while (p > reg && punct == 1) { \
|
96
113
|
switch (*(p - 1)) { \
|
114
|
+
case ')': \
|
115
|
+
{ /*needed to keep inside chars scoped for less memory usage*/\
|
116
|
+
char *temp_p = p - 1; \
|
117
|
+
char level = -1; \
|
118
|
+
while (temp_p > reg) { \
|
119
|
+
switch(*(temp_p - 1)) { \
|
120
|
+
case '(': ++level; break; \
|
121
|
+
case ')': --level; break; \
|
122
|
+
} \
|
123
|
+
--temp_p; \
|
124
|
+
} \
|
125
|
+
if (level == 0) { punct = 0; } else { --p; } \
|
126
|
+
} \
|
127
|
+
break; \
|
97
128
|
case '!': case '"': case '#': case '$': case '%': case ']': case '[': case '&': case '\'': \
|
98
|
-
case '*': case '+': case ',': case '-': case '.': case '
|
129
|
+
case '*': case '+': case ',': case '-': case '.': case '(': case ':': \
|
99
130
|
case ';': case '=': case '?': case '@': case '\\': case '^': case '_': \
|
100
131
|
case '`': case '|': case '~': p--; break; \
|
101
132
|
default: punct = 0; \
|
@@ -118,7 +149,7 @@ VALUE red_pass_code(VALUE, VALUE, VALUE, ID);
|
|
118
149
|
{ \
|
119
150
|
rb_ary_store(list_index, nest-1, INT2NUM(aint + 1)); \
|
120
151
|
} \
|
121
|
-
if (nest >
|
152
|
+
if (nest > RARRAY_LEN(list_layout)) \
|
122
153
|
{ \
|
123
154
|
sprintf(listm, "%s_open", list_type); \
|
124
155
|
if (list_continue == 1) \
|
@@ -141,17 +172,17 @@ VALUE red_pass_code(VALUE, VALUE, VALUE, ID);
|
|
141
172
|
} \
|
142
173
|
rb_hash_aset(regs, ID2SYM(rb_intern("nest")), INT2NUM(nest)); \
|
143
174
|
rb_str_append(html, rb_funcall(self, rb_intern(listm), 1, regs)); \
|
144
|
-
rb_ary_store(list_layout, nest-1,
|
175
|
+
rb_ary_store(list_layout, nest-1, STR_NEW2(list_type)); \
|
145
176
|
CLEAR_REGS(); \
|
146
177
|
ASET("first", "true"); \
|
147
178
|
} \
|
148
179
|
LIST_CLOSE(); \
|
149
|
-
rb_hash_aset(regs, ID2SYM(rb_intern("nest")), INT2NUM(
|
180
|
+
rb_hash_aset(regs, ID2SYM(rb_intern("nest")), INT2NUM(RARRAY_LEN(list_layout))); \
|
150
181
|
ASET("type", "li_open")
|
151
182
|
#define LIST_CLOSE() \
|
152
|
-
while (nest <
|
183
|
+
while (nest < RARRAY_LEN(list_layout)) \
|
153
184
|
{ \
|
154
|
-
rb_hash_aset(regs, ID2SYM(rb_intern("nest")), INT2NUM(
|
185
|
+
rb_hash_aset(regs, ID2SYM(rb_intern("nest")), INT2NUM(RARRAY_LEN(list_layout))); \
|
155
186
|
VALUE end_list = rb_ary_pop(list_layout); \
|
156
187
|
if (!NIL_P(end_list)) \
|
157
188
|
{ \
|
@@ -1,7 +1,7 @@
|
|
1
1
|
/*
|
2
2
|
* redcloth_attributes.c.rl
|
3
3
|
*
|
4
|
-
* Copyright (C)
|
4
|
+
* Copyright (C) 2009 Jason Garber
|
5
5
|
*/
|
6
6
|
#include <ruby.h>
|
7
7
|
#include "redcloth.h"
|
@@ -24,9 +24,8 @@ redcloth_attribute_parser(machine, self, p, pe)
|
|
24
24
|
char *p, *pe;
|
25
25
|
{
|
26
26
|
int cs, act;
|
27
|
-
char *ts, *te, *reg, *bck, *eof;
|
27
|
+
char *ts = 0, *te = 0, *reg = 0, *bck = NULL, *eof = NULL;
|
28
28
|
VALUE regs = rb_hash_new();
|
29
|
-
VALUE buf = Qnil;
|
30
29
|
|
31
30
|
%% write init;
|
32
31
|
|
@@ -1,7 +1,7 @@
|
|
1
1
|
/*
|
2
2
|
* redcloth_attributes.rl
|
3
3
|
*
|
4
|
-
* Copyright (C)
|
4
|
+
* Copyright (C) 2009 Jason Garber
|
5
5
|
*/
|
6
6
|
import java.io.IOException;
|
7
7
|
|
@@ -43,14 +43,12 @@ public class RedclothAttributes extends RedclothScanService.Base {
|
|
43
43
|
}
|
44
44
|
|
45
45
|
public void SET_ATTRIBUTE(String B, String A) {
|
46
|
-
|
47
|
-
|
48
|
-
((RubyHash)regs).aset(runtime.newSymbol(A), buf);
|
46
|
+
if(!((RubyHash)regs).aref(runtime.newSymbol(B)).isNil()) {
|
47
|
+
((RubyHash)regs).aset(runtime.newSymbol(A), ((RubyHash)regs).aref(runtime.newSymbol(B)));
|
49
48
|
}
|
50
49
|
}
|
51
50
|
|
52
51
|
private int machine;
|
53
|
-
private IRubyObject buf;
|
54
52
|
|
55
53
|
public RedclothAttributes(int machine, IRubyObject self, byte[] data, int p, int pe) {
|
56
54
|
this.runtime = self.getRuntime();
|
@@ -68,7 +66,6 @@ public class RedclothAttributes extends RedclothScanService.Base {
|
|
68
66
|
this.orig_pe = this.pe;
|
69
67
|
|
70
68
|
this.regs = RubyHash.newHash(runtime);
|
71
|
-
this.buf = runtime.getNil();
|
72
69
|
this.machine = machine;
|
73
70
|
}
|
74
71
|
|
@@ -89,6 +86,8 @@ public class RedclothAttributes extends RedclothScanService.Base {
|
|
89
86
|
}
|
90
87
|
|
91
88
|
public static IRubyObject link_attributes(IRubyObject self, IRubyObject str) {
|
89
|
+
Ruby runtime = self.getRuntime();
|
90
|
+
|
92
91
|
ByteList bl = str.convertToString().getByteList();
|
93
92
|
int cs = redcloth_attributes_en_link_says;
|
94
93
|
return new RedclothAttributes(cs, self, bl.bytes, bl.begin, bl.realSize).parse();
|
@@ -1,14 +1,14 @@
|
|
1
1
|
/*
|
2
2
|
* redcloth_attributes.rl
|
3
3
|
*
|
4
|
-
* Copyright (C)
|
4
|
+
* Copyright (C) 2009 Jason Garber
|
5
5
|
*/
|
6
6
|
%%{
|
7
7
|
|
8
8
|
machine redcloth_attributes;
|
9
9
|
|
10
10
|
C2_CLAS = ( "(" ( [^)#]+ >A %{ STORE("class_buf"); } )? ("#" [^)]+ >A %{STORE("id_buf");} )? ")" ) ;
|
11
|
-
C2_LNGE = ( "[" [^\]]+ >A %{ STORE("lang_buf"); } "]" ) ;
|
11
|
+
C2_LNGE = ( "[" [^\[\]]+ >A %{ STORE("lang_buf"); } "]" ) ;
|
12
12
|
C2_STYL = ( "{" [^}]+ >A %{ STORE("style_buf"); } "}" ) ;
|
13
13
|
C2 = ( C2_CLAS | C2_STYL | C2_LNGE )+ ;
|
14
14
|
|
@@ -77,7 +77,11 @@
|
|
77
77
|
script_tag_start = ( "<script" [^>]* ">" ) >X >A %T ;
|
78
78
|
script_tag_end = ( "</script>" >A %T LF? ) >X ;
|
79
79
|
|
80
|
-
|
80
|
+
code_tag_start = "<code" [^>]* ">" ;
|
81
|
+
code_tag_end = "</code>" ;
|
82
|
+
|
83
|
+
notextile = "<notextile>" >X (default+ -- "</notextile>") >A %T "</notextile>";
|
84
|
+
|
81
85
|
# URI tokens (lifted from Mongrel)
|
82
86
|
CTL = (cntrl | 127);
|
83
87
|
safe = ("$" | "-" | "_" | ".");
|
@@ -1,7 +1,7 @@
|
|
1
1
|
/*
|
2
2
|
* redcloth_inline.c.rl
|
3
3
|
*
|
4
|
-
* Copyright (C)
|
4
|
+
* Copyright (C) 2009 Jason Garber
|
5
5
|
*/
|
6
6
|
#include <ruby.h>
|
7
7
|
#include "redcloth.h"
|
@@ -36,16 +36,52 @@ VALUE
|
|
36
36
|
red_parse_link_attr(VALUE self, VALUE regs, VALUE ref)
|
37
37
|
{
|
38
38
|
VALUE txt = rb_hash_aref(regs, ref);
|
39
|
-
VALUE new_regs = redcloth_link_attributes(self, txt);
|
39
|
+
VALUE new_regs = red_parse_title(redcloth_link_attributes(self, txt), ref);
|
40
|
+
|
40
41
|
return rb_funcall(regs, rb_intern("update"), 1, new_regs);
|
41
42
|
}
|
42
43
|
|
44
|
+
VALUE
|
45
|
+
red_parse_image_attr(VALUE self, VALUE regs, VALUE ref)
|
46
|
+
{
|
47
|
+
|
48
|
+
return red_parse_title(regs, ref);
|
49
|
+
}
|
50
|
+
|
51
|
+
VALUE
|
52
|
+
red_parse_title(VALUE regs, VALUE ref)
|
53
|
+
{
|
54
|
+
// Store title/alt
|
55
|
+
VALUE txt = rb_hash_aref(regs, ref);
|
56
|
+
if ( txt != Qnil ) {
|
57
|
+
char *p = RSTRING_PTR(txt) + RSTRING_LEN(txt);
|
58
|
+
if (*(p - 1) == ')') {
|
59
|
+
char level = -1;
|
60
|
+
p--;
|
61
|
+
while (p > RSTRING_PTR(txt) && level < 0) {
|
62
|
+
switch(*(p - 1)) {
|
63
|
+
case '(': ++level; break;
|
64
|
+
case ')': --level; break;
|
65
|
+
}
|
66
|
+
--p;
|
67
|
+
}
|
68
|
+
VALUE title = STR_NEW(p + 1, RSTRING_PTR(txt) + RSTRING_LEN(txt) - 2 - p );
|
69
|
+
if (p > RSTRING_PTR(txt) && *(p - 1) == ' ') --p;
|
70
|
+
if (p != RSTRING_PTR(txt)) {
|
71
|
+
rb_hash_aset(regs, ref, STR_NEW(RSTRING_PTR(txt), p - RSTRING_PTR(txt) ));
|
72
|
+
rb_hash_aset(regs, ID2SYM(rb_intern("title")), title);
|
73
|
+
}
|
74
|
+
}
|
75
|
+
}
|
76
|
+
return regs;
|
77
|
+
}
|
78
|
+
|
43
79
|
VALUE
|
44
80
|
red_pass_code(VALUE self, VALUE regs, VALUE ref, ID meth)
|
45
81
|
{
|
46
82
|
VALUE txt = rb_hash_aref(regs, ref);
|
47
83
|
if (!NIL_P(txt)) {
|
48
|
-
VALUE txt2 =
|
84
|
+
VALUE txt2 = STR_NEW2("");
|
49
85
|
rb_str_cat_escaped_for_preformatted(self, txt2, RSTRING_PTR(txt), RSTRING_PTR(txt) + RSTRING_LEN(txt));
|
50
86
|
rb_hash_aset(regs, ref, txt2);
|
51
87
|
}
|
@@ -62,14 +98,14 @@ red_block(VALUE self, VALUE regs, VALUE block, VALUE refs)
|
|
62
98
|
block = rb_funcall(block, rb_intern("strip"), 0);
|
63
99
|
if ((!NIL_P(block)) && !NIL_P(btype))
|
64
100
|
{
|
65
|
-
method =
|
66
|
-
if (method == rb_intern("notextile")) {
|
101
|
+
method = rb_str_intern(btype);
|
102
|
+
if (method == ID2SYM(rb_intern("notextile"))) {
|
67
103
|
rb_hash_aset(regs, sym_text, block);
|
68
104
|
} else {
|
69
105
|
rb_hash_aset(regs, sym_text, redcloth_inline2(self, block, refs));
|
70
106
|
}
|
71
|
-
if (
|
72
|
-
block = rb_funcall(self, method, 1, regs);
|
107
|
+
if (rb_ary_includes(rb_funcall(self, rb_intern("formatter_methods"), 0), method)) {
|
108
|
+
block = rb_funcall(self, SYM2ID(method), 1, regs);
|
73
109
|
} else {
|
74
110
|
fallback = rb_hash_aref(regs, ID2SYM(rb_intern("fallback")));
|
75
111
|
if (!NIL_P(fallback)) {
|
@@ -111,12 +147,10 @@ redcloth_inline(self, p, pe, refs)
|
|
111
147
|
VALUE refs;
|
112
148
|
{
|
113
149
|
int cs, act;
|
114
|
-
char *ts, *te, *reg, *eof;
|
115
|
-
char *orig_p = p
|
116
|
-
VALUE block =
|
150
|
+
char *ts = NULL, *te = NULL, *reg = NULL, *eof = NULL;
|
151
|
+
char *orig_p = p;
|
152
|
+
VALUE block = STR_NEW2("");
|
117
153
|
VALUE regs = Qnil;
|
118
|
-
unsigned int opts = 0;
|
119
|
-
VALUE buf = Qnil;
|
120
154
|
|
121
155
|
%% write init;
|
122
156
|
|
@@ -135,7 +169,7 @@ rb_str_cat_escaped(self, str, ts, te)
|
|
135
169
|
VALUE self, str;
|
136
170
|
char *ts, *te;
|
137
171
|
{
|
138
|
-
VALUE source_str =
|
172
|
+
VALUE source_str = STR_NEW(ts, te-ts);
|
139
173
|
VALUE escaped_str = rb_funcall(self, rb_intern("escape"), 1, source_str);
|
140
174
|
rb_str_concat(str, escaped_str);
|
141
175
|
}
|
@@ -145,7 +179,7 @@ rb_str_cat_escaped_for_preformatted(self, str, ts, te)
|
|
145
179
|
VALUE self, str;
|
146
180
|
char *ts, *te;
|
147
181
|
{
|
148
|
-
VALUE source_str =
|
182
|
+
VALUE source_str = STR_NEW(ts, te-ts);
|
149
183
|
VALUE escaped_str = rb_funcall(self, rb_intern("escape_pre"), 1, source_str);
|
150
184
|
rb_str_concat(str, escaped_str);
|
151
185
|
}
|