Sha256: 51b436ba36aae2336ae9e4ffb643a10c9b168c45811b2baf15a49e9dbd11e12f

Contents?: true

Size: 534 Bytes

Versions: 5

Compression:

Stored size: 534 Bytes

Contents

require "redcarpet"
require "rouge"

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

    def markdown(text)
      Markdown.new(text).to_html.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} * 12px) + 0.5rem);"
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
lookbook-0.2.4 app/helpers/lookbook/application_helper.rb
lookbook-0.2.3 app/helpers/lookbook/application_helper.rb
lookbook-0.2.2 app/helpers/lookbook/application_helper.rb
lookbook-0.2.1 app/helpers/lookbook/application_helper.rb
lookbook-0.2.0 app/helpers/lookbook/application_helper.rb