Module: Gitlab::MarkupHelper

Extended by:
MarkupHelper
Included in:
MarkupHelper
Defined in:
lib/gitlab/markup_helper.rb

Constant Summary collapse

MARKDOWN_EXTENSIONS =
%w[mdown mkd mkdn md markdown rmd].freeze
ASCIIDOC_EXTENSIONS =
%w[adoc ad asciidoc].freeze
OTHER_EXTENSIONS =
%w[textile rdoc org creole wiki mediawiki rst].freeze
EXTENSIONS =
MARKDOWN_EXTENSIONS + ASCIIDOC_EXTENSIONS + OTHER_EXTENSIONS
PLAIN_FILENAMES =
%w[readme index].freeze

Instance Method Summary collapse

Instance Method Details

#asciidoc?(filename) ⇒ Boolean

Public: Determines if the given filename has AsciiDoc extension.

filename - Filename string to check

Returns boolean

Returns:

  • (Boolean)


37
38
39
# File 'lib/gitlab/markup_helper.rb', line 37

def asciidoc?(filename)
  ASCIIDOC_EXTENSIONS.include?(extension(filename))
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)


28
29
30
# File 'lib/gitlab/markup_helper.rb', line 28

def gitlab_markdown?(filename)
  MARKDOWN_EXTENSIONS.include?(extension(filename))
end

#markup?(filename) ⇒ Boolean

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

filename - Filename string to check

Returns boolean

Returns:

  • (Boolean)


18
19
20
# File 'lib/gitlab/markup_helper.rb', line 18

def markup?(filename)
  EXTENSIONS.include?(extension(filename))
end

#plain?(filename) ⇒ Boolean

Public: Determines if the given filename is plain text.

filename - Filename string to check

Returns boolean

Returns:

  • (Boolean)


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

def plain?(filename)
  extension(filename) == 'txt' || plain_filename?(filename)
end

#previewable?(filename) ⇒ Boolean

Returns:

  • (Boolean)


50
51
52
# File 'lib/gitlab/markup_helper.rb', line 50

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