Sha256: df6b85d80502800870fb31fa4289fbc4895ceb7e4afeb00b4c60f47b7d8edb08

Contents?: true

Size: 433 Bytes

Versions: 4

Compression:

Stored size: 433 Bytes

Contents

# frozen_string_literal: true

module Tocer
  module Parsers
    # Represents a Markdown header.
    class Header
      PUNCTUATION = "#"

      def initialize markdown
        @markdown = markdown
      end

      def prefix
        String markdown[/#{PUNCTUATION}{1,}/o]
      end

      def content
        markdown[prefix.length + 1, markdown.length].strip
      end

      private

      attr_reader :markdown
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
tocer-11.1.0 lib/tocer/parsers/header.rb
tocer-11.0.0 lib/tocer/parsers/header.rb
tocer-10.5.0 lib/tocer/parsers/header.rb
tocer-10.4.1 lib/tocer/parsers/header.rb