mirror of
https://github.com/foo-dogsquared/asciidoctor-foodogsquared-extensions.git
synced 2025-02-07 12:19:14 +00:00
Create IETF RFC link inline macro
This commit is contained in:
parent
0758726908
commit
0def42d067
@ -21,11 +21,13 @@ require_relative 'fdroid-link-inline-macro/extension'
|
|||||||
require_relative 'musicbrainz-link-inline-macro/extension'
|
require_relative 'musicbrainz-link-inline-macro/extension'
|
||||||
require_relative 'flathub-link-inline-macro/extension'
|
require_relative 'flathub-link-inline-macro/extension'
|
||||||
require_relative 'repology-link-inline-macro/extension'
|
require_relative 'repology-link-inline-macro/extension'
|
||||||
|
require_relative 'ietf-rfc-link-inline-macro/extension'
|
||||||
|
|
||||||
OpenURI::Cache.cache_path = '/tmp/open-uri-cache-foodogsquared-website'
|
OpenURI::Cache.cache_path = '/tmp/open-uri-cache-foodogsquared-website'
|
||||||
|
|
||||||
Asciidoctor::Extensions.register do
|
Asciidoctor::Extensions.register do
|
||||||
inline_macro ManInlineMacro
|
inline_macro ManInlineMacro
|
||||||
|
inline_macro IETFRFCLinkInlineMacro
|
||||||
block ChatBlock if @document.basebackend? 'html'
|
block ChatBlock if @document.basebackend? 'html'
|
||||||
|
|
||||||
inline_macro SWHInlineMacro
|
inline_macro SWHInlineMacro
|
||||||
|
27
lib/asciidoctor/ietf-rfc-link-inline-macro/README.adoc
Normal file
27
lib/asciidoctor/ietf-rfc-link-inline-macro/README.adoc
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
= Flathub link inline macro
|
||||||
|
:toc:
|
||||||
|
|
||||||
|
|
||||||
|
A shorthand for linking link:https://datatracker.ietf.org/[IETF RFCs].
|
||||||
|
|
||||||
|
|
||||||
|
== Synopsis
|
||||||
|
|
||||||
|
[source, asciidoc]
|
||||||
|
----
|
||||||
|
rfc:$RFC[$CAPTION]
|
||||||
|
----
|
||||||
|
|
||||||
|
Where...
|
||||||
|
|
||||||
|
- `$RFC` is the RFC number.
|
||||||
|
|
||||||
|
- `$CAPTION` is the link text to be used.
|
||||||
|
By default, it will be `RFC$RFC`.
|
||||||
|
|
||||||
|
|
||||||
|
== Example usage
|
||||||
|
|
||||||
|
- `rfc:2136[]` links to the link:https://datatracker.ietf.org/doc/html/rfc2136[RFC2136 (dynamic update)] with the caption `RFC2136`.
|
||||||
|
|
||||||
|
- `rfc:2136[Dynamic DNS updates]` is the same as the previous list item but with the caption text `Dynamic DNS updates`.
|
16
lib/asciidoctor/ietf-rfc-link-inline-macro/extension.rb
Normal file
16
lib/asciidoctor/ietf-rfc-link-inline-macro/extension.rb
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
class IETFRFCLinkInlineMacro < Asciidoctor::Extensions::InlineMacroProcessor
|
||||||
|
use_dsl
|
||||||
|
|
||||||
|
named :rfc
|
||||||
|
name_positional_attributes 'caption'
|
||||||
|
|
||||||
|
def process(parent, target, attrs)
|
||||||
|
doc = parent.document
|
||||||
|
url = %(https://datatracker.ietf.org/doc/html/#{target})
|
||||||
|
attrs['caption'] ||= "RFC#{target}"
|
||||||
|
doc.register :links, url
|
||||||
|
create_anchor parent, attrs['caption'], type: :link, target: url
|
||||||
|
end
|
||||||
|
end
|
Loading…
Reference in New Issue
Block a user