Sha256: 4d099e0bc57a02c73113856757ab0f0ad33d496c2ef0cfd68a3475c7b437e2ae

Contents?: true

Size: 402 Bytes

Versions: 46

Compression:

Stored size: 402 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])

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

      private

      attr_reader :markdown
    end
  end
end

Version data entries

46 entries across 46 versions & 1 rubygems

Version Path
tocer-15.2.0 lib/tocer/parsers/header.rb
tocer-15.1.2 lib/tocer/parsers/header.rb
tocer-15.1.1 lib/tocer/parsers/header.rb
tocer-15.1.0 lib/tocer/parsers/header.rb
tocer-15.0.0 lib/tocer/parsers/header.rb
tocer-14.5.0 lib/tocer/parsers/header.rb
tocer-14.4.0 lib/tocer/parsers/header.rb
tocer-14.3.0 lib/tocer/parsers/header.rb
tocer-14.2.0 lib/tocer/parsers/header.rb
tocer-14.1.0 lib/tocer/parsers/header.rb
tocer-14.0.1 lib/tocer/parsers/header.rb
tocer-14.0.0 lib/tocer/parsers/header.rb
tocer-13.3.1 lib/tocer/parsers/header.rb
tocer-13.3.0 lib/tocer/parsers/header.rb
tocer-13.2.0 lib/tocer/parsers/header.rb
tocer-13.1.0 lib/tocer/parsers/header.rb
tocer-13.0.2 lib/tocer/parsers/header.rb
tocer-13.0.1 lib/tocer/parsers/header.rb
tocer-13.0.0 lib/tocer/parsers/header.rb
tocer-12.2.0 lib/tocer/parsers/header.rb