Sha256: 5413da3b2e1fa531a5562a721a91e87e5ffee6340ad392145402bbb8c026ee40
Contents?: true
Size: 1003 Bytes
Versions: 1
Compression:
Stored size: 1003 Bytes
Contents
# frozen_string_literal: true module FrontMatterParser module SyntaxParser # Parser for syntaxes which use comments ended by indentation class IndentationComment extend Factorizable # @!attribute [r] regexp # A regexp that returns two groups: front_matter and content attr_reader :regexp def initialize @regexp = build_regexp(*self.class.delimiters) end # @see SyntaxParser def call(string) string.match(regexp) end # @see Factorizable # :nocov: def self.delimiters raise NotImplementedError end private # rubocop:disable Metrics/MethodLength def build_regexp(delimiter) / \A [[:space:]]* (?<multiline_comment_indentation>^[[:blank:]]*) #{delimiter} [[:space:]]* --- (?<front_matter>.*?) --- [[:blank:]]*$[\n\r] (?<content>.*) \z /mx end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
front_matter_parser-0.1.1 | lib/front_matter_parser/syntax_parser/indentation_comment.rb |