Skip to content

Commit f249e66

Browse files
committed
Fixed url quote issues
1 parent 7b23b7f commit f249e66

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

src/sahl.rb

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -108,16 +108,23 @@ def standardise(raw)
108108
result = []
109109
lines = raw.split("\n")
110110
lines.each do |line|
111+
quotes = false
111112
if line.strip.start_with?("// ")
112113
line = "<!--#{line.strip[2..-1]} -->"
113114
elsif line.strip.start_with?("//")
114115
line = "<!-- #{line.strip[2..-1]} -->"
115-
elsif line.include?("// ")
116-
line = line.split("//", 2)
117-
line = line[0]+"<!--"+line[1]+" -->"
118-
elsif line.include?("//")
119-
line = line.split("//", 2)
120-
line = line[0]+"<!-- "+line[1]+" -->"
116+
end
117+
line.chars.each_with_index do |ch, i|
118+
quotes = !quotes if ch == "\""
119+
begin
120+
if ch+line[i+1]+line[i+2] == "// " && !quotes
121+
line = line.split("//", 2)
122+
line = line[0]+"<!--"+line[1]+" -->"
123+
elsif ch+line[i+1] == "//" && !quotes
124+
line = line.split("//", 2)
125+
line = line[0]+"<!-- "+line[1]+" -->"
126+
end
127+
rescue; break; end
121128
end
122129
if line.strip.start_with?(".") && bracketBalance(line) == 0
123130
head = line.match(/(^\s*\.\w*\s*(\[.*?\]|)\s*)/)[0].to_s

0 commit comments

Comments
 (0)