Class: HtmlToProsemirror::Nodes::CodeBlock
  
  
  
  
  
    - Inherits:
- 
      Node
      
        
          - Object
- Node
- HtmlToProsemirror::Nodes::CodeBlock
 show all
    - Defined in:
- lib/html_to_prosemirror/nodes/code_block.rb
 
  Instance Attribute Summary
  
  Attributes inherited from Node
  #type, #wrapper
  
    
      Instance Method Summary
      collapse
    
    
  
  
  
  
  
  
  
  
  
  Methods inherited from Node
  #initialize
  
    Instance Method Details
    
      
  
  
    #data  ⇒ Object 
  
  
  
  
    | 
9
10
11
12
13
14 | # File 'lib/html_to_prosemirror/nodes/code_block.rb', line 9
def data
  block = { type: "code_block" }
  lang = get_language
  block.merge({attrs: { language: lang } }) if lang
  block
end | 
 
    
      
  
  
    #get_language  ⇒ Object 
  
  
  
  
    | 
16
17
18
19
20
21
22 | # File 'lib/html_to_prosemirror/nodes/code_block.rb', line 16
def get_language
  lang = @node.attribute('class')
  if (lang && lang.value)
    return lang.value.gsub("/^language-/", "")
  end
  return nil
end | 
 
    
      
  
  
    #matching  ⇒ Object 
  
  
  
  
    | 
5
6
7 | # File 'lib/html_to_prosemirror/nodes/code_block.rb', line 5
def matching
  @node.name === 'code' && @node.parent.name === 'pre'
end |