Class: Legion::Data::Extract::Handlers::Markdown
- Inherits:
-
Base
- Object
- Base
- Legion::Data::Extract::Handlers::Markdown
show all
- Defined in:
- lib/legion/data/extract/handlers/markdown.rb
Class Method Summary
collapse
Methods inherited from Base
available?, for_type, inherited, register, supported_types
#handle_exception
Class Method Details
.extensions ⇒ Object
9
|
# File 'lib/legion/data/extract/handlers/markdown.rb', line 9
def self.extensions = %w[.md .markdown]
|
12
13
14
15
16
17
18
19
20
|
# File 'lib/legion/data/extract/handlers/markdown.rb', line 12
def self.(source)
content = source.respond_to?(:read) ? source.read : File.read(source.to_s)
text = content.sub(/\A---\n.*?\n---\n/m, '')
{ text: text.strip, metadata: { bytes: content.bytesize, has_frontmatter: content != text } }
rescue StandardError => e
handle_exception(e, level: :warn, handled: true, operation: :extract_markdown)
{ text: nil, error: e.message }
end
|
.gem_name ⇒ Object
10
|
# File 'lib/legion/data/extract/handlers/markdown.rb', line 10
def self.gem_name = nil
|
.type ⇒ Object
8
|
# File 'lib/legion/data/extract/handlers/markdown.rb', line 8
def self.type = :markdown
|