Sha256: e3713fa08e9c3401468f0a456ebc3d23fa0c477f15c4af5f506a4cd2a8a6b1a6

Contents?: true

Size: 830 Bytes

Versions: 25

Compression:

Stored size: 830 Bytes

Contents

require 'middleman-core/renderers/redcarpet'

module GovukTechDocs
  class TechDocsHTMLRenderer < Middleman::Renderers::MiddlemanRedcarpetHTML
    include Redcarpet::Render::SmartyPants

    def initialize(options = {})
      @local_options = options.dup
      @app = @local_options[:context].app
      super
    end

    def paragraph(text)
      @app.api("<p>#{text.strip}</p>\n")
    end

    def header(text, level)
      anchor = UniqueIdentifierGenerator.instance.create(text, level)
      %(<h#{level} id="#{anchor}">#{text}</h#{level}>)
    end

    def image(link, *args)
      %(<a href="#{link}" target="_blank" rel="noopener noreferrer">#{super}</a>)
    end

    def table(header, body)
      %(<div class="table-container">
        <table>
          #{header}#{body}
        </table>
      </div>)
    end
  end
end

Version data entries

25 entries across 25 versions & 2 rubygems

Version Path
govuk_tech_docs-2.0.7 lib/govuk_tech_docs/tech_docs_html_renderer.rb
govuk_tech_docs-2.0.6 lib/govuk_tech_docs/tech_docs_html_renderer.rb
govuk_tech_docs-2.0.5 lib/govuk_tech_docs/tech_docs_html_renderer.rb
govuk_tech_docs-2.0.4 lib/govuk_tech_docs/tech_docs_html_renderer.rb
govuk_tech_docs-2.0.3 lib/govuk_tech_docs/tech_docs_html_renderer.rb
govuk_tech_docs-2.0.2 lib/govuk_tech_docs/tech_docs_html_renderer.rb
govuk_tech_docs-2.0.1 lib/govuk_tech_docs/tech_docs_html_renderer.rb
govuk_tech_docs-2.0.0.pre.test.pre.release.pre.525 lib/govuk_tech_docs/tech_docs_html_renderer.rb
govuk_tech_docs-2.0.0.pre.test.pre.release.pre.524 lib/govuk_tech_docs/tech_docs_html_renderer.rb
govuk_tech_docs-2.0.0.test.pre.release.521 lib/govuk_tech_docs/tech_docs_html_renderer.rb
govuk_tech_docs-2.0.0 lib/govuk_tech_docs/tech_docs_html_renderer.rb
govuk_tech_docs-1.9.0.pre.rc2 lib/govuk_tech_docs/tech_docs_html_renderer.rb
govuk_tech_docs-1.9.0.pre.gfe lib/govuk_tech_docs/tech_docs_html_renderer.rb
govuk_tech_docs-1.8.3 lib/govuk_tech_docs/tech_docs_html_renderer.rb
dss_tech_docs-0.1.2 lib/govuk_tech_docs/tech_docs_html_renderer.rb
dss_tech_docs-0.1.1 lib/govuk_tech_docs/tech_docs_html_renderer.rb
dss_tech_docs-0.1.0 lib/govuk_tech_docs/tech_docs_html_renderer.rb
govuk_tech_docs-1.8.2 lib/govuk_tech_docs/tech_docs_html_renderer.rb
govuk_tech_docs-1.8.1 lib/govuk_tech_docs/tech_docs_html_renderer.rb
govuk_tech_docs-1.8.0 lib/govuk_tech_docs/tech_docs_html_renderer.rb