Skip to content
This repository was archived by the owner on Apr 7, 2022. It is now read-only.

Commit 09002de

Browse files
committed
fixed row parsing with trailing spaces
1 parent 2df95c6 commit 09002de

1 file changed

Lines changed: 8 additions & 3 deletions

File tree

jWebUnit/fitplugin/rubywiki/wiki.rb

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ def formatBody(lines)
5555
body += emitCode(codeArr, code='h2', 1) if s.sub!(/^!!/, '')
5656
body += emitCode(codeArr, code='blockquote', 1) if s.sub!(/^\"\"/, '')
5757
if s =~ /^\|/
58-
s.sub!(/^\|.*\|$/) {asRow($&)}
58+
s.sub!(/^\|.*\|\s*$/) {asRow($&)}
5959
body += emitCode(codeArr, code='table', 1)
6060
end
6161
body += emitCode(codeArr, '', 0) if code == ''
@@ -102,6 +102,7 @@ def emitCode(codeArr, code, depth)
102102

103103
def asRow(s)
104104
cells = s.sub!(/^\|/, '').scan(/([^|]*)\|/).flatten
105+
comment cells
105106
cellspans = []
106107
cells.each do |e|
107108
if e.strip != ''
@@ -110,6 +111,7 @@ def asRow(s)
110111
cellspans.last[1] += 1 unless cellspans.empty?
111112
end
112113
end
114+
comment cellspans
113115
row = '<tr>'
114116
cellspans.each do |cell|
115117
content = cell[0]
@@ -121,6 +123,9 @@ def asRow(s)
121123
row += '</tr>'
122124
end
123125

126+
def comment(obj)
127+
puts "<!-- #{obj.inspect} -->"
128+
end
124129

125130
def asAnchor(title)
126131
if File.exists?("pages/#{title}")
@@ -145,7 +150,7 @@ def inPlaceUrl(origRef)
145150
print "Content-type: text/html\n\n"
146151

147152
page = ENV['QUERY_STRING'] =~ /^(#{LINK})$/ ? $1 : "WelcomeVisitors" # $& is the last match
148-
page.untaint
153+
149154
par = {}
150155
par['page' ] = page
151156
par['title'] = page.gsub(/(.)([A-Z])/, '\1 \2')
@@ -166,7 +171,7 @@ def inPlaceUrl(origRef)
166171
end
167172

168173
par['summary'] = " -- Last edited #{date}" if date
169-
par['body'] = formatBody(body.untaint)
174+
par['body'] = formatBody(body)
170175
par['action'] = <<-BLAH
171176
<form method=post action="edit.rb?#{page}">
172177
<input type=submit value=" Edit ">

0 commit comments

Comments
 (0)