Sha256: 71f302d0c7d03742b1967ac90a5cd38441f629303a853356cee035a7640a7ba0

Contents?: true

Size: 700 Bytes

Versions: 30

Compression:

Stored size: 700 Bytes

Contents

module Nexmo
  module OAS
    module Renderer
      module Filters
        class BlockEscape < Banzai::Filter
          def call(input)
            # Freeze to prevent Markdown formatting
            input.gsub(/````\n(.+?)````/m) do |_s|
              lexer = Rouge::Lexer.find('text')
              formatter = Rouge::Formatters::HTML.new
              highlighted_source = formatter.format(lexer.lex($1))

              output = <<~HEREDOC
                <pre class="highlight #{lexer.tag}"><code>#{highlighted_source}</code></pre>
              HEREDOC

              "FREEZESTART#{Base64.urlsafe_encode64(output)}FREEZEEND"
            end
          end
        end
      end
    end
  end
end

Version data entries

30 entries across 30 versions & 1 rubygems

Version Path
nexmo-oas-renderer-0.7.1 lib/nexmo/oas/renderer/filters/block_escape.rb
nexmo-oas-renderer-0.7.0 lib/nexmo/oas/renderer/filters/block_escape.rb
nexmo-oas-renderer-0.6.6 lib/nexmo/oas/renderer/filters/block_escape.rb
nexmo-oas-renderer-0.6.5 lib/nexmo/oas/renderer/filters/block_escape.rb
nexmo-oas-renderer-0.6.4 lib/nexmo/oas/renderer/filters/block_escape.rb
nexmo-oas-renderer-0.6.3 lib/nexmo/oas/renderer/filters/block_escape.rb
nexmo-oas-renderer-0.6.2 lib/nexmo/oas/renderer/filters/block_escape.rb
nexmo-oas-renderer-0.6.1 lib/nexmo/oas/renderer/filters/block_escape.rb
nexmo-oas-renderer-0.5.6 lib/nexmo/oas/renderer/filters/block_escape.rb
nexmo-oas-renderer-0.5.5 lib/nexmo/oas/renderer/filters/block_escape.rb
nexmo-oas-renderer-0.5.4 lib/nexmo/oas/renderer/filters/block_escape.rb
nexmo-oas-renderer-0.5.2 lib/nexmo/oas/renderer/filters/block_escape.rb
nexmo-oas-renderer-0.5.1 lib/nexmo/oas/renderer/filters/block_escape.rb
nexmo-oas-renderer-0.5.0 lib/nexmo/oas/renderer/filters/block_escape.rb
nexmo-oas-renderer-0.4.1 lib/nexmo/oas/renderer/filters/block_escape.rb
nexmo-oas-renderer-0.4.0 lib/nexmo/oas/renderer/filters/block_escape.rb
nexmo-oas-renderer-0.3.7 lib/nexmo/oas/renderer/filters/block_escape.rb
nexmo-oas-renderer-0.3.6 lib/nexmo/oas/renderer/filters/block_escape.rb
nexmo-oas-renderer-0.3.5 lib/nexmo/oas/renderer/filters/block_escape.rb
nexmo-oas-renderer-0.3.4 lib/nexmo/oas/renderer/filters/block_escape.rb