skwp-superredcloth 1.160
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +4 -0
- data/COPYING +18 -0
- data/README +162 -0
- data/Rakefile +180 -0
- data/ext/superredcloth_scan/extconf.rb +6 -0
- data/ext/superredcloth_scan/superredcloth.h +77 -0
- data/ext/superredcloth_scan/superredcloth_common.rl +63 -0
- data/ext/superredcloth_scan/superredcloth_inline.c +19445 -0
- data/ext/superredcloth_scan/superredcloth_inline.rl +234 -0
- data/ext/superredcloth_scan/superredcloth_scan.c +21138 -0
- data/ext/superredcloth_scan/superredcloth_scan.rl +130 -0
- data/extras/mingw-rbconfig.rb +176 -0
- data/lib/superredcloth.rb +126 -0
- data/lib/superredcloth_scan.so +0 -0
- data/test/code.yml +148 -0
- data/test/definitions.yml +36 -0
- data/test/filter_html.yml +56 -0
- data/test/images.yml +171 -0
- data/test/instiki.yml +61 -0
- data/test/links.yml +161 -0
- data/test/lists.yml +385 -0
- data/test/poignant.yml +64 -0
- data/test/sanitize_html.yml +9 -0
- data/test/table.yml +212 -0
- data/test/test_parser.rb +22 -0
- data/test/textile_hard_breaks.yml +37 -0
- data/test/textism.yml +374 -0
- metadata +81 -0
@@ -0,0 +1,130 @@
|
|
1
|
+
/*
|
2
|
+
* superredcloth_scan.rl
|
3
|
+
*
|
4
|
+
* $Author: why $
|
5
|
+
* $Date$
|
6
|
+
*
|
7
|
+
* Copyright (C) 2007 why the lucky stiff
|
8
|
+
*/
|
9
|
+
#define superredcloth_scan_c
|
10
|
+
|
11
|
+
#include <ruby.h>
|
12
|
+
#include "superredcloth.h"
|
13
|
+
|
14
|
+
VALUE super_ParseError, super_RedCloth;
|
15
|
+
|
16
|
+
%%{
|
17
|
+
|
18
|
+
machine superredcloth_scan;
|
19
|
+
include superredcloth_common "superredcloth_common.rl";
|
20
|
+
|
21
|
+
action notextile { rb_str_append(html, rb_funcall(super_RedCloth, rb_intern("ignore"), 1, regs)); }
|
22
|
+
|
23
|
+
# blocks
|
24
|
+
notextile_start = "<notextile>" ;
|
25
|
+
notextile_end = "</notextile>" ;
|
26
|
+
btype = ( "p" | "h1" | "h2" | "h3" | "h4" | "h5" | "h6" | "bq" ) >A %{ STORE(type) } ;
|
27
|
+
block_start = ( btype A C :> dotspace ) ;
|
28
|
+
block_end = ( CRLF{2} | EOF );
|
29
|
+
ftype = ( "fn" >A %{ STORE(type) } digit+ >A %{ STORE(id) } ) ;
|
30
|
+
footnote_start = ( ftype A C :> dotspace ) ;
|
31
|
+
ul = "*" %{nest++; list_type = "ul";};
|
32
|
+
ol = "#" %{nest++; list_type = "ol";};
|
33
|
+
list_start = ( ( ul | ol )+ N A C :> " " ) >{nest = 0;} ;
|
34
|
+
|
35
|
+
# tables
|
36
|
+
para = ( default+ ) -- CRLF ;
|
37
|
+
btext = para ( CRLF{2} )? ;
|
38
|
+
tddef = ( S A C :> dotspace ) ;
|
39
|
+
td = ( tddef? btext >A %T :> "|" >{PASS(table, text, td);} ) >X ;
|
40
|
+
trdef = ( A C :> dotspace ) ;
|
41
|
+
tr = ( trdef? "|" %{INLINE(table, tr_open);} td+ ) >X %{INLINE(table, tr_close);} ;
|
42
|
+
trows = ( tr (CRLF >X tr)* ) ;
|
43
|
+
tdef = ( "table" >X A C :> dotspace CRLF ) ;
|
44
|
+
table = ( tdef? trows >{INLINE(table, table_open);} ) >{ reg = NULL; } ;
|
45
|
+
|
46
|
+
notextile := |*
|
47
|
+
notextile_end { DONE(block); fgoto main; };
|
48
|
+
default => cat;
|
49
|
+
*|;
|
50
|
+
|
51
|
+
block := |*
|
52
|
+
block_end { ADD_BLOCK(); fgoto main; };
|
53
|
+
default => cat;
|
54
|
+
*|;
|
55
|
+
|
56
|
+
footnote := |*
|
57
|
+
block_end { ADD_BLOCK(); fgoto main; };
|
58
|
+
default => cat;
|
59
|
+
*|;
|
60
|
+
|
61
|
+
list := |*
|
62
|
+
CRLF list_start { ADD_BLOCK(); LIST_ITEM(); };
|
63
|
+
block_end { ADD_BLOCK(); nest = 0; LIST_ITEM(); fgoto main; };
|
64
|
+
default => cat;
|
65
|
+
*|;
|
66
|
+
|
67
|
+
main := |*
|
68
|
+
notextile_start { ASET(type, notextile); fgoto notextile; };
|
69
|
+
block_start { fgoto block; };
|
70
|
+
footnote_start { fgoto footnote; };
|
71
|
+
list_start { list_layout = rb_ary_new(); LIST_ITEM(); fgoto list; };
|
72
|
+
table { INLINE(table, table_close); DONE(table); };
|
73
|
+
default { ASET(type, p); CAT(block); fgoto block; };
|
74
|
+
EOF;
|
75
|
+
*|;
|
76
|
+
|
77
|
+
}%%
|
78
|
+
|
79
|
+
%% write data nofinal;
|
80
|
+
|
81
|
+
VALUE
|
82
|
+
superredcloth_transform(p, pe)
|
83
|
+
char *p, *pe;
|
84
|
+
{
|
85
|
+
int cs, act, nest;
|
86
|
+
char *tokstart, *tokend, *reg;
|
87
|
+
VALUE html = rb_str_new2("");
|
88
|
+
VALUE table = rb_str_new2("");
|
89
|
+
VALUE block = rb_str_new2("");
|
90
|
+
VALUE regs = rb_hash_new();
|
91
|
+
VALUE list_layout = Qnil;
|
92
|
+
char *list_type = NULL;
|
93
|
+
|
94
|
+
%% write init;
|
95
|
+
|
96
|
+
%% write exec;
|
97
|
+
|
98
|
+
if (RSTRING(block)->len > 0)
|
99
|
+
{
|
100
|
+
ADD_BLOCK();
|
101
|
+
}
|
102
|
+
|
103
|
+
return html;
|
104
|
+
}
|
105
|
+
|
106
|
+
VALUE
|
107
|
+
superredcloth_transform2(str)
|
108
|
+
VALUE str;
|
109
|
+
{
|
110
|
+
rb_str_cat2(str, "\n");
|
111
|
+
StringValue(str);
|
112
|
+
return superredcloth_transform(RSTRING(str)->ptr, RSTRING(str)->ptr + RSTRING(str)->len + 1);
|
113
|
+
}
|
114
|
+
|
115
|
+
static VALUE
|
116
|
+
superredcloth_to_html(self)
|
117
|
+
VALUE self;
|
118
|
+
{
|
119
|
+
char *pe, *p;
|
120
|
+
int len = 0;
|
121
|
+
|
122
|
+
return superredcloth_transform2(self);
|
123
|
+
}
|
124
|
+
|
125
|
+
void Init_superredcloth_scan()
|
126
|
+
{
|
127
|
+
super_RedCloth = rb_define_class("SuperRedCloth", rb_cString);
|
128
|
+
rb_define_method(super_RedCloth, "to_html", superredcloth_to_html, 0);
|
129
|
+
super_ParseError = rb_define_class_under(super_RedCloth, "ParseError", rb_eException);
|
130
|
+
}
|
@@ -0,0 +1,176 @@
|
|
1
|
+
|
2
|
+
# This rbconfig.rb corresponds to a Ruby installation for win32 cross-compiled
|
3
|
+
# with mingw under i686-linux. It can be used to cross-compile extensions for
|
4
|
+
# win32 using said toolchain.
|
5
|
+
#
|
6
|
+
# This file assumes that a cross-compiled mingw32 build (compatible with the
|
7
|
+
# mswin32 builds) is installed under $HOME/ruby-mingw32.
|
8
|
+
|
9
|
+
module Config
|
10
|
+
#RUBY_VERSION == "1.8.5" or
|
11
|
+
# raise "ruby lib version (1.8.5) doesn't match executable version (#{RUBY_VERSION})"
|
12
|
+
|
13
|
+
mingw32 = ENV['MINGW32_RUBY'] || "#{ENV["HOME"]}/ruby-mingw32"
|
14
|
+
mingwpre = ENV['MINGW32_PREFIX']
|
15
|
+
TOPDIR = File.dirname(__FILE__).chomp!("/lib/ruby/1.8/i386-mingw32")
|
16
|
+
DESTDIR = '' unless defined? DESTDIR
|
17
|
+
CONFIG = {}
|
18
|
+
CONFIG["DESTDIR"] = DESTDIR
|
19
|
+
CONFIG["INSTALL"] = "/usr/bin/install -c"
|
20
|
+
CONFIG["prefix"] = (TOPDIR || DESTDIR + mingw32)
|
21
|
+
CONFIG["EXEEXT"] = ".exe"
|
22
|
+
CONFIG["ruby_install_name"] = "ruby"
|
23
|
+
CONFIG["RUBY_INSTALL_NAME"] = "ruby"
|
24
|
+
CONFIG["RUBY_SO_NAME"] = "msvcrt-ruby18"
|
25
|
+
CONFIG["SHELL"] = "/bin/sh"
|
26
|
+
CONFIG["PATH_SEPARATOR"] = ":"
|
27
|
+
CONFIG["PACKAGE_NAME"] = ""
|
28
|
+
CONFIG["PACKAGE_TARNAME"] = ""
|
29
|
+
CONFIG["PACKAGE_VERSION"] = ""
|
30
|
+
CONFIG["PACKAGE_STRING"] = ""
|
31
|
+
CONFIG["PACKAGE_BUGREPORT"] = ""
|
32
|
+
CONFIG["exec_prefix"] = "$(prefix)"
|
33
|
+
CONFIG["bindir"] = "$(exec_prefix)/bin"
|
34
|
+
CONFIG["sbindir"] = "$(exec_prefix)/sbin"
|
35
|
+
CONFIG["libexecdir"] = "$(exec_prefix)/libexec"
|
36
|
+
CONFIG["datadir"] = "$(prefix)/share"
|
37
|
+
CONFIG["sysconfdir"] = "$(prefix)/etc"
|
38
|
+
CONFIG["sharedstatedir"] = "$(prefix)/com"
|
39
|
+
CONFIG["localstatedir"] = "$(prefix)/var"
|
40
|
+
CONFIG["libdir"] = "$(exec_prefix)/lib"
|
41
|
+
CONFIG["includedir"] = "$(prefix)/include"
|
42
|
+
CONFIG["oldincludedir"] = "/usr/include"
|
43
|
+
CONFIG["infodir"] = "$(prefix)/info"
|
44
|
+
CONFIG["mandir"] = "$(prefix)/man"
|
45
|
+
CONFIG["build_alias"] = "i686-linux"
|
46
|
+
CONFIG["host_alias"] = "#{mingwpre}"
|
47
|
+
CONFIG["target_alias"] = "i386-mingw32"
|
48
|
+
CONFIG["ECHO_C"] = ""
|
49
|
+
CONFIG["ECHO_N"] = "-n"
|
50
|
+
CONFIG["ECHO_T"] = ""
|
51
|
+
CONFIG["LIBS"] = "-lwsock32 "
|
52
|
+
CONFIG["MAJOR"] = "1"
|
53
|
+
CONFIG["MINOR"] = "8"
|
54
|
+
CONFIG["TEENY"] = "4"
|
55
|
+
CONFIG["build"] = "i686-pc-linux"
|
56
|
+
CONFIG["build_cpu"] = "i686"
|
57
|
+
CONFIG["build_vendor"] = "pc"
|
58
|
+
CONFIG["build_os"] = "linux"
|
59
|
+
CONFIG["host"] = "i586-pc-mingw32msvc"
|
60
|
+
CONFIG["host_cpu"] = "i586"
|
61
|
+
CONFIG["host_vendor"] = "pc"
|
62
|
+
CONFIG["host_os"] = "mingw32msvc"
|
63
|
+
CONFIG["target"] = "i386-pc-mingw32"
|
64
|
+
CONFIG["target_cpu"] = "i386"
|
65
|
+
CONFIG["target_vendor"] = "pc"
|
66
|
+
CONFIG["target_os"] = "mingw32"
|
67
|
+
CONFIG["CC"] = "#{mingwpre}-gcc"
|
68
|
+
CONFIG["CFLAGS"] = "-g -O2 "
|
69
|
+
CONFIG["LDFLAGS"] = ""
|
70
|
+
CONFIG["CPPFLAGS"] = ""
|
71
|
+
CONFIG["OBJEXT"] = "o"
|
72
|
+
CONFIG["CPP"] = "#{mingwpre}-gcc -E"
|
73
|
+
CONFIG["EGREP"] = "grep -E"
|
74
|
+
CONFIG["GNU_LD"] = "yes"
|
75
|
+
CONFIG["CPPOUTFILE"] = "-o conftest.i"
|
76
|
+
CONFIG["OUTFLAG"] = "-o "
|
77
|
+
CONFIG["YACC"] = "bison -y"
|
78
|
+
CONFIG["RANLIB"] = "#{mingwpre}-ranlib"
|
79
|
+
CONFIG["AR"] = "#{mingwpre}-ar"
|
80
|
+
CONFIG["NM"] = "#{mingwpre}-nm"
|
81
|
+
CONFIG["WINDRES"] = "#{mingwpre}-windres"
|
82
|
+
CONFIG["DLLWRAP"] = "#{mingwpre}-dllwrap"
|
83
|
+
CONFIG["OBJDUMP"] = "#{mingwpre}-objdump"
|
84
|
+
CONFIG["LN_S"] = "ln -s"
|
85
|
+
CONFIG["SET_MAKE"] = ""
|
86
|
+
CONFIG["INSTALL_PROGRAM"] = "$(INSTALL)"
|
87
|
+
CONFIG["INSTALL_SCRIPT"] = "$(INSTALL)"
|
88
|
+
CONFIG["INSTALL_DATA"] = "$(INSTALL) -m 644"
|
89
|
+
CONFIG["RM"] = "rm -f"
|
90
|
+
CONFIG["CP"] = "cp"
|
91
|
+
CONFIG["MAKEDIRS"] = "mkdir -p"
|
92
|
+
CONFIG["LIBOBJS"] = " fileblocks$(U).o crypt$(U).o flock$(U).o acosh$(U).o win32$(U).o"
|
93
|
+
CONFIG["ALLOCA"] = ""
|
94
|
+
CONFIG["DLDFLAGS"] = " -Wl,--enable-auto-import,--export-all"
|
95
|
+
CONFIG["ARCH_FLAG"] = ""
|
96
|
+
CONFIG["STATIC"] = ""
|
97
|
+
CONFIG["CCDLFLAGS"] = ""
|
98
|
+
CONFIG["LDSHARED"] = "#{mingwpre}-gcc -shared -s"
|
99
|
+
CONFIG["DLEXT"] = "so"
|
100
|
+
CONFIG["DLEXT2"] = "dll"
|
101
|
+
CONFIG["LIBEXT"] = "a"
|
102
|
+
CONFIG["LINK_SO"] = ""
|
103
|
+
CONFIG["LIBPATHFLAG"] = " -L\"%s\""
|
104
|
+
CONFIG["RPATHFLAG"] = ""
|
105
|
+
CONFIG["LIBPATHENV"] = ""
|
106
|
+
CONFIG["TRY_LINK"] = ""
|
107
|
+
CONFIG["STRIP"] = "strip"
|
108
|
+
CONFIG["EXTSTATIC"] = ""
|
109
|
+
CONFIG["setup"] = "Setup"
|
110
|
+
CONFIG["MINIRUBY"] = "ruby -rfake"
|
111
|
+
CONFIG["PREP"] = "fake.rb"
|
112
|
+
CONFIG["RUNRUBY"] = "$(MINIRUBY) -I`cd $(srcdir)/lib; pwd`"
|
113
|
+
CONFIG["EXTOUT"] = ".ext"
|
114
|
+
CONFIG["ARCHFILE"] = ""
|
115
|
+
CONFIG["RDOCTARGET"] = ""
|
116
|
+
CONFIG["XCFLAGS"] = " -DRUBY_EXPORT"
|
117
|
+
CONFIG["XLDFLAGS"] = " -Wl,--stack,0x02000000 -L."
|
118
|
+
CONFIG["LIBRUBY_LDSHARED"] = "#{mingwpre}-gcc -shared -s"
|
119
|
+
CONFIG["LIBRUBY_DLDFLAGS"] = " -Wl,--enable-auto-import,--export-all -Wl,--out-implib=$(LIBRUBY)"
|
120
|
+
CONFIG["rubyw_install_name"] = "rubyw"
|
121
|
+
CONFIG["RUBYW_INSTALL_NAME"] = "rubyw"
|
122
|
+
CONFIG["LIBRUBY_A"] = "lib$(RUBY_SO_NAME)-static.a"
|
123
|
+
CONFIG["LIBRUBY_SO"] = "$(RUBY_SO_NAME).dll"
|
124
|
+
CONFIG["LIBRUBY_ALIASES"] = ""
|
125
|
+
CONFIG["LIBRUBY"] = "lib$(LIBRUBY_SO).a"
|
126
|
+
CONFIG["LIBRUBYARG"] = "$(LIBRUBYARG_SHARED)"
|
127
|
+
CONFIG["LIBRUBYARG_STATIC"] = "-l$(RUBY_SO_NAME)-static"
|
128
|
+
CONFIG["LIBRUBYARG_SHARED"] = "-l$(RUBY_SO_NAME)"
|
129
|
+
CONFIG["SOLIBS"] = "$(LIBS)"
|
130
|
+
CONFIG["DLDLIBS"] = ""
|
131
|
+
CONFIG["ENABLE_SHARED"] = "yes"
|
132
|
+
CONFIG["MAINLIBS"] = ""
|
133
|
+
CONFIG["COMMON_LIBS"] = "m"
|
134
|
+
CONFIG["COMMON_MACROS"] = ""
|
135
|
+
CONFIG["COMMON_HEADERS"] = "windows.h winsock.h"
|
136
|
+
CONFIG["EXPORT_PREFIX"] = ""
|
137
|
+
CONFIG["MINIOBJS"] = "dmydln.o"
|
138
|
+
CONFIG["MAKEFILES"] = "Makefile GNUmakefile"
|
139
|
+
CONFIG["arch"] = "i386-mingw32"
|
140
|
+
CONFIG["sitearch"] = "i386-msvcrt"
|
141
|
+
CONFIG["sitedir"] = "$(prefix)/lib/ruby/site_ruby"
|
142
|
+
CONFIG["configure_args"] = "'--host=#{mingwpre}' '--target=i386-mingw32' '--build=i686-linux' '--prefix=#{mingw32}' 'build_alias=i686-linux' 'host_alias=#{mingwpre}' 'target_alias=i386-mingw32'"
|
143
|
+
CONFIG["NROFF"] = "/usr/bin/nroff"
|
144
|
+
CONFIG["MANTYPE"] = "doc"
|
145
|
+
CONFIG["LTLIBOBJS"] = " fileblocks$(U).lo crypt$(U).lo flock$(U).lo acosh$(U).lo win32$(U).lo"
|
146
|
+
CONFIG["ruby_version"] = "$(MAJOR).$(MINOR)"
|
147
|
+
CONFIG["rubylibdir"] = "$(libdir)/ruby/$(ruby_version)"
|
148
|
+
CONFIG["archdir"] = "$(rubylibdir)/$(arch)"
|
149
|
+
CONFIG["sitelibdir"] = "$(sitedir)/$(ruby_version)"
|
150
|
+
CONFIG["sitearchdir"] = "$(sitelibdir)/$(sitearch)"
|
151
|
+
CONFIG["topdir"] = File.dirname(__FILE__)
|
152
|
+
MAKEFILE_CONFIG = {}
|
153
|
+
CONFIG.each{|k,v| MAKEFILE_CONFIG[k] = v.dup}
|
154
|
+
def Config::expand(val, config = CONFIG)
|
155
|
+
val.gsub!(/\$\$|\$\(([^()]+)\)|\$\{([^{}]+)\}/) do |var|
|
156
|
+
if !(v = $1 || $2)
|
157
|
+
'$'
|
158
|
+
elsif key = config[v = v[/\A[^:]+(?=(?::(.*?)=(.*))?\z)/]]
|
159
|
+
pat, sub = $1, $2
|
160
|
+
config[v] = false
|
161
|
+
Config::expand(key, config)
|
162
|
+
config[v] = key
|
163
|
+
key = key.gsub(/#{Regexp.quote(pat)}(?=\s|\z)/n) {sub} if pat
|
164
|
+
key
|
165
|
+
else
|
166
|
+
var
|
167
|
+
end
|
168
|
+
end
|
169
|
+
val
|
170
|
+
end
|
171
|
+
CONFIG.each_value do |val|
|
172
|
+
Config::expand(val)
|
173
|
+
end
|
174
|
+
end
|
175
|
+
RbConfig = Config # compatibility for ruby-1.9
|
176
|
+
CROSS_COMPILING = nil unless defined? CROSS_COMPILING
|
@@ -0,0 +1,126 @@
|
|
1
|
+
require 'superredcloth_scan'
|
2
|
+
|
3
|
+
class << SuperRedCloth
|
4
|
+
def pba opts
|
5
|
+
atts = ''
|
6
|
+
if opts[:block]
|
7
|
+
opts[:float] = opts.delete(:align)
|
8
|
+
else
|
9
|
+
opts[:"text-align"] = opts.delete(:align)
|
10
|
+
end
|
11
|
+
[:float, :"text-align"].each do |a|
|
12
|
+
opts[:style] = "#{a}:#{opts[a]};#{opts[:style]}" if opts[a]
|
13
|
+
end
|
14
|
+
[:"padding-right", :"padding-left"].each do |a|
|
15
|
+
opts[:style] = "#{a}:#{opts[a]}em;#{opts[:style]}" if opts[a]
|
16
|
+
end
|
17
|
+
[:style, :class, :lang, :id, :colspan, :rowspan, :title, :start].each do |a|
|
18
|
+
atts << " #{a}=\"#{ opts[a] }\"" if opts[a]
|
19
|
+
end
|
20
|
+
atts
|
21
|
+
end
|
22
|
+
[:h1, :h2, :h3, :h4, :h5, :h6, :p].each do |m|
|
23
|
+
define_method(m) do |opts|
|
24
|
+
"<#{m}#{pba(opts)}>#{opts[:text]}</#{m}>"
|
25
|
+
end
|
26
|
+
end
|
27
|
+
[:strong, :code, :em, :i, :b, :del, :ins, :sup, :sub, :span, :cite, :acronym].each do |m|
|
28
|
+
define_method(m) do |opts|
|
29
|
+
opts[:block] = true
|
30
|
+
"<#{m}#{pba(opts)}>#{opts[:text]}</#{m}>"
|
31
|
+
end
|
32
|
+
end
|
33
|
+
[:ol, :ul].each do |m|
|
34
|
+
define_method("#{m}_open") do |opts|
|
35
|
+
opts[:block] = true
|
36
|
+
"<#{m}#{pba(opts)}>\n"
|
37
|
+
end
|
38
|
+
define_method("#{m}_close") do |opts|
|
39
|
+
"</#{m}>"
|
40
|
+
end
|
41
|
+
end
|
42
|
+
def li opts
|
43
|
+
"\t<li#{pba(opts)}>#{opts[:text]}</li>\n"
|
44
|
+
end
|
45
|
+
def ignore opts
|
46
|
+
opts[:text]
|
47
|
+
end
|
48
|
+
alias_method :notextile, :ignore
|
49
|
+
def para txt
|
50
|
+
"<p>" + txt + "</p>"
|
51
|
+
end
|
52
|
+
def td opts
|
53
|
+
"\t\t\t<td#{pba(opts)}>#{opts[:text]}</td>\n"
|
54
|
+
end
|
55
|
+
def tr_open opts
|
56
|
+
"\t\t<tr#{pba(opts)}>\n"
|
57
|
+
end
|
58
|
+
def tr_close opts
|
59
|
+
"\t\t</tr>\n"
|
60
|
+
end
|
61
|
+
def table_open opts
|
62
|
+
"<table#{pba(opts)}>\n"
|
63
|
+
end
|
64
|
+
def table_close opts
|
65
|
+
"\t</table>"
|
66
|
+
end
|
67
|
+
def bq opts
|
68
|
+
"<blockquote><p>" + opts[:text] + "</p></blockquote>"
|
69
|
+
end
|
70
|
+
def link opts
|
71
|
+
"<a href=\"#{opts[:href].gsub(/&/, '&')}\"#{pba(opts)}>#{opts[:name]}</a>"
|
72
|
+
end
|
73
|
+
def image opts
|
74
|
+
p_opts = {:block => true, :align => opts.delete(:align)} if opts[:align]
|
75
|
+
opts[:alt] = opts[:title]
|
76
|
+
img = "<img src=\"#{opts[:src]}\"#{pba(opts)} alt=\"#{opts[:alt]}\" />"
|
77
|
+
img = "<a href=\"#{urlesc opts[:href]}\">#{img}</a>" if opts[:href]
|
78
|
+
img = "<p#{pba(p_opts)}>#{img}</p>" if p_opts
|
79
|
+
img
|
80
|
+
end
|
81
|
+
def footno opts
|
82
|
+
opts[:id] ||= opts[:text]
|
83
|
+
"<sup><a href=\"#fn#{opts[:id]}\">#{opts[:text]}</a></sup>"
|
84
|
+
end
|
85
|
+
def fn opts
|
86
|
+
no = opts[:id]
|
87
|
+
opts[:id] = "fn#{no}"
|
88
|
+
"<p#{pba(opts)}><sup>#{no}</sup> #{opts[:text]}</p>"
|
89
|
+
end
|
90
|
+
def snip opts
|
91
|
+
"<pre#{pba(opts)}><code>#{opts[:text]}</code></pre>"
|
92
|
+
end
|
93
|
+
def quote1 opts
|
94
|
+
"‘#{opts[:text]}’"
|
95
|
+
end
|
96
|
+
def quote2 opts
|
97
|
+
"“#{opts[:text]}”"
|
98
|
+
end
|
99
|
+
def ellipsis opts
|
100
|
+
"#{opts[:text]}…"
|
101
|
+
end
|
102
|
+
def emdash opts
|
103
|
+
"—"
|
104
|
+
end
|
105
|
+
def endash opts
|
106
|
+
"–"
|
107
|
+
end
|
108
|
+
def arrow opts
|
109
|
+
"→"
|
110
|
+
end
|
111
|
+
def dim opts
|
112
|
+
"#{opts[:x]}×#{opts[:y]}"
|
113
|
+
end
|
114
|
+
def trademark opts
|
115
|
+
"™"
|
116
|
+
end
|
117
|
+
def registered opts
|
118
|
+
"®"
|
119
|
+
end
|
120
|
+
def copyright opts
|
121
|
+
"©"
|
122
|
+
end
|
123
|
+
def urlesc txt
|
124
|
+
txt.gsub(/&/, '&')
|
125
|
+
end
|
126
|
+
end
|
Binary file
|
data/test/code.yml
ADDED
@@ -0,0 +1,148 @@
|
|
1
|
+
---
|
2
|
+
in: 'This is an empty dictionary: @{}@'
|
3
|
+
out: '<p>This is an empty dictionary: <code>{}</code></p>'
|
4
|
+
---
|
5
|
+
in: 'This is an empty dictionary: ==```=={}==```=='
|
6
|
+
out: '<p>This is an empty dictionary: ```{}```</p>'
|
7
|
+
---
|
8
|
+
in: 'This is an empty dictionary: ```{}```'
|
9
|
+
out: '<p>This is an empty dictionary: <pre><code>{}</code></pre></p>'
|
10
|
+
---
|
11
|
+
in: |-
|
12
|
+
Testing nested pre tags...
|
13
|
+
|
14
|
+
<pre>
|
15
|
+
<code>
|
16
|
+
Good code here.
|
17
|
+
|
18
|
+
<pre>
|
19
|
+
a = 1
|
20
|
+
</pre>
|
21
|
+
|
22
|
+
Bad code here.
|
23
|
+
|
24
|
+
<script language="JavaScript">
|
25
|
+
window.open( "about:blank" );
|
26
|
+
</script>
|
27
|
+
</code>
|
28
|
+
</pre>
|
29
|
+
|
30
|
+
out: |-
|
31
|
+
<p>Testing nested pre tags…</p>
|
32
|
+
|
33
|
+
|
34
|
+
<pre>
|
35
|
+
<code>
|
36
|
+
Good code here.
|
37
|
+
|
38
|
+
<pre>
|
39
|
+
a = 1
|
40
|
+
</pre>
|
41
|
+
|
42
|
+
Bad code here.
|
43
|
+
|
44
|
+
<script language="JavaScript">
|
45
|
+
window.open( "about:blank" );
|
46
|
+
</script>
|
47
|
+
</code>
|
48
|
+
</pre>
|
49
|
+
---
|
50
|
+
in: |-
|
51
|
+
<pre>
|
52
|
+
*** test
|
53
|
+
</pre>
|
54
|
+
out: |-
|
55
|
+
<pre>
|
56
|
+
*** test
|
57
|
+
</pre>
|
58
|
+
---
|
59
|
+
in: |-
|
60
|
+
<notextile>
|
61
|
+
*** test
|
62
|
+
</notextile>
|
63
|
+
out: |-
|
64
|
+
*** test
|
65
|
+
---
|
66
|
+
in: '*this <span></span> is strong*'
|
67
|
+
out: '<p><strong>this <span></span> is strong</strong></p>'
|
68
|
+
---
|
69
|
+
in: '*this <span>test</span> is strong*'
|
70
|
+
out: '<p><strong>this <span>test</span> is strong</strong></p>'
|
71
|
+
---
|
72
|
+
in: <pre class="code"> __inline__</pre>
|
73
|
+
out: <pre class="code"> __inline__</pre>
|
74
|
+
---
|
75
|
+
in: |-
|
76
|
+
* @foo@
|
77
|
+
* @bar@
|
78
|
+
* and @x@ is also.
|
79
|
+
|
80
|
+
out: |-
|
81
|
+
<ul>
|
82
|
+
<li><code>foo</code></li>
|
83
|
+
<li><code>bar</code></li>
|
84
|
+
<li>and <code>x</code> is also.</li>
|
85
|
+
</ul>
|
86
|
+
|
87
|
+
|
88
|
+
---
|
89
|
+
in: |-
|
90
|
+
<pre class="code"> <hello> </pre>
|
91
|
+
<pre class="code"> <hello> </pre>
|
92
|
+
out: |-
|
93
|
+
<pre class="code"> <hello> </pre>
|
94
|
+
<pre class="code"> <hello> </pre>
|
95
|
+
---
|
96
|
+
in: |-
|
97
|
+
Test of Markdown-style indented code.
|
98
|
+
|
99
|
+
a = [1, 2, 3]
|
100
|
+
a.each do |x|
|
101
|
+
puts "test number", x,
|
102
|
+
"and more!"
|
103
|
+
end
|
104
|
+
|
105
|
+
Paragraph 2.
|
106
|
+
|
107
|
+
Paragraph 3.
|
108
|
+
out: |-
|
109
|
+
<p>Test of Markdown-style indented code.</p>
|
110
|
+
|
111
|
+
<pre><code>a = [1, 2, 3]
|
112
|
+
a.each do |x|
|
113
|
+
puts "test number", x,
|
114
|
+
"and more!"
|
115
|
+
end</code></pre>
|
116
|
+
|
117
|
+
<p>Paragraph 2.</p>
|
118
|
+
|
119
|
+
<p>Paragraph 3.</p>
|
120
|
+
---
|
121
|
+
in: |-
|
122
|
+
If, however, you have a line or two of code or HTML or the like to embed, sandwich it between two sets of triple-backticks, ==```==, like so:
|
123
|
+
|
124
|
+
```
|
125
|
+
./foo.pl%
|
126
|
+
<p>foo outputs an HTML paragraph</p>
|
127
|
+
|
128
|
+
```
|
129
|
+
out: |-
|
130
|
+
<p>If, however, you have a line or two of code or <span class="caps">HTML</span> or the like to embed, sandwich it between two sets of triple-backticks, ```, like so:</p>
|
131
|
+
|
132
|
+
<pre><code>
|
133
|
+
./foo.pl%
|
134
|
+
<p>foo outputs an HTML paragraph</p>
|
135
|
+
</code></pre>
|
136
|
+
---
|
137
|
+
in: |-
|
138
|
+
```
|
139
|
+
here is some *starred* code
|
140
|
+
|
141
|
+
but I want some redcloth*bold*redcloth code
|
142
|
+
```
|
143
|
+
out: |-
|
144
|
+
<pre><code>
|
145
|
+
here is some *starred* code
|
146
|
+
|
147
|
+
but I want some <strong>bold</strong> code
|
148
|
+
</code></pre>
|