mirror of
https://github.com/foo-dogsquared/asciidoctor-foodogsquared-extensions.git
synced 2025-01-30 22:57:56 +00:00
Add repo
option for GitLab link inline macro
This commit is contained in:
parent
627ccd3f20
commit
6f3ee231f2
@ -23,6 +23,10 @@ By default. it doesn't point to anything which should be in the default branch o
|
||||
|
||||
- `path` is the filepath to be linked.
|
||||
|
||||
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.
|
||||
|
||||
|
||||
== Example usage
|
||||
|
||||
|
@ -12,7 +12,12 @@ class GitLabLinkInlineMacro < Asciidoctor::Extensions::InlineMacroProcessor
|
||||
def process(parent, target, attrs)
|
||||
doc = parent.document
|
||||
|
||||
text = attrs['caption'] || target
|
||||
default_caption = if attrs.key?('repo-option')
|
||||
target.split('/').at(1)
|
||||
else
|
||||
target
|
||||
end
|
||||
text = attrs['caption'] || default_caption
|
||||
uri = URI.parse %(https://#{attrs['domain']}/#{target})
|
||||
|
||||
uri.path += %(/-/tree/#{attrs['rev']}) if attrs['rev']
|
||||
|
Loading…
Reference in New Issue
Block a user