Class: Github::Client::Markdown

Inherits:
API
  • Object
show all
Defined in:
lib/github_api/client/markdown.rb

Constant Summary

Constants included from MimeType

MimeType::MEDIA_LOOKUP

Constants included from Github::Constants

Github::Constants::ACCEPT, Github::Constants::ACCEPTED_OAUTH_SCOPES, Github::Constants::ACCEPT_CHARSET, Github::Constants::CACHE_CONTROL, Github::Constants::CONTENT_LENGTH, Github::Constants::CONTENT_TYPE, Github::Constants::DATE, Github::Constants::ETAG, Github::Constants::HEADER_LAST, Github::Constants::HEADER_LINK, Github::Constants::HEADER_NEXT, Github::Constants::LOCATION, Github::Constants::META_FIRST, Github::Constants::META_LAST, Github::Constants::META_NEXT, Github::Constants::META_PREV, Github::Constants::META_REL, Github::Constants::OAUTH_SCOPES, Github::Constants::PARAM_PAGE, Github::Constants::PARAM_PER_PAGE, Github::Constants::PARAM_START_PAGE, Github::Constants::RATELIMIT_LIMIT, Github::Constants::RATELIMIT_REMAINING, Github::Constants::RATELIMIT_RESET, Github::Constants::SERVER, Github::Constants::USER_AGENT

Instance Attribute Summary

Attributes inherited from API

#current_options

Instance Method Summary collapse

Methods inherited from API

after_callbacks, after_request, #api_methods_in, #arguments, before_callbacks, before_request, clear_request_methods!, #execute, extend_with_actions, extra_methods, #extract_basic_auth, extract_class_name, #filter_callbacks, inherited, #initialize, internal_methods, method_added, #method_missing, #module_methods_in, namespace, request_methods, root!, #run_callbacks, #set, #yield_or_eval

Methods included from Github::ClassMethods

#configuration, #configure, #require_all

Methods included from RateLimit

#ratelimit, #ratelimit_remaining, #ratelimit_reset

Methods included from Request::Verbs

#delete_request, #get_request, #head_request, #options_request, #patch_request, #post_request, #put_request

Methods included from MimeType

#lookup_media, #parse

Methods included from Authorization

#auth_code, #authenticated?, #authentication, #authorize_url, #basic_authed?, #client, #get_token

Constructor Details

This class inherits a constructor from Github::API

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Github::API

Instance Method Details

#render(*args) ⇒ Object

Render an arbritrary Markdown document

Parameters

<tt>:text</tt> - Required string - The Markdown text to render
<tt>:mode<tt> - Optional string - The rendering mode
  * <tt>markdown</tt> to render a document as plain Markdown, just
                      like README files are rendered.
  * <tt>gfm</tt> to render a document as user-content, e.g. like user
    comments or issues are rendered. In GFM mode, hard line breaks are
    always taken into account, and issue and user mentions are
    linked accordingly.
<tt>:context<tt> - Optional string - The repository context, only taken
                   into account when rendering as <tt>gfm</tt>

Examples

github = Github.new
github.markdown.render
  "text": "Hello world github/linguist#1 **cool**, and #1!",
  "mode": "gfm",
  "context": "github/gollum"

27
28
29
30
31
32
33
34
35
# File 'lib/github_api/client/markdown.rb', line 27

def render(*args)
  arguments(args) do
    assert_required ['text']
  end
  params = arguments.params
  params['raw'] = true

  post_request("markdown", arguments.params)
end

#render_raw(*args) ⇒ Object

Render a Markdown document in raw mode

Input

The raw API it not JSON-based. It takes a Markdown document as plaintext
<tt>text/plain</tt> or <tt>text/x-markdown</tt> and renders it as plain
Markdown without a repository context (just like a README.md file is
rendered – this is the simplest way to preview a readme online)

Examples

github = Github.new
github.markdown.render_raw "Hello github/linguist#1 **cool**, and #1!",
  "accept": "text/plain",

50
51
52
53
54
55
56
57
# File 'lib/github_api/client/markdown.rb', line 50

def render_raw(*args)
  params = arguments(args).params
  mime_type, params['data'] = params['mime'], args.shift
  params['raw'] = true
  params['accept'] = params.fetch('accept') { 'text/plain' }

  post_request("markdown/raw", params)
end