Module: Gitlab::MarkupHelper

Included in:
Tree
Defined in:
lib/gitlab/markup_helper.rb

Class Method Summary collapse

Class Method Details

.asciidoc?(filename) ⇒ Boolean

Public: Determines if the given filename has AsciiDoc extension.

filename - Filename string to check

Returns boolean

Returns:

  • (Boolean)

32
33
34
# File 'lib/gitlab/markup_helper.rb', line 32

def asciidoc?(filename)
  filename.downcase.end_with?(*%w(.adoc .ad .asciidoc))
end

.gitlab_markdown?(filename) ⇒ Boolean

Public: Determines if a given filename is compatible with GitLab-flavored Markdown.

filename - Filename string to check

Returns boolean

Returns:

  • (Boolean)

23
24
25
# File 'lib/gitlab/markup_helper.rb', line 23

def gitlab_markdown?(filename)
  filename.downcase.end_with?(*%w(.mdown .mkd .mkdn .md .markdown))
end

.markup?(filename) ⇒ Boolean

Public: Determines if a given filename is compatible with GitHub::Markup.

filename - Filename string to check

Returns boolean

Returns:

  • (Boolean)

10
11
12
13
14
15
# File 'lib/gitlab/markup_helper.rb', line 10

def markup?(filename)
  gitlab_markdown?(filename) ||
    asciidoc?(filename) ||
    filename.downcase.end_with?(*%w(.textile .rdoc .org .creole .wiki
                                    .mediawiki .rst))
end

.plain?(filename) ⇒ Boolean

Public: Determines if the given filename is plain text.

filename - Filename string to check

Returns boolean

Returns:

  • (Boolean)

41
42
43
44
# File 'lib/gitlab/markup_helper.rb', line 41

def plain?(filename)
  filename.downcase.end_with?('.txt') ||
    filename.downcase == 'readme'
end

.previewable?(filename) ⇒ Boolean

Returns:

  • (Boolean)

46
47
48
# File 'lib/gitlab/markup_helper.rb', line 46

def previewable?(filename)
  markup?(filename)
end