Sha256: 000e42a5c058fa46bdc93718548c3fb55a956634aae4d632373c8e77d68da367

Contents?: true

Size: 710 Bytes

Versions: 2

Compression:

Stored size: 710 Bytes

Contents

require "redcarpet"
require "rouge"

module Lookbook
  module ApplicationHelper
    def config
      Lookbook::Engine.config.lookbook
    end

    def markdown(text)
      markdown = Redcarpet::Markdown.new(Redcarpet::Render::HTML, {
        tables: true,
        fenced_code_blocks: true,
        disable_indented_code_blocks: true,
      })
      markdown.render(text).html_safe
    end

    def highlight(source, language)
      formatter = Rouge::Formatters::HTML.new(css_class: "highlight")
      lexer = Rouge::Lexer.find(language)
      formatter.format(lexer.lex(source)).html_safe
    end

    def nav_padding_style(depth)
      "padding-left: calc((#{depth - 1} * 12px) + 0.5rem);"
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
lookbook-0.4.4 app/helpers/lookbook/application_helper.rb
lookbook-0.4.3 app/helpers/lookbook/application_helper.rb