summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-04-06 21:09:19 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2020-04-06 21:09:19 +0000
commit7915c41e4261719719e791602c8235574157164c (patch)
tree6c1fc8c4ad4e974878c879fcc2c7c8f7d56d0cee /lib
parent495c22d1245b6212b21b7379a542df73dfa77206 (diff)
downloadgitlab-ce-7915c41e4261719719e791602c8235574157164c.tar.gz
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'lib')
-rw-r--r--lib/gitlab/asciidoc.rb16
1 files changed, 15 insertions, 1 deletions
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