From 6b446abcdad6d4e129f74f9a4b45a9b1d7a88e80 Mon Sep 17 00:00:00 2001 From: "HASHIMOTO, Naoki" Date: Sun, 20 Sep 2015 18:37:30 +0900 Subject: [PATCH 1/5] add an assertion in HikiDocTestCase#test_not_wiki_name() --- test/hikidoc_test.rb | 3 +++ 1 file changed, 3 insertions(+) diff --git a/test/hikidoc_test.rb b/test/hikidoc_test.rb index f88dc95..ebefb5d 100644 --- a/test/hikidoc_test.rb +++ b/test/hikidoc_test.rb @@ -301,6 +301,9 @@ def test_not_wiki_name use_not_wiki_name: false) assert_convert("

foo WikiName bar

\n", "foo ^WikiName bar") + assert_convert("

WikiName - Disable WikiName link

\n", + "^WikiName - Disable WikiName link") + end def test_use_wiki_name_option From 0e5d2d08b2ed1b6fce448c318a887b91267e9caf Mon Sep 17 00:00:00 2001 From: "HASHIMOTO, Naoki" Date: Sun, 20 Sep 2015 19:20:15 +0900 Subject: [PATCH 2/5] bug fix: you could not properly escape a WikiName in the following case ^WikiName - Disable WikiName link was rendered as

WikiName - Disable WikiName link - Disable WikiName link

--- lib/hikidoc.rb | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/hikidoc.rb b/lib/hikidoc.rb index b3f5480..78a4c83 100644 --- a/lib/hikidoc.rb +++ b/lib/hikidoc.rb @@ -400,21 +400,22 @@ def inline_syntax_re def compile_inline(str, buf = nil) buf ||= @output.container re = inline_syntax_re - pending_str = nil + pending_str = "" while m = re.match(str) str = m.post_match link, uri, mod, wiki_name = m[1, 4] if wiki_name and wiki_name[0, 1] == "^" - pending_str = m.pre_match + wiki_name[1..-1] + str + pending_str += m.pre_match + wiki_name[1..-1] next end pre_str = "#{pending_str}#{m.pre_match}" - pending_str = nil + pending_str = "" evaluate_plugin_block(pre_str, buf) compile_inline_markup(buf, link, uri, mod, wiki_name) end + pending_str = pending_str.empty? ? nil : pending_str + str evaluate_plugin_block(pending_str || str, buf) buf end From f942f40dc74f264dc049c1a9fccdce1b2b416105 Mon Sep 17 00:00:00 2001 From: "HASHIMOTO, Naoki" Date: Sun, 20 Sep 2015 19:31:15 +0900 Subject: [PATCH 3/5] refactoring HikiDoc#compile_inline --- lib/hikidoc.rb | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/lib/hikidoc.rb b/lib/hikidoc.rb index 78a4c83..334f9c8 100644 --- a/lib/hikidoc.rb +++ b/lib/hikidoc.rb @@ -405,7 +405,7 @@ def compile_inline(str, buf = nil) str = m.post_match link, uri, mod, wiki_name = m[1, 4] - if wiki_name and wiki_name[0, 1] == "^" + if wiki_name and wiki_name.start_with? "^" pending_str += m.pre_match + wiki_name[1..-1] next end @@ -415,8 +415,7 @@ def compile_inline(str, buf = nil) evaluate_plugin_block(pre_str, buf) compile_inline_markup(buf, link, uri, mod, wiki_name) end - pending_str = pending_str.empty? ? nil : pending_str + str - evaluate_plugin_block(pending_str || str, buf) + evaluate_plugin_block(pending_str + str, buf) buf end From 24633bdeea6e5cc60bae82298a2f053cd13e2659 Mon Sep 17 00:00:00 2001 From: "HASHIMOTO, Naoki" Date: Sun, 20 Sep 2015 19:43:08 +0900 Subject: [PATCH 4/5] update TextFormattingRules.md --- TextFormattingRules.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/TextFormattingRules.md b/TextFormattingRules.md index 704c3ed..317fe9e 100644 --- a/TextFormattingRules.md +++ b/TextFormattingRules.md @@ -62,7 +62,7 @@ WikiName - WikiName From c6cce1d01b7cfe9c819eaf1db35824b0d590896c Mon Sep 17 00:00:00 2001 From: "HASHIMOTO, Naoki" Date: Sun, 20 Sep 2015 19:54:11 +0900 Subject: [PATCH 5/5] add other assertions in HikiDocTestCase#test_not_wiki_name --- test/hikidoc_test.rb | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/test/hikidoc_test.rb b/test/hikidoc_test.rb index ebefb5d..c9af77c 100644 --- a/test/hikidoc_test.rb +++ b/test/hikidoc_test.rb @@ -303,7 +303,12 @@ def test_not_wiki_name "foo ^WikiName bar") assert_convert("

WikiName - Disable WikiName link

\n", "^WikiName - Disable WikiName link") - + assert_convert("

WikiName - Disable DisabledWikiName link

\n", + "WikiName - Disable ^DisabledWikiName link") + assert_convert("

WikiName - Disable WikiName link

\n", + "WikiName - Disable WikiName link") + assert_convert("

DisabledWikiName - Disable DisabledWikiName link

\n", + "^DisabledWikiName - Disable ^DisabledWikiName link") end def test_use_wiki_name_option