Sha256: f3bdb05bc15d80020962fa8d0266c0ae6e1f8c5759ab168092b9da944b2f0a8a

Contents?: true

Size: 855 Bytes

Versions: 30

Compression:

Stored size: 855 Bytes

Contents

module Nexmo
  module OAS
    module Renderer
      module Filters
        class Collapsible < Banzai::Filter
          def call(input)
            input.gsub(/^\|\s(\#{1,6})(\s)?(.+?)\n^\|\n(.+?)\n\n/m) do |_s|
              heading = $3
              body = $4.gsub(/^\|\n/, "\n")
              body = body.gsub(/^\|\s/, '')
              parsed_body = MarkdownPipeline.new.call(body)

              <<~HEREDOC
                <div class="Vlt-accordion Vlt-box Vlt-box--lesspadding Nxd-accordion-emphasis">
                  <h5 class="Vlt-accordion__trigger"  tabindex="0">#{heading}</h5>
                  <div class="Vlt-accordion__content Vlt-accordion__content--noborder">
                    #{parsed_body}
                  </div>
                </div>
              HEREDOC
            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/collapsible.rb
nexmo-oas-renderer-0.7.0 lib/nexmo/oas/renderer/filters/collapsible.rb
nexmo-oas-renderer-0.6.6 lib/nexmo/oas/renderer/filters/collapsible.rb
nexmo-oas-renderer-0.6.5 lib/nexmo/oas/renderer/filters/collapsible.rb
nexmo-oas-renderer-0.6.4 lib/nexmo/oas/renderer/filters/collapsible.rb
nexmo-oas-renderer-0.6.3 lib/nexmo/oas/renderer/filters/collapsible.rb
nexmo-oas-renderer-0.6.2 lib/nexmo/oas/renderer/filters/collapsible.rb
nexmo-oas-renderer-0.6.1 lib/nexmo/oas/renderer/filters/collapsible.rb
nexmo-oas-renderer-0.5.6 lib/nexmo/oas/renderer/filters/collapsible.rb
nexmo-oas-renderer-0.5.5 lib/nexmo/oas/renderer/filters/collapsible.rb
nexmo-oas-renderer-0.5.4 lib/nexmo/oas/renderer/filters/collapsible.rb
nexmo-oas-renderer-0.5.2 lib/nexmo/oas/renderer/filters/collapsible.rb
nexmo-oas-renderer-0.5.1 lib/nexmo/oas/renderer/filters/collapsible.rb
nexmo-oas-renderer-0.5.0 lib/nexmo/oas/renderer/filters/collapsible.rb
nexmo-oas-renderer-0.4.1 lib/nexmo/oas/renderer/filters/collapsible.rb
nexmo-oas-renderer-0.4.0 lib/nexmo/oas/renderer/filters/collapsible.rb
nexmo-oas-renderer-0.3.7 lib/nexmo/oas/renderer/filters/collapsible.rb
nexmo-oas-renderer-0.3.6 lib/nexmo/oas/renderer/filters/collapsible.rb
nexmo-oas-renderer-0.3.5 lib/nexmo/oas/renderer/filters/collapsible.rb
nexmo-oas-renderer-0.3.4 lib/nexmo/oas/renderer/filters/collapsible.rb