Module: Markdpwn

Defined in:
lib/markdpwn.rb,
lib/markdpwn/code.rb,
lib/markdpwn/docs.rb,
lib/markdpwn/dpwn.rb,
lib/markdpwn/glue.rb,
lib/markdpwn/red_carpet_renderer.rb

Overview

HTML-formats text documents such as Markdown, textile, and source code.

Defined Under Namespace

Modules: Code, Docs, Dpwn Classes: RedCarpetRenderer

Class Method Summary collapse

Class Method Details

.markdpwn(text, options = {}) ⇒ Object

Marks up a markdpwn text document.

The caller is responsible for ensuring that the text uses markdpwn, otherwise extreme ugliness might ensue. Use Markdpwn.markup when unsure.



28
29
30
# File 'lib/markdpwn/glue.rb', line 28

def self.markdpwn(text, options = {})
  Markdpwn::Dpwn.render text, options
end

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

Marks up a text document.

Parameters:

  • text (String)

    the text to be formatted

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

    text file 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

  • :language (String)

    the name of the text’s language; GFM code blocks can include a language name

Returns:

  • (String)

    a HTML fragment containing the formatted text



14
15
16
17
18
19
20
21
22
# File 'lib/markdpwn/glue.rb', line 14

def self.markup(text, options = {})
  if Markdpwn::Dpwn.accepts? options
    Markdpwn::Dpwn.render text, options
  elsif html = Markdpwn::Docs.gh_markup(text, options)
    html
  else
    Markdpwn::Code.render text, options
  end
end