tartan 0.1.1 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +11 -0
- data/Manifest.txt +42 -0
- data/{README → README.txt} +12 -8
- data/Rakefile +78 -0
- data/lib/core_ext/array.rb +9 -10
- data/lib/core_ext/module.rb +2 -0
- data/lib/{symbolize.rb → core_ext/symbolize.rb} +0 -0
- data/lib/core_ext.rb +7 -0
- data/lib/{markdown.yml → tartan/markdown/markdown.yml} +67 -25
- data/lib/tartan/markdown/rules.rb +11 -0
- data/lib/tartan/markdown.rb +14 -0
- data/lib/tartan/table/rules.rb +11 -0
- data/lib/{table.yml → tartan/table/table.yml} +1 -1
- data/lib/tartan/test/base_rules.rb +9 -0
- data/lib/{test_base.yml → tartan/test/test_base.yml} +0 -0
- data/lib/{wiki-test.rb → tartan/test/wiki-test.rb} +15 -12
- data/lib/tartan/wiki_rule.rb +242 -0
- data/lib/tartan/wikilink/rules.rb +18 -0
- data/lib/{wikilink.yml → tartan/wikilink/wikilink.yml} +4 -2
- data/lib/tartan.rb +259 -270
- data/test/test-combo.rb +21 -14
- data/test/test-combo.yml +17 -0
- data/test/test-markdown-and-wikilink.rb +22 -0
- data/test/test-markdown-and-wikilink.yml +6 -0
- data/test/test-markdown.rb +4 -5
- data/test/test-markdown.yml +194 -1
- data/test/test-readme-example.rb +6 -5
- data/test/test-tables.rb +11 -7
- data/test/test-tartan.rb +8 -7
- data/test/test-wikilink.rb +13 -9
- data/test/test-wikilink.yml +3 -0
- metadata +47 -86
- data/lib/tartan_markdown.rb +0 -8
- data/lib/tartan_markdown_def.rb +0 -7
- data/lib/tartan_table_def.rb +0 -7
- data/lib/tartan_test_base_def.rb +0 -5
- data/lib/tartan_wikilink_def.rb +0 -14
- data/lib/wiki_rule.rb +0 -240
- data/test/MarkdownTest_1.0/Amps and angle encoding.html +0 -17
- data/test/MarkdownTest_1.0/Amps and angle encoding.text +0 -21
- data/test/MarkdownTest_1.0/Auto links.html +0 -18
- data/test/MarkdownTest_1.0/Auto links.text +0 -13
- data/test/MarkdownTest_1.0/Backslash codeescapes.html +0 -68
- data/test/MarkdownTest_1.0/Backslash codeescapes.text +0 -68
- data/test/MarkdownTest_1.0/Backslash simpleescapes.html +0 -33
- data/test/MarkdownTest_1.0/Backslash simpleescapes.text +0 -33
- data/test/MarkdownTest_1.0/Blockquotes with code blocks.html +0 -15
- data/test/MarkdownTest_1.0/Blockquotes with code blocks.text +0 -11
- data/test/MarkdownTest_1.0/Hard-wrapped paragraphs with list-like lines.html +0 -8
- data/test/MarkdownTest_1.0/Hard-wrapped paragraphs with list-like lines.text +0 -8
- data/test/MarkdownTest_1.0/Horizontal rules.html +0 -71
- data/test/MarkdownTest_1.0/Horizontal rules.text +0 -67
- data/test/MarkdownTest_1.0/Inline HTML (Advanced).html +0 -14
- data/test/MarkdownTest_1.0/Inline HTML (Advanced).text +0 -14
- data/test/MarkdownTest_1.0/Inline HTML (Simple).html +0 -72
- data/test/MarkdownTest_1.0/Inline HTML (Simple).text +0 -69
- data/test/MarkdownTest_1.0/Inline HTML comments.html +0 -13
- data/test/MarkdownTest_1.0/Inline HTML comments.text +0 -13
- data/test/MarkdownTest_1.0/Links, inline style.html +0 -9
- data/test/MarkdownTest_1.0/Links, inline style.text +0 -9
- data/test/MarkdownTest_1.0/Links, reference style.html +0 -18
- data/test/MarkdownTest_1.0/Links, reference style.text +0 -31
- data/test/MarkdownTest_1.0/Literal quotes in titles.html +0 -3
- data/test/MarkdownTest_1.0/Literal quotes in titles.text +0 -7
- data/test/MarkdownTest_1.0/Markdown Documentation - Basics.html +0 -314
- data/test/MarkdownTest_1.0/Markdown Documentation - Basics.out +0 -316
- data/test/MarkdownTest_1.0/Markdown Documentation - Basics.text +0 -306
- data/test/MarkdownTest_1.0/Markdown Documentation - Syntax.html +0 -942
- data/test/MarkdownTest_1.0/Markdown Documentation - Syntax.out +0 -947
- data/test/MarkdownTest_1.0/Markdown Documentation - Syntax.text +0 -888
- data/test/MarkdownTest_1.0/Nested blockquotes.html +0 -9
- data/test/MarkdownTest_1.0/Nested blockquotes.text +0 -5
- data/test/MarkdownTest_1.0/Ordered and unordered lists.html +0 -137
- data/test/MarkdownTest_1.0/Ordered and unordered lists.text +0 -122
- data/test/MarkdownTest_1.0/Strong and em together.html +0 -7
- data/test/MarkdownTest_1.0/Strong and em together.text +0 -7
- data/test/MarkdownTest_1.0/Tabs.html +0 -25
- data/test/MarkdownTest_1.0/Tabs.text +0 -21
- data/test/MarkdownTest_1.0/Tidyness.html +0 -8
- data/test/MarkdownTest_1.0/Tidyness.text +0 -5
- data/test/MarkdownTest_1.0/run-markdown.rb +0 -56
- data/test/MarkdownTest_1.0/test-fireball-markdown.rb +0 -177
- data/test/MarkdownTest_1.0/testdiff.rb +0 -42
- data/test/harder/test-markdown-harder.rb +0 -11
- data/test/harder/test-markdown-harder.yml +0 -111
- data/test/redcloth/redcloth-markdown-tests.rb +0 -29
- data/test/redcloth/redcloth-markdown-tests.yml +0 -218
- data/test/test-tartan-markdown.rb +0 -11
data/lib/tartan.rb
CHANGED
@@ -1,80 +1,9 @@
|
|
1
|
-
#$Id: tartan.rb
|
1
|
+
#$Id: tartan.rb 194 2007-04-24 07:53:09Z bitherder $
|
2
2
|
|
3
3
|
require 'rubygems'
|
4
4
|
require 'yaml'
|
5
|
-
require 'core_ext
|
6
|
-
require '
|
7
|
-
require 'wiki_rule'
|
8
|
-
require 'symbolize'
|
9
|
-
require 'core_ext/module'
|
10
|
-
require 'core_ext/array'
|
11
|
-
|
12
|
-
class Shelf
|
13
|
-
Front = "\001"
|
14
|
-
Back = "\002"
|
15
|
-
|
16
|
-
def initialize
|
17
|
-
@counter = 0
|
18
|
-
@hash = {}
|
19
|
-
end
|
20
|
-
|
21
|
-
def replacement(i)
|
22
|
-
replacement = String.new(Front + i.to_s + Back)
|
23
|
-
end
|
24
|
-
|
25
|
-
def shelve(string)
|
26
|
-
@counter = @counter.next
|
27
|
-
@hash[@counter] = string
|
28
|
-
replacement(@counter)
|
29
|
-
end
|
30
|
-
|
31
|
-
def putback(text)
|
32
|
-
new_text = text.gsub(/#{Front}([[:digit:]]+)#{Back}/) do
|
33
|
-
putback(@hash[$1.to_i])
|
34
|
-
end
|
35
|
-
end
|
36
|
-
end
|
37
|
-
|
38
|
-
class ParsedText < String
|
39
|
-
def initialize(claimed, value)
|
40
|
-
super(value)
|
41
|
-
@claimed = claimed
|
42
|
-
end
|
43
|
-
|
44
|
-
def claimed?
|
45
|
-
@claimed
|
46
|
-
end
|
47
|
-
end
|
48
|
-
|
49
|
-
class ParsedTextList < Array
|
50
|
-
def initialize(*args)
|
51
|
-
self
|
52
|
-
|
53
|
-
if 1 == args.length
|
54
|
-
add_text(false, args[0])
|
55
|
-
end
|
56
|
-
end
|
57
|
-
|
58
|
-
def add_text(claimed, text)
|
59
|
-
push(ParsedText.new(claimed, text))
|
60
|
-
end
|
61
|
-
|
62
|
-
def add(text_element)
|
63
|
-
push(text_element)
|
64
|
-
end
|
65
|
-
|
66
|
-
def add_back(text_element)
|
67
|
-
parsed_text = args.first
|
68
|
-
unshift(parsed_text)
|
69
|
-
end
|
70
|
-
|
71
|
-
def add_back_text(claimed, text)
|
72
|
-
unshift(ParsedText.new(claimed, text))
|
73
|
-
end
|
74
|
-
|
75
|
-
alias :to_s :join
|
76
|
-
end
|
77
|
-
|
5
|
+
require 'core_ext'
|
6
|
+
require 'tartan/wiki_rule'
|
78
7
|
|
79
8
|
class Object
|
80
9
|
def wiki_hash
|
@@ -100,260 +29,320 @@ class Array
|
|
100
29
|
end
|
101
30
|
end
|
102
31
|
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
32
|
+
|
33
|
+
module Tartan
|
34
|
+
class Shelf
|
35
|
+
Front = "\001"
|
36
|
+
Back = "\002"
|
37
|
+
|
38
|
+
def initialize
|
39
|
+
@counter = 0
|
40
|
+
@hash = {}
|
41
|
+
end
|
42
|
+
|
43
|
+
def replacement(i)
|
44
|
+
replacement = String.new(Front + i.to_s + Back)
|
45
|
+
end
|
46
|
+
|
47
|
+
def shelve(string)
|
48
|
+
@counter = @counter.next
|
49
|
+
@hash[@counter] = string
|
50
|
+
replacement(@counter)
|
51
|
+
end
|
52
|
+
|
53
|
+
def putback(text)
|
54
|
+
new_text = text.gsub(/#{Front}([[:digit:]]+)#{Back}/) do
|
55
|
+
putback(@hash[$1.to_i])
|
56
|
+
end
|
109
57
|
end
|
110
|
-
|
111
|
-
raise ArgumentError, "Can't find file #{file_name} in Ruby library path"
|
112
|
-
end
|
113
58
|
end
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
59
|
+
|
60
|
+
class ParsedText < String
|
61
|
+
def initialize(claimed, value)
|
62
|
+
super(value)
|
63
|
+
@claimed = claimed
|
64
|
+
end
|
65
|
+
|
66
|
+
def claimed?
|
67
|
+
@claimed
|
68
|
+
end
|
118
69
|
end
|
119
70
|
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
71
|
+
class ParsedTextList < Array
|
72
|
+
def initialize(*args)
|
73
|
+
if 1 == args.length
|
74
|
+
add_text(false, args[0])
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
def add_text(claimed, text)
|
79
|
+
push(ParsedText.new(claimed, text))
|
80
|
+
end
|
81
|
+
|
82
|
+
def add(text_element)
|
83
|
+
push(text_element)
|
84
|
+
end
|
85
|
+
|
86
|
+
def add_back(text_element)
|
87
|
+
parsed_text = args.first
|
88
|
+
unshift(parsed_text)
|
89
|
+
end
|
90
|
+
|
91
|
+
def add_back_text(claimed, text)
|
92
|
+
unshift(ParsedText.new(claimed, text))
|
93
|
+
end
|
94
|
+
|
95
|
+
alias :to_s :join
|
124
96
|
end
|
97
|
+
|
98
|
+
class WikiDefs < Hash
|
99
|
+
class << self
|
100
|
+
def find_file_in_path(file_name)
|
101
|
+
$:.each do |path|
|
102
|
+
file = path+'/'+file_name
|
103
|
+
return file if File.file?(file)
|
104
|
+
end
|
105
|
+
|
106
|
+
raise ArgumentError, "Can't find file #{file_name} in Ruby library path"
|
107
|
+
end
|
108
|
+
end
|
125
109
|
|
126
|
-
|
127
|
-
|
110
|
+
# Initialize initial defs
|
111
|
+
def initialize(external_defs={})
|
112
|
+
add(external_defs)
|
113
|
+
end
|
128
114
|
|
129
|
-
|
115
|
+
def find_sub_hash_index(hash_array, title)
|
116
|
+
index = hash_array.index { |sub_hash| sub_hash.title == title }
|
117
|
+
end
|
118
|
+
|
119
|
+
def add_yaml_file(def_file)
|
120
|
+
file_with_path = WikiDefs.find_file_in_path(def_file)
|
121
|
+
|
122
|
+
defs = YAML.load_file(file_with_path).symbolize
|
130
123
|
|
131
|
-
|
132
|
-
|
124
|
+
add(defs)
|
125
|
+
end
|
133
126
|
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
127
|
+
def add(defs)
|
128
|
+
defs.wiki_hash {|h| add_hash(h)}
|
129
|
+
self
|
130
|
+
end
|
138
131
|
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
# self[context_name] ||= Dictionary.new
|
143
|
-
|
132
|
+
def add_hash(external_defs)
|
133
|
+
external_defs.each {|context_name, external_rule_list|
|
134
|
+
self[context_name] ||= []
|
135
|
+
# self[context_name] ||= Dictionary.new
|
136
|
+
rule_dictionary = self[context_name]
|
144
137
|
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
138
|
+
external_rule_list.each { |proto_rule|
|
139
|
+
rule = case proto_rule
|
140
|
+
when WikiRule: proto_rule
|
141
|
+
when Symbol, String: WikiRule.new({ proto_rule => true })
|
142
|
+
when Hash: WikiRule.new(proto_rule);
|
143
|
+
else raise ArgumentError, "each matching rule must be a Hash"
|
144
|
+
end
|
152
145
|
|
153
|
-
|
154
|
-
|
146
|
+
if rule.template
|
147
|
+
index = find_sub_hash_index(self[context_name], rule.template)
|
155
148
|
|
156
|
-
|
157
|
-
|
149
|
+
rule = WikiRule.new(self[context_name][index].merge(rule))
|
150
|
+
end
|
158
151
|
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
152
|
+
if rule.before
|
153
|
+
# rule_dictionary
|
154
|
+
addByPosition(context_name, rule, :before)
|
155
|
+
rule.placed(:before)
|
156
|
+
elsif rule.after
|
157
|
+
addByPosition(context_name, rule, :after, 1)
|
158
|
+
rule.placed(:after)
|
159
|
+
elsif rule.beginning
|
160
|
+
self[context_name].unshift(rule)
|
161
|
+
rule.placed(:beginning)
|
162
|
+
else
|
163
|
+
self[context_name].push(rule)
|
164
|
+
end
|
165
|
+
}
|
172
166
|
}
|
173
|
-
|
174
|
-
end
|
167
|
+
end
|
175
168
|
|
176
|
-
|
169
|
+
private
|
177
170
|
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
171
|
+
def addByPosition(context_name, rule, position, index_offset=0)
|
172
|
+
index = find_sub_hash_index(self[context_name], rule[position])
|
173
|
+
unless index
|
174
|
+
raise "\"#{rule.title}\" can not be added #{position.to_s}" +
|
175
|
+
" \"#{rule[position]}\", because it does not exist"
|
176
|
+
end
|
177
|
+
self[context_name].insert(index+index_offset, rule)
|
184
178
|
end
|
185
|
-
self[context_name].insert(index+index_offset, rule)
|
186
179
|
end
|
187
|
-
end
|
188
180
|
|
189
|
-
class
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
181
|
+
class Parser < String
|
182
|
+
class << self
|
183
|
+
def yaml(file_name)
|
184
|
+
@defs ||= WikiDefs.new
|
185
|
+
@defs.add_yaml_file(file_name)
|
186
|
+
end
|
195
187
|
|
196
|
-
|
197
|
-
|
198
|
-
|
188
|
+
def defs
|
189
|
+
@defs
|
190
|
+
end
|
199
191
|
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
192
|
+
def add_defs (def_set)
|
193
|
+
@defs ||= WikiDefs.new
|
194
|
+
@defs.add(def_set)
|
195
|
+
end
|
204
196
|
|
205
|
-
|
206
|
-
|
197
|
+
alias :set_defs :add_defs
|
198
|
+
end
|
207
199
|
|
208
|
-
|
200
|
+
# parser helper methods
|
209
201
|
|
210
|
-
|
211
|
-
|
212
|
-
|
202
|
+
def initialize_helper
|
203
|
+
@sequences = {}
|
204
|
+
end
|
213
205
|
|
214
|
-
|
215
|
-
|
216
|
-
|
206
|
+
def count(str)
|
207
|
+
str.length
|
208
|
+
end
|
217
209
|
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
210
|
+
def sequence(sequence_id)
|
211
|
+
@sequences[sequence_id] ||= 0
|
212
|
+
@sequences[sequence_id] += 1
|
213
|
+
end
|
222
214
|
|
223
|
-
|
224
|
-
|
225
|
-
|
215
|
+
def sequence_reset(sequence_id)
|
216
|
+
@sequences[sequence_id] = 0
|
217
|
+
end
|
226
218
|
|
227
|
-
|
228
|
-
|
229
|
-
|
219
|
+
def untabify(text)
|
220
|
+
text.gsub(/(\n?)(?:([^\t\n]{4})|([^\t\n]*)\t)/n) {$1+[$+].pack("A4")}
|
221
|
+
end
|
230
222
|
|
231
|
-
|
232
|
-
|
233
|
-
|
223
|
+
def len(text)
|
224
|
+
text.length
|
225
|
+
end
|
234
226
|
|
235
|
-
|
236
|
-
|
237
|
-
|
227
|
+
def finalize(type, text)
|
228
|
+
text
|
229
|
+
end
|
238
230
|
|
239
|
-
|
231
|
+
# core Tartan methods
|
240
232
|
|
241
|
-
|
242
|
-
|
233
|
+
def initialize(wstring, options=nil)
|
234
|
+
wstring.gsub!(/\r/, '')
|
243
235
|
|
244
|
-
|
236
|
+
@default_rule = WikiRule.new
|
245
237
|
|
246
|
-
|
238
|
+
@shelf = Shelf.new
|
247
239
|
|
248
|
-
|
240
|
+
@wiki_string = wstring
|
249
241
|
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
242
|
+
if !options
|
243
|
+
if defined? WikiOptions
|
244
|
+
@options = WikiOptions.dup
|
245
|
+
else
|
246
|
+
@options = {}
|
247
|
+
end
|
248
|
+
else
|
249
|
+
@options = options
|
250
|
+
end
|
259
251
|
|
260
|
-
|
261
|
-
|
252
|
+
initialize_helper
|
253
|
+
end
|
262
254
|
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
255
|
+
def substitute(string, match)
|
256
|
+
# do function value substutution
|
257
|
+
local_string = string.gsub(/#\{([a-zA-Z_]+)(?:\((.*?)\))?\}/m) {|to_eval|
|
258
|
+
function_match = $~
|
267
259
|
|
268
|
-
|
269
|
-
|
270
|
-
|
260
|
+
# break the parameters up
|
261
|
+
# '-1' used to retain all parameters even if they are empty
|
262
|
+
params = function_match[2].split(/,/,-1)
|
271
263
|
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
264
|
+
params.collect! { |param|
|
265
|
+
"nul param" ": " + string if ! param
|
266
|
+
substitute(param, match)
|
267
|
+
}
|
276
268
|
|
277
|
-
|
278
|
-
|
269
|
+
send(function_match[1].to_sym, *params)
|
270
|
+
}
|
279
271
|
|
280
|
-
|
272
|
+
local_string = match.replace(local_string) if match
|
281
273
|
|
282
|
-
|
283
|
-
|
284
|
-
|
274
|
+
# do variable substitution
|
275
|
+
return local_string.gsub(/\{\{\{(.+?)\}\}\}/) {|var| get_var($1)}
|
276
|
+
end
|
285
277
|
|
286
|
-
|
287
|
-
|
288
|
-
|
278
|
+
def shelve(string)
|
279
|
+
@shelf.shelve(string)
|
280
|
+
end
|
289
281
|
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
282
|
+
def to_type(type=:html, context=:block)
|
283
|
+
out = @shelf.putback(parse_by_context(type, context, @wiki_string))
|
284
|
+
finalize(type, out)
|
285
|
+
end
|
294
286
|
|
295
|
-
|
287
|
+
alias :to_html :to_type
|
296
288
|
|
297
|
-
|
298
|
-
|
299
|
-
end
|
300
|
-
|
301
|
-
def set_vars(var_cluster, match)
|
302
|
-
return unless var_cluster
|
289
|
+
def set_vars(var_cluster, match)
|
290
|
+
return unless var_cluster
|
303
291
|
|
304
|
-
|
305
|
-
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
|
292
|
+
if Array == var_cluster.class
|
293
|
+
var_cluster.each do |a_hash|
|
294
|
+
set_vars(a_hash, match)
|
295
|
+
end
|
296
|
+
return
|
297
|
+
end
|
310
298
|
|
311
|
-
|
299
|
+
local_hash = var_cluster.dup
|
312
300
|
|
313
|
-
|
314
|
-
|
315
|
-
|
301
|
+
var_cluster.each do |var_name,var_val|
|
302
|
+
var_val = substitute(var_val, match)
|
303
|
+
var_name = substitute(var_name, match)
|
316
304
|
|
317
|
-
|
318
|
-
|
319
|
-
|
320
|
-
|
321
|
-
|
322
|
-
|
305
|
+
local_hash[var_name] = var_val
|
306
|
+
# allow case-insensitive names via :set for markdown
|
307
|
+
local_hash[var_name.downcase] = var_val
|
308
|
+
end
|
309
|
+
@options.merge!(local_hash)
|
310
|
+
end
|
323
311
|
|
324
|
-
|
325
|
-
|
326
|
-
|
327
|
-
|
328
|
-
|
329
|
-
|
312
|
+
def get_var(var)
|
313
|
+
# not all variable names are downcased
|
314
|
+
value = @options[var]
|
315
|
+
value ||= @options[var.downcase]
|
316
|
+
return value
|
317
|
+
end
|
330
318
|
|
331
|
-
|
332
|
-
|
319
|
+
def parse_by_context(parse_type, parse_context, parse_string)
|
320
|
+
parsing = ParsedTextList.new(parse_string)
|
333
321
|
|
334
|
-
|
322
|
+
self.class.defs[parse_context].each do |rule|
|
335
323
|
|
336
|
-
|
337
|
-
|
338
|
-
|
339
|
-
|
340
|
-
|
341
|
-
|
342
|
-
|
324
|
+
if rule.default_rule
|
325
|
+
@default_rule = @default_rule.deep_merge(rule)
|
326
|
+
next if rule.ignore
|
327
|
+
else
|
328
|
+
next if rule.ignore
|
329
|
+
rule = @default_rule.deep_merge(rule)
|
330
|
+
end
|
343
331
|
|
344
|
-
|
345
|
-
|
346
|
-
|
332
|
+
if !rule.match && rule.vars_to_set
|
333
|
+
set_vars(rule.vars_to_set, nil)
|
334
|
+
end
|
347
335
|
|
348
|
-
|
349
|
-
|
350
|
-
|
336
|
+
if rule.match
|
337
|
+
parsing = rule.parse_element(parse_type, parsing, self)
|
338
|
+
end
|
351
339
|
|
352
|
-
|
353
|
-
|
354
|
-
|
355
|
-
|
340
|
+
if rule.rescan
|
341
|
+
parsing = ParsedTextList.new(parsing.to_s)
|
342
|
+
end
|
343
|
+
end
|
356
344
|
|
357
|
-
|
345
|
+
parsing.to_s
|
346
|
+
end
|
358
347
|
end
|
359
|
-
end
|
348
|
+
end # Tartan
|
data/test/test-combo.rb
CHANGED
@@ -1,23 +1,30 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
-
#$Id: test-combo.rb
|
2
|
+
#$Id: test-combo.rb 190 2007-02-22 15:12:19Z bitherder $
|
3
3
|
|
4
4
|
$:.unshift File.join(File.dirname(__FILE__), "..", "lib")
|
5
5
|
|
6
|
-
require '
|
7
|
-
require '
|
8
|
-
require '
|
6
|
+
require 'tartan/markdown'
|
7
|
+
require 'tartan/wikilink/rules'
|
8
|
+
require 'tartan/table/rules'
|
9
|
+
require 'tartan/test/wiki-test'
|
9
10
|
require 'wikilink-test-helper'
|
10
|
-
require 'wiki-test'
|
11
11
|
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
12
|
+
module Tartan
|
13
|
+
module Combo
|
14
|
+
class Parser < Tartan::Parser
|
15
|
+
include Tartan::Markdown::Rules
|
16
|
+
include Tartan::Wikilink::Rules
|
17
|
+
include Tartan::Table::Rules
|
18
|
+
include WikilinkTestHelper
|
19
|
+
end
|
20
|
+
end
|
17
21
|
end
|
18
22
|
|
19
|
-
cases = WikiTestCases.new(
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
+
cases = WikiTestCases.new( Tartan::Combo::Parser,
|
24
|
+
[ "test-wikilink.yml",
|
25
|
+
"test-markdown.yml",
|
26
|
+
"test-tables.yml",
|
27
|
+
"test-combo.yml"
|
28
|
+
]
|
29
|
+
)
|
23
30
|
|
data/test/test-combo.yml
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
#$Id: test-tables.yml 124 2006-05-07 16:28:09Z larry $
|
2
|
+
|
3
|
+
title: TableInCodeBlock
|
4
|
+
in: " [|bob||jim|]"
|
5
|
+
html: |-
|
6
|
+
<pre><code>[|bob||jim|]
|
7
|
+
</code></pre>
|
8
|
+
---
|
9
|
+
title: TableInBackquotes
|
10
|
+
in: '`[|bob||jim|]`'
|
11
|
+
html: |-
|
12
|
+
<p><code>[|bob||jim|]</code></p>
|
13
|
+
---
|
14
|
+
title:
|
15
|
+
in: "[| [[Blog]] (new!) |]"
|
16
|
+
html: |-
|
17
|
+
<table class=""><tr><td><a class="existing" href="/prefix/Blog">Blog</a> (new!)</td></tr></table>
|
@@ -0,0 +1,22 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
#$Id: test-markdown-and-wikilink.rb 194 2007-04-24 07:53:09Z bitherder $
|
3
|
+
|
4
|
+
$:.unshift File.join(File.dirname(__FILE__), "..", "lib")
|
5
|
+
|
6
|
+
require 'tartan'
|
7
|
+
require 'tartan/wikilink/rules'
|
8
|
+
require 'tartan/test/wiki-test'
|
9
|
+
require 'tartan/test/base_rules'
|
10
|
+
require 'wikilink-test-helper'
|
11
|
+
|
12
|
+
module Tartan
|
13
|
+
module Wikilink
|
14
|
+
class Parser < Tartan::Parser
|
15
|
+
include Tartan::Markdown::Rules
|
16
|
+
include Tartan::Wikilink::Rules
|
17
|
+
include WikilinkTestHelper
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
cases = WikiTestCases.new(Tartan::Wikilink::Parser, "test-markdown-and-wikilink.yml")
|