Skip to content
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

fix special characters escaping #1

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
6 changes: 3 additions & 3 deletions lib/html2confluence.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,9 @@ def normalise_space(s)

# Escape any special characters.
def escape_special_characters(s)
return s
# Escaping is disabled now since it caused more problems that not having
# it. The insertion of unecessary escaping was annoying for JIRA users.
s.to_s.gsub(/[*#+\-_{}|]/) do |s|
s.to_s.gsub(/[*#+\-_{}|!]/) do |s|
"\\#{s}"
end
end
Expand Down Expand Up @@ -125,7 +124,7 @@ def handle_data(data)
write(data)
else
data ||= ""
data = normalise_space(escape_special_characters(data))
data = normalise_space(data)
if @last_write[-1] =~ /\s/
data = data.lstrip # Collapse whitespace if the previous character was whitespace.
end
Expand Down Expand Up @@ -427,6 +426,7 @@ def tag_end(name)
end

def text(string)
string = escape_special_characters(string) unless @preserveWhitespace
handle_data(string)
end
end