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.3.3 lib/nexmo/oas/renderer/filters/collapsible.rb
nexmo-oas-renderer-0.3.2 lib/nexmo/oas/renderer/filters/collapsible.rb
nexmo-oas-renderer-0.3.1 lib/nexmo/oas/renderer/filters/collapsible.rb
nexmo-oas-renderer-0.3.0 lib/nexmo/oas/renderer/filters/collapsible.rb
nexmo-oas-renderer-0.2.2 lib/nexmo/oas/renderer/filters/collapsible.rb
nexmo-oas-renderer-0.2.1 lib/nexmo/oas/renderer/filters/collapsible.rb
nexmo-oas-renderer-0.2.0 lib/nexmo/oas/renderer/filters/collapsible.rb
nexmo-oas-renderer-0.1.2 lib/nexmo/oas/renderer/filters/collapsible.rb
nexmo-oas-renderer-0.1.1 lib/nexmo/oas/renderer/filters/collapsible.rb
nexmo-oas-renderer-0.1.0 lib/nexmo/oas/renderer/filters/collapsible.rb