mirror of
https://github.com/foo-dogsquared/website.git
synced 2025-01-31 07:58:02 +00:00
Update GitHub link default captions
This commit is contained in:
parent
ebf2aca634
commit
4a9f1294f7
@ -20,22 +20,25 @@ If caption is missing, the link text will be the namespace (i.e., `$OWNER/$REPO`
|
|||||||
There are optional attributes for this macro.
|
There are optional attributes for this macro.
|
||||||
|
|
||||||
- `rev` is the commit/branch/tag of the repo to be linked.
|
- `rev` is the commit/branch/tag of the repo to be linked.
|
||||||
|
When given no caption, it will update the default caption with `$OWNER/$REPO@$REV`.
|
||||||
|
|
||||||
- `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.
|
- `issue` accepts the issue number to be linked in the GitHub repo.
|
||||||
Take note `issue` is exclusive to other attributes and has more precedence.
|
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.
|
For example, if `issue` and `rev` are both present, the link for issue will be the result.
|
||||||
|
+
|
||||||
|
When given no caption, it will update the default caption with `$OWNER/$REPO#$ISSUE`.
|
||||||
|
|
||||||
|
|
||||||
== Example usage
|
== Example usage
|
||||||
|
|
||||||
- `github:foo-dogsquared/website` will link to link:https://github.com/foo-dogsquared/website[my website repository].
|
- `github:foo-dogsquared/website[]` will link to link:https://github.com/foo-dogsquared/website[my website repository] with the link text `foo-dogsquared/website`.
|
||||||
|
|
||||||
- `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 caption of `nixpkgs nixos-unstable branch`.
|
||||||
|
|
||||||
- `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]` should link to https://github.com/neovim/neovim/issues/614[an issue of Neovim] with `Neovim cannot open large files properly` as the link text.
|
||||||
|
|
||||||
- `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`.
|
- `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`.
|
||||||
|
@ -16,9 +16,11 @@ class GitHubLinkInlineMacro < Asciidoctor::Extensions::InlineMacroProcessor
|
|||||||
|
|
||||||
if attrs.key? 'issue'
|
if attrs.key? 'issue'
|
||||||
uri.path += %(/issues/#{attrs['issue']})
|
uri.path += %(/issues/#{attrs['issue']})
|
||||||
|
text << "##{attrs['issue']}" if text == target
|
||||||
else
|
else
|
||||||
uri.path += %(/tree/#{attrs['rev']}) if attrs.key? 'rev'
|
uri.path += %(/tree/#{attrs['rev']}) if attrs.key? 'rev'
|
||||||
uri.path += %(/#{attrs['path']}) if attrs.key? 'path'
|
uri.path += %(/#{attrs['path']}) if attrs.key? 'path'
|
||||||
|
text << "@#{attrs['rev']}" if text == target
|
||||||
end
|
end
|
||||||
|
|
||||||
target = uri.to_s
|
target = uri.to_s
|
||||||
|
Loading…
Reference in New Issue
Block a user