diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-04-07 00:09:19 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-04-07 00:09:19 +0300 |
commit | 7915c41e4261719719e791602c8235574157164c (patch) | |
tree | 6c1fc8c4ad4e974878c879fcc2c7c8f7d56d0cee /lib | |
parent | 495c22d1245b6212b21b7379a542df73dfa77206 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'lib')
-rw-r--r-- | lib/gitlab/asciidoc.rb | 16 |
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 |