dtext_rb 1.0.14 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.ruby-version +1 -0
- data/Gemfile.lock +29 -24
- data/VERSION +1 -1
- data/dtext_rb.gemspec +5 -5
- data/ext/dtext/dtext.c +1970 -1919
- data/ext/dtext/dtext.rl +9 -6
- data/test/dtext_test.rb +13 -0
- metadata +4 -4
- data/.rbenv-version +0 -1
data/ext/dtext/dtext.rl
CHANGED
@@ -133,11 +133,14 @@ internal_url = '/' utf8graph+;
|
|
133
133
|
basic_textile_link = '"' nonquote+ >mark_a1 '"' >mark_a2 ':' (url | internal_url) >mark_b1 %mark_b2;
|
134
134
|
bracketed_textile_link = '"' nonquote+ >mark_a1 '"' >mark_a2 ':[' (url | internal_url) >mark_b1 %mark_b2 :>> ']';
|
135
135
|
|
136
|
-
basic_wiki_link = '[[' nonpipebracket
|
137
|
-
aliased_wiki_link = '[[' nonpipebracket+ >mark_a1 %mark_a2 '|'
|
136
|
+
basic_wiki_link = '[[' (nonbracket nonpipebracket*) >mark_a1 %mark_a2 ']]';
|
137
|
+
aliased_wiki_link = '[[' nonpipebracket+ >mark_a1 %mark_a2 '|' nonpipebracket+ >mark_b1 %mark_b2 ']]';
|
138
138
|
|
139
139
|
post_link = '{{' noncurly+ >mark_a1 %mark_a2 '}}';
|
140
140
|
|
141
|
+
spoilers_open = '[spoiler'i 's'i? ']';
|
142
|
+
spoilers_close = '[/spoiler'i 's'i? ']';
|
143
|
+
|
141
144
|
post_id = 'post #'i digit+ >mark_a1 %mark_a2;
|
142
145
|
forum_post_id = 'forum #'i digit+ >mark_a1 %mark_a2;
|
143
146
|
forum_topic_id = 'topic #'i digit+ >mark_a1 %mark_a2;
|
@@ -531,14 +534,14 @@ inline := |*
|
|
531
534
|
}
|
532
535
|
};
|
533
536
|
|
534
|
-
|
537
|
+
spoilers_open => {
|
535
538
|
g_debug("inline [spoiler]");
|
536
539
|
g_debug(" push <span>");
|
537
540
|
dstack_push(sm, &INLINE_SPOILER);
|
538
541
|
append(sm, true, "<span class=\"spoiler\">");
|
539
542
|
};
|
540
543
|
|
541
|
-
|
544
|
+
spoilers_close => {
|
542
545
|
g_debug("inline [/spoiler]");
|
543
546
|
dstack_close_before_block(sm);
|
544
547
|
|
@@ -933,7 +936,7 @@ main := |*
|
|
933
936
|
append_block(sm, "<blockquote>");
|
934
937
|
};
|
935
938
|
|
936
|
-
|
939
|
+
spoilers_open space* => {
|
937
940
|
g_debug("block [spoiler]");
|
938
941
|
g_debug(" push spoiler");
|
939
942
|
g_debug(" print <div>");
|
@@ -942,7 +945,7 @@ main := |*
|
|
942
945
|
append_block(sm, "<div class=\"spoiler\">");
|
943
946
|
};
|
944
947
|
|
945
|
-
|
948
|
+
spoilers_close => {
|
946
949
|
g_debug("block [/spoiler]");
|
947
950
|
dstack_close_before_block(sm);
|
948
951
|
if (dstack_check(sm, BLOCK_SPOILER)) {
|
data/test/dtext_test.rb
CHANGED
@@ -39,6 +39,11 @@ class DTextTest < Minitest::Test
|
|
39
39
|
assert_parse("<p>a <a href=\"/wiki_pages/show_or_new?title=spoiler\">spoiler</a> c</p>", "a [[spoiler]] c")
|
40
40
|
end
|
41
41
|
|
42
|
+
def test_wiki_links_edge
|
43
|
+
assert_parse("<p>[[|_|]]</p>", "[[|_|]]")
|
44
|
+
assert_parse("<p>[[||_||]]</p>", "[[||_||]]")
|
45
|
+
end
|
46
|
+
|
42
47
|
def test_wiki_links_nested_b
|
43
48
|
assert_parse("<p><strong>[[</strong>tag<strong>]]</strong></p>", "[b][[[/b]tag[b]]][/b]")
|
44
49
|
end
|
@@ -47,10 +52,18 @@ class DTextTest < Minitest::Test
|
|
47
52
|
assert_parse("<p>this is <span class=\"spoiler\">an inline spoiler</span>.</p>", "this is [spoiler]an inline spoiler[/spoiler].")
|
48
53
|
end
|
49
54
|
|
55
|
+
def test_spoilers_inline_plural
|
56
|
+
assert_parse("<p>this is <span class=\"spoiler\">an inline spoiler</span>.</p>", "this is [SPOILERS]an inline spoiler[/SPOILERS].")
|
57
|
+
end
|
58
|
+
|
50
59
|
def test_spoilers_block
|
51
60
|
assert_parse("<p>this is</p><div class=\"spoiler\"><p>a block spoiler</p></div><p>.</p>", "this is\n\n[spoiler]\na block spoiler\n[/spoiler].")
|
52
61
|
end
|
53
62
|
|
63
|
+
def test_spoilers_block_plural
|
64
|
+
assert_parse("<p>this is</p><div class=\"spoiler\"><p>a block spoiler</p></div><p>.</p>", "this is\n\n[SPOILERS]\na block spoiler\n[/SPOILERS].")
|
65
|
+
end
|
66
|
+
|
54
67
|
def test_spoilers_with_no_closing_tag_1
|
55
68
|
assert_parse("<div class=\"spoiler\"><p>this is a spoiler with no closing tag</p><p>new text</p></div>", "[spoiler]this is a spoiler with no closing tag\n\nnew text")
|
56
69
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dtext_rb
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0
|
4
|
+
version: 1.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- r888888888
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-12-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: minitest
|
@@ -59,7 +59,7 @@ extensions:
|
|
59
59
|
- ext/dtext/extconf.rb
|
60
60
|
extra_rdoc_files: []
|
61
61
|
files:
|
62
|
-
- ".
|
62
|
+
- ".ruby-version"
|
63
63
|
- Gemfile
|
64
64
|
- Gemfile.lock
|
65
65
|
- Rakefile
|
@@ -96,7 +96,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
96
96
|
version: '0'
|
97
97
|
requirements: []
|
98
98
|
rubyforge_project:
|
99
|
-
rubygems_version: 2.
|
99
|
+
rubygems_version: 2.5.1
|
100
100
|
signing_key:
|
101
101
|
specification_version: 4
|
102
102
|
summary: Compiled DText parser
|
data/.rbenv-version
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
2.1.5
|