Module: GLFMMarkdown

Defined in:
lib/gitlab-glfm-markdown.rb,
lib/gitlab_glfm_markdown/version.rb

Constant Summary collapse

GLFM_DEFAULT_OPTIONS =
{
  autolink: true,
  cjk_friendly_emphasis: true,
  escaped_char_spans: false,
  footnotes: true,
  full_info_string: true,
  gfm_quirks: true,
  github_pre_lang: false,
  hardbreaks: false,
  inapplicable_tasks: false,
  math_code: false,
  math_dollars: false,
  multiline_block_quotes: true,
  relaxed_autolinks: false,
  sourcepos: true,
  smart: false,
  strikethrough: true,
  table: true,
  tasklist: true,
  tasklist_classes: true,
  unsafe: true
}.freeze
VERSION =
'0.0.43'

Class Method Summary collapse

Class Method Details

.escape_commonmark_inline(text) ⇒ Object

Raises:

  • (TypeError)


43
44
45
46
47
48
# File 'lib/gitlab-glfm-markdown.rb', line 43

def escape_commonmark_inline(text)
  raise TypeError, 'text must be a String' unless text.is_a?(String)
  raise TypeError, 'text must be UTF-8 encoded' unless text.encoding == Encoding::UTF_8

  escape_commonmark_inline_rs(text)
end

Raises:

  • (TypeError)


50
51
52
53
54
55
# File 'lib/gitlab-glfm-markdown.rb', line 50

def escape_commonmark_link_destination(url)
  raise TypeError, 'url must be a String' unless url.is_a?(String)
  raise TypeError, 'url must be UTF-8 encoded' unless url.encoding == Encoding::UTF_8

  escape_commonmark_link_destination_rs(url)
end

.to_html(markdown, options: {}) ⇒ Object

Raises:

  • (TypeError)


33
34
35
36
37
38
39
40
41
# File 'lib/gitlab-glfm-markdown.rb', line 33

def to_html(markdown, options: {})
  raise TypeError, 'markdown must be a String' unless markdown.is_a?(String)
  raise TypeError, 'markdown must be UTF-8 encoded' unless markdown.encoding == Encoding::UTF_8
  raise TypeError, 'options must be a Hash' unless options.is_a?(Hash)

  default_options = options[:glfm] ? GLFM_DEFAULT_OPTIONS : {}

  render_to_html_rs(markdown, default_options.merge(options))
end