Skip to content
This repository has been archived by the owner on Mar 3, 2020. It is now read-only.

Commit

Permalink
strip leading whitespace in generated code blocks
Browse files Browse the repository at this point in the history
  • Loading branch information
mislav committed Dec 3, 2008
1 parent 258ff1d commit 09f5712
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/hanna/template_files/page.haml
Expand Up @@ -45,6 +45,6 @@

#text
- if values["description"]
#description~ values["description"]
#description~ sanitize_code_blocks values["description"]

= yield
5 changes: 5 additions & 0 deletions lib/hanna/template_helpers.rb
Expand Up @@ -104,5 +104,10 @@ def render_class_tree(tree, parent = nil)
out
end
end

# primarily for removing leading whitespace in <pre> tags
def sanitize_code_blocks(text)
text.gsub(/<pre>(.+?)<\/pre>/m) { "<pre>#{$1.sub(/^\s*\n/, '')}</pre>" }
end
end
end

0 comments on commit 09f5712

Please sign in to comment.