Class: Qiita::Markdown::Filters::SyntaxHighlight::Highlighter
- Inherits:
-
Object
- Object
- Qiita::Markdown::Filters::SyntaxHighlight::Highlighter
- Defined in:
- lib/qiita/markdown/filters/syntax_highlight.rb
Class Method Summary collapse
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(default_language: nil, node: nil) ⇒ Highlighter
constructor
A new instance of Highlighter.
Constructor Details
#initialize(default_language: nil, node: nil) ⇒ Highlighter
Returns a new instance of Highlighter.
28 29 30 31 |
# File 'lib/qiita/markdown/filters/syntax_highlight.rb', line 28 def initialize(default_language: nil, node: nil) @default_language = default_language @node = node end |
Class Method Details
.call(*args) ⇒ Object
24 25 26 |
# File 'lib/qiita/markdown/filters/syntax_highlight.rb', line 24 def self.call(*args) new(*args).call end |
Instance Method Details
#call ⇒ Object
33 34 35 36 37 38 39 |
# File 'lib/qiita/markdown/filters/syntax_highlight.rb', line 33 def call outer = Nokogiri::HTML.fragment(%Q[<div class="code-frame" data-lang="#{language}">]) frame = outer.at('div') frame.add_child(filename_node) if filename frame.add_child(highlighted_node) @node.replace(outer) end |