mirror of
https://github.com/foo-dogsquared/asciidoctor-foodogsquared-extensions.git
synced 2025-02-07 06:19:01 +00:00
Add GitHub inline macro with issue
attribute
This commit is contained in:
parent
1b9ecedc60
commit
68020109f0
@ -23,6 +23,10 @@ There are optional attributes for this macro.
|
|||||||
|
|
||||||
- `path` is the filepath to be linked within the repo.
|
- `path` is the filepath to be linked within the repo.
|
||||||
|
|
||||||
|
- `issue` accepts the issue number to be linked in the GitHub repo.
|
||||||
|
Take note `issue` is exclusive to other attributes and has more precedence.
|
||||||
|
For example, if `issue` and `rev` are both present, the link for issue will be the result.
|
||||||
|
|
||||||
|
|
||||||
== Example usage
|
== Example usage
|
||||||
|
|
||||||
@ -31,3 +35,7 @@ There are optional attributes for this macro.
|
|||||||
- `github:NixOS/nixpkgs[nixpkgs nixos-unstable branch, rev=nixos-unstable]` should link to the link:https://github.com/NixOS/nixpkgs/tree/nixos-unstable[NixOS unstable branch of nixpkgs] with a custom link text.
|
- `github:NixOS/nixpkgs[nixpkgs nixos-unstable branch, rev=nixos-unstable]` should link to the link:https://github.com/NixOS/nixpkgs/tree/nixos-unstable[NixOS unstable branch of nixpkgs] with a custom link text.
|
||||||
|
|
||||||
- `github:errata-ai/vale[Vale v2.3.0 README, path=README.md, rev=v2.3.0]` should link to the link:https://github.com/errata-ai/vale/blob/v2.3.0/README.md[README of Vale v2.3.0].
|
- `github:errata-ai/vale[Vale v2.3.0 README, path=README.md, rev=v2.3.0]` should link to the link:https://github.com/errata-ai/vale/blob/v2.3.0/README.md[README of Vale v2.3.0].
|
||||||
|
|
||||||
|
- `github:neovim/neovim[Neovim cannot open large files properly, issue=614]` should link to https://github.com/neovim/neovim/issues/614[an issue of Neovim].
|
||||||
|
|
||||||
|
- `github:neovim/neovim[Neovim cannot open large files properly, issue=614, rev=master]` should still link to https://github.com/neovim/neovim/issues/614[an issue of Neovim] since `issue` has more precedence over `rev`.
|
||||||
|
@ -14,8 +14,12 @@ class GitHubLinkInlineMacro < Asciidoctor::Extensions::InlineMacroProcessor
|
|||||||
text = attrs['caption'] || target
|
text = attrs['caption'] || target
|
||||||
uri = URI.parse %(https://github.com/#{target})
|
uri = URI.parse %(https://github.com/#{target})
|
||||||
|
|
||||||
uri.path += %(/tree/#{attrs['rev']}) if attrs['rev']
|
if attrs.key? 'issue'
|
||||||
uri.path += %(/#{attrs['path']}) if attrs['path']
|
uri.path += %(/issues/#{attrs['issue']})
|
||||||
|
else
|
||||||
|
uri.path += %(/tree/#{attrs['rev']}) if attrs.key? 'rev'
|
||||||
|
uri.path += %(/#{attrs['path']}) if attrs.key? 'path'
|
||||||
|
end
|
||||||
|
|
||||||
target = uri.to_s
|
target = uri.to_s
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user