Module: Markdpwn::Docs

Defined in:
lib/markdpwn/docs.rb

Overview

Document (e.g. textile, markdown) formatting.

Class Method Summary collapse

Class Method Details

.gh_markup(text, options = {}) ⇒ String

The raw GitHub::Markup output for parsing a text document.

Parameters:

  • options (Hash) (defaults to: {})

    code properties that help choose the formatter

Options Hash (options):

  • :mime_type (String)

    the MIME type of the code file; e-mail attachments and git blobs have MIME types

  • :file_name (String)

    the name of the file containing the piece of code; meaningful for files in version control repositories, e-mail attachments, and code fetched from links

Returns:

  • (String)

    the GitHub::Markup output, or nil if the file cannot be rendered by GitHub::Markup



23
24
25
26
27
28
29
30
31
32
# File 'lib/markdpwn/docs.rb', line 23

def self.gh_markup(text, options = {})
  # NOTE: the MIME type is specified in the API so clients won't need to
  #       change if/when MIME-based detection is added
  file_name = options[:file_name]
  if file_name && GitHub::Markup.can_render?(file_name, text)
    GitHub::Markup.render file_name, text
  else
    nil
  end
end