2014-08-11 06:50:56 +00:00
|
|
|
module Gitlab
|
2015-05-12 23:40:11 +00:00
|
|
|
module MarkupHelper
|
2014-08-11 06:50:56 +00:00
|
|
|
module_function
|
|
|
|
|
|
|
|
# Public: Determines if a given filename is compatible with GitHub::Markup.
|
|
|
|
#
|
|
|
|
# filename - Filename string to check
|
|
|
|
#
|
|
|
|
# Returns boolean
|
|
|
|
def markup?(filename)
|
2015-05-12 23:54:13 +00:00
|
|
|
gitlab_markdown?(filename) ||
|
|
|
|
asciidoc?(filename) ||
|
|
|
|
filename.downcase.end_with?(*%w(.textile .rdoc .org .creole .wiki
|
|
|
|
.mediawiki .rst))
|
2014-08-11 06:50:56 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
# Public: Determines if a given filename is compatible with
|
|
|
|
# GitLab-flavored Markdown.
|
|
|
|
#
|
|
|
|
# filename - Filename string to check
|
|
|
|
#
|
|
|
|
# Returns boolean
|
|
|
|
def gitlab_markdown?(filename)
|
|
|
|
filename.downcase.end_with?(*%w(.mdown .md .markdown))
|
|
|
|
end
|
2014-10-04 15:56:12 +00:00
|
|
|
|
2015-05-12 23:07:48 +00:00
|
|
|
# Public: Determines if the given filename has AsciiDoc extension.
|
|
|
|
#
|
|
|
|
# filename - Filename string to check
|
|
|
|
#
|
|
|
|
# Returns boolean
|
|
|
|
def asciidoc?(filename)
|
|
|
|
filename.downcase.end_with?(*%w(.adoc .ad .asciidoc))
|
|
|
|
end
|
|
|
|
|
2014-10-04 15:56:12 +00:00
|
|
|
def previewable?(filename)
|
2015-05-12 23:54:13 +00:00
|
|
|
markup?(filename)
|
2014-10-04 15:56:12 +00:00
|
|
|
end
|
2014-08-11 06:50:56 +00:00
|
|
|
end
|
|
|
|
end
|