Class: Gmi2html::NodeRenderers::Preformatted

Inherits:
Base
  • Object
show all
Defined in:
lib/gmi2html/node_renderers/preformatted.rb

Instance Method Summary collapse

Methods inherited from Base

#content, #escaped_content, for_gemtext, #initialize, #to_s

Constructor Details

This class inherits a constructor from Gmi2html::NodeRenderers::Base

Instance Method Details

#escaped_alt_textObject



14
15
16
# File 'lib/gmi2html/node_renderers/preformatted.rb', line 14

def escaped_alt_text
  CGI.escapeHTML(@node.caption)
end

#escaped_codeObject



18
19
20
21
22
# File 'lib/gmi2html/node_renderers/preformatted.rb', line 18

def escaped_code
  return escaped_content unless @node.caption

  %(<code class="language-#{escaped_alt_text}">#{escaped_content}</code>)
end


10
11
12
# File 'lib/gmi2html/node_renderers/preformatted.rb', line 10

def escaped_link
  CGI.escapeHTML(@node.target)
end

#render(_prev_node = nil, _next_node = nil) ⇒ Object



24
25
26
# File 'lib/gmi2html/node_renderers/preformatted.rb', line 24

def render(_prev_node = nil, _next_node = nil)
  %(<#{tag}>#{escaped_code}</#{tag}>\n)
end

#tagObject



6
7
8
# File 'lib/gmi2html/node_renderers/preformatted.rb', line 6

def tag
  'pre'
end