Skip to content
Browse files

Fixed encoding issue and stripped '#'

  • Loading branch information...
1 parent e6e8046 commit de59c0b35e83704f75c29c093e4ed0c4d81c41e6 @apraditya apraditya committed
Showing with 12 additions and 6 deletions.
  1. +1 −1 lib/method_doc.rb
  2. +10 −4 lib/resource_doc.rb
  3. +1 −1 templates/_resource_method.html.erb
View
2 lib/method_doc.rb
@@ -32,7 +32,7 @@ def add_output(name, value)
def append_output(value)
last_output_key = @outputs.last.keys[0]
- @outputs.last[last_output_key] += value
+ @outputs.last[last_output_key] += ERB::Util.html_escape(value)
end
def get_binding
View
14 lib/resource_doc.rb
@@ -62,11 +62,11 @@ def parse_apidoc!
elsif line =~ /::output-end::/
current_scope = :function
elsif current_scope == :response
- current_api_block.response += "#{line}"
+ current_api_block.response += strip_line(line)
elsif current_scope == :request
- current_api_block.request += "#{line}"
+ current_api_block.request += strip_line(line)
elsif current_scope == :output
- current_api_block.append_output "#{line}"
+ current_api_block.append_output strip_line(line)
elsif current_scope == :class || current_scope == :function # check if we are looking at a api block
# strip the # on the line
#line = line[1..line.length].lstrip.rstrip
@@ -83,7 +83,7 @@ def parse_apidoc!
end
else
# add line to block
- current_api_block.content << line
+ current_api_block.content << strip_line(line)
end
end
lineno += 1
@@ -116,5 +116,11 @@ def get_parsed_method(method_block)
File.open(File.join(File.dirname(__FILE__), '..', 'templates', '_resource_method.html.erb')).each { |line| template << line }
return ERB.new(template).result(method_block.get_binding)
end
+
+ private
+ # strip the '#' on the line
+ def strip_line(line)
+ line[1..line.length]
+ end
end
end
View
2 templates/_resource_method.html.erb
@@ -36,7 +36,7 @@
<% @outputs.each do |output| %>
<% output_format = output.keys.first %>
<div class="<%= (output == @outputs.first)? 'active' : '' %>" id="<%= output_format %>">
- <pre class="prettyprint" ><%= raw output[output_format] %></pre>
+ <pre class="prettyprint" ><%= output[output_format] %></pre>
</div>
<% end %>
</div>

0 comments on commit de59c0b

Please sign in to comment.
Something went wrong with that request. Please try again.