Sha256: 1af06dff74e72a247ec691dbef027d7b27a13ce7226222e227d43506318dd72e

Contents?: true

Size: 546 Bytes

Versions: 8

Compression:

Stored size: 546 Bytes

Contents

module Playgroundbook
  class PageProcessor
    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
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
playgroundbook-1.2.0 lib/renderer/page_processor.rb
playgroundbook-1.1.1 lib/renderer/page_processor.rb
playgroundbook-1.1.0 lib/renderer/page_processor.rb
playgroundbook-1.0.0 lib/renderer/page_processor.rb
playgroundbook-0.6.0 lib/renderer/page_processor.rb
playgroundbook-0.5.0 lib/renderer/page_processor.rb
playgroundbook-0.4.0 lib/renderer/page_processor.rb
playgroundbook-0.3.0 lib/playgroundbook_renderer/page_processor.rb