wikiwah 0.1.3 → 0.1.4
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/wikiwah/converter.rb +4 -4
- data/lib/wikiwah/flow.rb +13 -5
- data/lib/wikiwah/version.rb +1 -1
- data/test/wikiwah/flow_tests.rb +35 -11
- data/test/wikiwah_tests.rb +15 -11
- metadata +4 -4
data/lib/wikiwah/converter.rb
CHANGED
@@ -26,7 +26,7 @@ module WikiWah
|
|
26
26
|
end
|
27
27
|
|
28
28
|
def init_transformer
|
29
|
-
@transformer = WikiWah::Subst.new
|
29
|
+
@transformer = WikiWah::Subst.new
|
30
30
|
@transformer.add_transformation(/""(.+)""/) do |match|
|
31
31
|
# Double-double-quoted
|
32
32
|
CGI.escapeHTML(match[1])
|
@@ -35,9 +35,9 @@ module WikiWah
|
|
35
35
|
# Backslash-quoted
|
36
36
|
match[1]
|
37
37
|
end
|
38
|
-
@transformer.add_transformation(/\<(.+?)\>/m) do |match|
|
38
|
+
@transformer.add_transformation(/\<(.+?)\>/m) do |match|
|
39
39
|
# In-line HTML
|
40
|
-
match[0]
|
40
|
+
match[0]
|
41
41
|
end
|
42
42
|
@transformer.add_transformation(/\{(.+?)\}(@(\S*[\w\/]))?/m) do |match|
|
43
43
|
# Distinuished link
|
@@ -57,7 +57,7 @@ module WikiWah
|
|
57
57
|
# Bold/italic/etc.
|
58
58
|
tag = case match[2]
|
59
59
|
when '*'; 'strong'
|
60
|
-
when '+'; '
|
60
|
+
when '+'; 'samp'
|
61
61
|
when '/'; 'em'
|
62
62
|
when '_'; 'u'
|
63
63
|
end
|
data/lib/wikiwah/flow.rb
CHANGED
@@ -120,15 +120,23 @@ module WikiWah
|
|
120
120
|
when /\A(( *)\| )/
|
121
121
|
push_context('pre',$2.size)
|
122
122
|
block = strip_prefix($1, block)
|
123
|
-
write_html(
|
123
|
+
write_html(CGI.escapeHTML(block))
|
124
124
|
|
125
|
-
# preformatted (with
|
126
|
-
when /\A( *)\,-- (\S+)
|
125
|
+
# preformatted (with element and class)
|
126
|
+
when /\A( *)\,--(?: *(\S+))?.*\n/
|
127
127
|
indent = $1
|
128
|
-
|
128
|
+
html_element, *html_classes = $2.split('.')
|
129
129
|
push_context('pre',indent.size)
|
130
130
|
block = strip_prefix(indent + "| ", $')
|
131
|
-
|
131
|
+
block = CGI.escapeHTML(block)
|
132
|
+
if html_element
|
133
|
+
open_tag = html_element
|
134
|
+
unless html_classes.empty?
|
135
|
+
open_tag += %( class="#{html_classes.join(' ')}")
|
136
|
+
end
|
137
|
+
block = "<#{open_tag}>" + block + "</#{html_element}>"
|
138
|
+
end
|
139
|
+
write_html(block)
|
132
140
|
|
133
141
|
# heading
|
134
142
|
when /\A( *)(=+) /
|
data/lib/wikiwah/version.rb
CHANGED
data/test/wikiwah/flow_tests.rb
CHANGED
@@ -163,7 +163,31 @@ item 1
|
|
163
163
|
P2
|
164
164
|
</p>
|
165
165
|
|
166
|
+
==== # Preformatted
|
167
|
+
| code
|
168
|
+
|
|
169
|
+
| more code
|
170
|
+
----
|
171
|
+
<pre>
|
172
|
+
code
|
173
|
+
|
174
|
+
more code
|
175
|
+
</pre>
|
176
|
+
|
177
|
+
==== # Output sample
|
178
|
+
,-- samp --
|
179
|
+
| code
|
180
|
+
|
|
181
|
+
| more code
|
182
|
+
----
|
183
|
+
<pre>
|
184
|
+
<samp>code
|
185
|
+
|
186
|
+
more code
|
187
|
+
</samp></pre>
|
188
|
+
|
166
189
|
==== # Code
|
190
|
+
,-- code --
|
167
191
|
| code
|
168
192
|
|
|
169
193
|
| more code
|
@@ -175,15 +199,15 @@ more code
|
|
175
199
|
</code></pre>
|
176
200
|
|
177
201
|
==== # Code with language specified
|
178
|
-
,-- fnord-script --
|
179
|
-
|
|
202
|
+
,-- code.fnord-script --
|
203
|
+
| fnord
|
180
204
|
|
|
181
|
-
|
|
205
|
+
| fnord fnord
|
182
206
|
----
|
183
207
|
<pre>
|
184
|
-
<code class="fnord-script">
|
208
|
+
<code class="fnord-script">fnord
|
185
209
|
|
186
|
-
|
210
|
+
fnord fnord
|
187
211
|
</code></pre>
|
188
212
|
|
189
213
|
==== # Blockquote
|
@@ -234,8 +258,8 @@ item
|
|
234
258
|
</li>
|
235
259
|
</ul>
|
236
260
|
<pre>
|
237
|
-
|
238
|
-
</
|
261
|
+
code
|
262
|
+
</pre>
|
239
263
|
|
240
264
|
====
|
241
265
|
* item
|
@@ -247,8 +271,8 @@ item
|
|
247
271
|
item
|
248
272
|
</li>
|
249
273
|
<pre>
|
250
|
-
|
251
|
-
</
|
274
|
+
code
|
275
|
+
</pre>
|
252
276
|
</ul>
|
253
277
|
|
254
278
|
====
|
@@ -345,10 +369,10 @@ two
|
|
345
369
|
| z
|
346
370
|
----
|
347
371
|
<pre>
|
348
|
-
|
372
|
+
x
|
349
373
|
|y|
|
350
374
|
z
|
351
|
-
</
|
375
|
+
</pre>
|
352
376
|
|
353
377
|
====
|
354
378
|
- list item
|
data/test/wikiwah_tests.rb
CHANGED
@@ -16,33 +16,37 @@ class WikiWahTests < Test::Unit::TestCase
|
|
16
16
|
def test_paragraph
|
17
17
|
assert_wikiwah("<p>\nxyz\n</p>\n", "xyz\n")
|
18
18
|
end
|
19
|
-
|
19
|
+
|
20
20
|
def test_strong
|
21
21
|
assert_wikiwah("<p>\n<strong>xyz</strong>\n</p>\n", "*xyz*\n")
|
22
22
|
end
|
23
|
-
|
23
|
+
|
24
24
|
def test_em
|
25
25
|
assert_wikiwah("<p>\n<em>xyz</em>\n</p>\n", "/xyz/\n")
|
26
26
|
end
|
27
|
-
|
27
|
+
|
28
|
+
def test_samp
|
29
|
+
assert_wikiwah("<p>\n<samp>foo bar</samp> baz\n</p>\n", "+foo bar+ baz\n")
|
30
|
+
end
|
31
|
+
|
28
32
|
def test_strong_em
|
29
33
|
assert_wikiwah("<p>\n<strong><em>xyz</em></strong>\n</p>\n", "*/xyz/*\n")
|
30
34
|
end
|
31
|
-
|
35
|
+
|
32
36
|
def test_strong_then_em
|
33
37
|
assert_wikiwah("<p>\n<strong>abc</strong>=<em>xyz</em>\n</p>\n", "*abc*=/xyz/\n")
|
34
38
|
end
|
35
|
-
|
39
|
+
|
36
40
|
def test_link
|
37
|
-
assert_wikiwah(%{<p>\n<a href='/yyy'>xxx</a>\n</p>\n},
|
41
|
+
assert_wikiwah(%{<p>\n<a href='/yyy'>xxx</a>\n</p>\n},
|
38
42
|
"{xxx}@/yyy\n")
|
39
43
|
end
|
40
|
-
|
44
|
+
|
41
45
|
def test_bold_link
|
42
|
-
assert_wikiwah(%{<p>\n<a href='/yyy'><strong>xxx</strong></a>\n</p>\n},
|
46
|
+
assert_wikiwah(%{<p>\n<a href='/yyy'><strong>xxx</strong></a>\n</p>\n},
|
43
47
|
"{*xxx*}@/yyy\n")
|
44
48
|
end
|
45
|
-
|
49
|
+
|
46
50
|
def assert_wikiwah_unchanged(input)
|
47
51
|
expected = "<p>\n" + input + "</p>\n"
|
48
52
|
assert_wikiwah(expected, input)
|
@@ -51,9 +55,9 @@ class WikiWahTests < Test::Unit::TestCase
|
|
51
55
|
def test_inline_html
|
52
56
|
assert_wikiwah_unchanged(%{<b>blah</b><img src="xxx" />})
|
53
57
|
end
|
54
|
-
|
58
|
+
|
55
59
|
def test_inline_html_with_link
|
56
60
|
assert_wikiwah_unchanged(%{<b>blah</b><img src="http://blah.com" />})
|
57
61
|
end
|
58
|
-
|
62
|
+
|
59
63
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: wikiwah
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.4
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-06-
|
12
|
+
date: 2013-06-19 00:00:00.000000000 Z
|
13
13
|
dependencies: []
|
14
14
|
description: ! "WikiWah is a text-to-HTML converter, along the lines of Markdown.
|
15
15
|
\ \n\nThis isn't the markup language you're looking for. \nIt offers no improvements
|
@@ -51,7 +51,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
51
51
|
version: '0'
|
52
52
|
segments:
|
53
53
|
- 0
|
54
|
-
hash: -
|
54
|
+
hash: -1320649274484203233
|
55
55
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
56
56
|
none: false
|
57
57
|
requirements:
|
@@ -60,7 +60,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
60
60
|
version: '0'
|
61
61
|
segments:
|
62
62
|
- 0
|
63
|
-
hash: -
|
63
|
+
hash: -1320649274484203233
|
64
64
|
requirements: []
|
65
65
|
rubyforge_project:
|
66
66
|
rubygems_version: 1.8.23
|