Module: MarkdownRecord::ContentDsl::Attribute

Included in:
MarkdownRecord::ContentDsl
Defined in:
lib/markdown_record/rendering/content_dsl/attribute.rb

Constant Summary collapse

REGEX =
/<!--\s*attribute\s*:\s*(\w+)\s*(?::((?:html|md|int|float|string)?))?-->/
ENCODED_REGEX =
/&lt;!--\s*attribute\s*:\s*(\w+)\s*(?::((?:html|md|int|float|string)?))?--&gt;/

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.remove_dsl(text) ⇒ Object



17
18
19
# File 'lib/markdown_record/rendering/content_dsl/attribute.rb', line 17

def self.remove_dsl(text)
  text.gsub(REGEX, "").gsub(ENCODED_REGEX, "")
end

Instance Method Details

#attribute_dsl(text) ⇒ Object



7
8
9
10
11
12
13
14
15
# File 'lib/markdown_record/rendering/content_dsl/attribute.rb', line 7

def attribute_dsl(text)
  match = text.match(REGEX)

  if match
    [match[1].strip, match[2]&.strip]
  else
    nil
  end
end