mirror of
https://github.com/foo-dogsquared/asciidoctor-foodogsquared-extensions.git
synced 2025-01-30 22:57:56 +00:00
Add 'issue' attribute for GitLab link inline macro
This commit is contained in:
parent
42454be244
commit
cf8a942011
@ -23,6 +23,9 @@ By default. it doesn't point to anything which should be in the default branch o
|
||||
|
||||
- `path` is the filepath to be linked.
|
||||
|
||||
- `issue` is the issue to be linked from the repo.
|
||||
Take note issue has higher precedence so once `domain` and `issue` are both set, it will still link to an issue.
|
||||
|
||||
There are settings that is enabled with the link:https://docs.asciidoctor.org/asciidoc/latest/attributes/options/[options attribute].
|
||||
|
||||
- `repo` sets the default caption to be the repo part.
|
||||
|
@ -20,8 +20,14 @@ class GitLabLinkInlineMacro < Asciidoctor::Extensions::InlineMacroProcessor
|
||||
text = attrs['caption'] || default_caption
|
||||
uri = URI.parse %(https://#{attrs['domain']}/#{target})
|
||||
|
||||
uri.path += %(/-/tree/#{attrs['rev']}) if attrs['rev']
|
||||
uri.path += %(/#{attrs['path']}) if attrs['path']
|
||||
if attrs.key? 'issue'
|
||||
uri.path += %(/-/issues/#{attrs['issue']})
|
||||
text << "##{attrs['issue']}" if text == target
|
||||
else
|
||||
uri.path += %(/-/tree/#{attrs['rev']}) if attrs.key? 'rev'
|
||||
uri.path += %(/#{attrs['path']}) if attrs.key? 'path'
|
||||
text << "@#{attrs['rev']}" if attrs.key?('rev') && text == target
|
||||
end
|
||||
|
||||
target = uri.to_s
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user