Class: MetaCommit::Extension::MarkdownSupport::Parsers::Markdown
- Inherits:
-
Contracts::Parser
- Object
- Contracts::Parser
- MetaCommit::Extension::MarkdownSupport::Parsers::Markdown
- Defined in:
- lib/meta_commit_markdown_support/parsers/markdown.rb
Class Method Summary collapse
-
.supported_file_extensions ⇒ Array<String>
Supported extensions.
- .supports_syntax?(source_code) ⇒ Boolean
Instance Method Summary collapse
Class Method Details
.supported_file_extensions ⇒ Array<String>
Returns supported extensions.
6 7 8 |
# File 'lib/meta_commit_markdown_support/parsers/markdown.rb', line 6 def self.supported_file_extensions %w(.markdown .mdown .mkdn .md .mkd .mdwn .mdtxt .mdtext .Rmd) end |
.supports_syntax?(source_code) ⇒ Boolean
12 13 14 15 16 17 18 19 |
# File 'lib/meta_commit_markdown_support/parsers/markdown.rb', line 12 def self.supports_syntax?(source_code) begin document = CommonMarker.render_doc(source_code) !document.nil? rescue Encoding::UndefinedConversionError => e return false end end |
Instance Method Details
#parse(source_code) ⇒ MetaCommit::Contracts::Ast
23 24 25 26 |
# File 'lib/meta_commit_markdown_support/parsers/markdown.rb', line 23 def parse(source_code) document = CommonMarker.render_doc(source_code) MetaCommit::Extension::MarkdownSupport::Models::Ast.new(document) end |