class Nexmo::Markdown::VoltaRender

Public Class Methods

new(options) click to toggle source
Calls superclass method
# File lib/nexmo_markdown_renderer/filters/markdown_filter.rb, line 33
def initialize(options)
  @options = options
  super(options)
end

Public Instance Methods

block_code(code, language) click to toggle source
# File lib/nexmo_markdown_renderer/filters/markdown_filter.rb, line 83
def block_code(code, language)
  lexer = ::Rouge::Lexer.find_fancy(language, code) || ::Rouge::Lexers::PlainText

  # XXX HACK: Redcarpet strips hard tabs out of code blocks,
  # so we assume you're not using leading spaces that aren't tabs,
  # and just replace them here.
  if lexer.tag == 'make'
    code.gsub! /^    /, "\t"
  end

  formatter ||= Rouge::Formatters::HTML.new
  highlighted_source = formatter.format(lexer.lex(code))

  code_snippet_body(lexer, highlighted_source, @options)
end
block_quote(quote) click to toggle source
# File lib/nexmo_markdown_renderer/filters/markdown_filter.rb, line 53
def block_quote(quote)
  '<div class="Vlt-callout Vlt-callout--tip">' \
    '<i></i>' \
    '<div class="Vlt-callout__content">' \
      "#{quote}" \
    '</div>' \
  '</div>'
end
image(link, _title, _alt_text) click to toggle source
# File lib/nexmo_markdown_renderer/filters/markdown_filter.rb, line 62
      def image(link, _title, _alt_text)
        <<~IMAGE
          <figure>
            <img src="#{link}" alt="#{_alt_text}">
            <figcaption class="Vlt-center"><em>#{_alt_text}</em></figcaption>
          </figure>
        IMAGE
      end
list(contents, list_type) click to toggle source
# File lib/nexmo_markdown_renderer/filters/markdown_filter.rb, line 71
def list(contents, list_type)
  if "#{list_type}" == 'unordered'
    '<ul class="Vlt-list Vlt-list--simple">' \
    "#{contents}" \
    '</ul>'
  else
    '<ol class="Vlt-list Vlt-list--simple">' \
    "#{contents}" \
    '</ol>' \
  end
end
paragraph(text) click to toggle source
# File lib/nexmo_markdown_renderer/filters/markdown_filter.rb, line 38
def paragraph(text)
  return text if @options[:skip_paragraph_surround]

  "<p>#{text}</p>"
end
table(header, body) click to toggle source
# File lib/nexmo_markdown_renderer/filters/markdown_filter.rb, line 44
def table(header, body)
  '<div class="Vlt-table Vlt-table--bordered">' \
  '<table>' \
    "<thead>#{header}</thead>" \
    "<tbody>#{body}</tbody>" \
  '</table>' \
  '</div>'
end