Skip to content

Bug fix for syntax to escape Wikinames #10

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion TextFormattingRules.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ WikiName - WikiName
<ul>
<li><ul>
<li><a href="WikiName">WikiName</a> - <a href="WikiName">WikiName</a></li>
<li>WikiName - Disable WikiName link - Disable <a href="WikiName">WikiName</a> link</li>
<li>WikiName - Disable <a href="WikiName">WikiName</a> link</li>
</ul></li>
</ul>

Expand Down
10 changes: 5 additions & 5 deletions lib/hikidoc.rb
Original file line number Diff line number Diff line change
Expand Up @@ -400,22 +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
if wiki_name and wiki_name.start_with? "^"
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
evaluate_plugin_block(pending_str || str, buf)
evaluate_plugin_block(pending_str + str, buf)
buf
end

Expand Down
8 changes: 8 additions & 0 deletions test/hikidoc_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,14 @@ def test_not_wiki_name
use_not_wiki_name: false)
assert_convert("<p>foo WikiName bar</p>\n",
"foo ^WikiName bar")
assert_convert("<p>WikiName - Disable <a href=\"WikiName\">WikiName</a> link</p>\n",
"^WikiName - Disable WikiName link")
assert_convert("<p><a href=\"WikiName\">WikiName</a> - Disable DisabledWikiName link</p>\n",
"WikiName - Disable ^DisabledWikiName link")
assert_convert("<p><a href=\"WikiName\">WikiName</a> - Disable <a href=\"WikiName\">WikiName</a> link</p>\n",
"WikiName - Disable WikiName link")
assert_convert("<p>DisabledWikiName - Disable DisabledWikiName link</p>\n",
"^DisabledWikiName - Disable ^DisabledWikiName link")
end

def test_use_wiki_name_option
Expand Down