Class: Docbook::Mirror::Handlers::CodeBlock
- Inherits:
-
Object
- Object
- Docbook::Mirror::Handlers::CodeBlock
- Defined in:
- lib/docbook/mirror/handlers/code_block.rb
Class Method Summary collapse
Class Method Details
.call(element, context:, language: nil) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/docbook/mirror/handlers/code_block.rb', line 7 def self.call(element, context:, language: nil) language ||= element.language # Check for <co> callout markers in the code block co_markers = context.extract_co_markers(element) text = context.extract_text_with_callouts(element, co_markers) return nil if text.empty? attrs = { language: language }.compact attrs[:callouts] = co_markers if co_markers.any? Node::CodeBlock.new( attrs: attrs, content: [Node::Text.new(text: text)], ) end |