From 7915c41e4261719719e791602c8235574157164c Mon Sep 17 00:00:00 2001 From: GitLab Bot Date: Mon, 6 Apr 2020 21:09:19 +0000 Subject: Add latest changes from gitlab-org/gitlab@master --- lib/gitlab/asciidoc.rb | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'lib/gitlab/asciidoc.rb') diff --git a/lib/gitlab/asciidoc.rb b/lib/gitlab/asciidoc.rb index 8d072422e17..2fac76d03e8 100644 --- a/lib/gitlab/asciidoc.rb +++ b/lib/gitlab/asciidoc.rb @@ -25,6 +25,19 @@ module Gitlab 'max-include-depth' => MAX_INCLUDE_DEPTH }.freeze + def self.path_attrs(path) + return {} unless path + + { + # Set an empty docname if the path is a directory + 'docname' => if path[-1] == ::File::SEPARATOR + '' + else + ::File.basename(path, '.*') + end + } + end + # Public: Converts the provided Asciidoc markup into HTML. # # input - the source text in Asciidoc format @@ -35,9 +48,10 @@ module Gitlab include_processor ::Gitlab::Asciidoc::IncludeProcessor.new(context) end + extra_attrs = path_attrs(context[:requested_path]) asciidoc_opts = { safe: :secure, backend: :gitlab_html5, - attributes: DEFAULT_ADOC_ATTRS, + attributes: DEFAULT_ADOC_ATTRS.merge(extra_attrs), extensions: extensions } context[:pipeline] = :ascii_doc -- cgit v1.2.1