Class: Playgroundbook::PageProcessor
- Inherits:
-
Object
- Object
- Playgroundbook::PageProcessor
- Defined in:
- lib/renderer/page_processor.rb
Instance Method Summary collapse
Instance Method Details
#strip_extraneous_newlines(page_contents) ⇒ Object
3 4 5 6 7 8 9 10 11 12 13 |
# File 'lib/renderer/page_processor.rb', line 3 def strip_extraneous_newlines(page_contents) # Three cases we need to look for: # - Extraneous newlines before /*: # - Extraneous newlines after */ # - Extraneous newlines either before or after //: page_contents .gsub(/\n+\/\*:/, "\n/*:") .gsub(/\*\/\n+/, "*/\n") .split(/(\/\/:.*$)\n*/).join("\n") # Important to do this before the next line, because it adds newlines before //: comments. .gsub(/\n+\/\/:/, "\n//:") end |