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