Class: Qiita::Markdown::Filters::CodeBlock::Metadata
- Inherits:
-
Object
- Object
- Qiita::Markdown::Filters::CodeBlock::Metadata
- Defined in:
- lib/qiita/markdown/filters/code_block.rb
Overview
Detects language from code block metadata.
Instance Method Summary collapse
- #filename ⇒ String?
-
#initialize(text) ⇒ Metadata
constructor
A new instance of Metadata.
- #language ⇒ String?
Constructor Details
#initialize(text) ⇒ Metadata
Returns a new instance of Metadata.
45 46 47 |
# File 'lib/qiita/markdown/filters/code_block.rb', line 45 def initialize(text) @text = text end |
Instance Method Details
#filename ⇒ String?
50 51 52 53 54 55 56 57 58 59 |
# File 'lib/qiita/markdown/filters/code_block.rb', line 50 def filename case when empty? nil when has_only_filename? sections[0] else sections[1] end end |
#language ⇒ String?
67 68 69 70 71 72 73 74 75 76 |
# File 'lib/qiita/markdown/filters/code_block.rb', line 67 def language case when empty? nil when !has_only_filename? sections[0] when linguist_language linguist_language.default_alias_name end end |