Sha256: 739ed8cbba9137fdbec68332cc063f27022f8b8f1b3cb6f8c220fd06ae835659

Contents?: true

Size: 572 Bytes

Versions: 6

Compression:

Stored size: 572 Bytes

Contents

require 'active_support/core_ext/string'

module Ecrire::Markdown
  module Nodes
    class CodeBlock < Node
      def initialize(language, title, nodes)
        @content = ERB::Util.html_escape(nodes.join("\n"))
        @title = title
        @language = language
      end

      def to_s
        str = "<pre>"
        str << "<header>#{@title}</header>"

        str << "<code"

        unless @language.nil?
          str << " class='language-#{@language}'>"
        end


        str << @content
        str << "</code></pre>"
        str
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
ecrire-0.26.3 lib/ecrire/markdown/nodes/code_block.rb
ecrire-0.26.2 lib/ecrire/markdown/nodes/code_block.rb
ecrire-0.26.1 lib/ecrire/markdown/nodes/code_block.rb
ecrire-0.26.0 lib/ecrire/markdown/nodes/code_block.rb
ecrire-0.25.2 lib/ecrire/markdown/nodes/code_block.rb
ecrire-0.25.1 lib/ecrire/markdown/nodes/code_block.rb