asciidoctor-foodogsquared-extensions 1.0.1 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.adoc +31 -0
- data/asciidoctor-foodogsquared-extensions.gemspec +3 -1
- data/lib/asciidoctor/chat-block-processor/extension.rb +11 -7
- data/lib/asciidoctor/fdroid-link-inline-macro/extension.rb +2 -4
- data/lib/asciidoctor/flathub-link-inline-macro/extension.rb +2 -4
- data/lib/asciidoctor/foodogsquared-extensions.rb +0 -1
- data/lib/asciidoctor/git-blob-include-processor/README.adoc +4 -15
- data/lib/asciidoctor/git-blob-include-processor/extension.rb +2 -15
- data/lib/asciidoctor/gitlab-link-inline-macro/README.adoc +3 -0
- data/lib/asciidoctor/gitlab-link-inline-macro/extension.rb +8 -2
- data/lib/asciidoctor/man-inline-macro/extension.rb +11 -6
- data/lib/asciidoctor/musicbrainz-link-inline-macro/extension.rb +9 -11
- data/lib/asciidoctor/spdx-link-inline-macro/README.adoc +26 -0
- metadata +16 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 903ca29ce450d3aad60571b57c851fbfcf11524f9fcda8ae3ba388e9c619fdf0
|
4
|
+
data.tar.gz: 405bfafa852a1bc66ebf46c1242bee986cc949c78289d699c987dacda17feac0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 63bc0807247b017729d2b4177796a32ffa34635fb373020552028827ff3b4cfdcea22c958e1abeb084f2c6f6d3e44a5bd154b6e5c479af94425e86c69aeed067
|
7
|
+
data.tar.gz: bed6effd30c18654a20582ddb383c249ed6f6ddf83ee751c10e4f1f01c98ab0551b7e3fcb095997893a16bf6bfa05e91f28d37986923c59b7fb6190882c5997f
|
data/CHANGELOG.adoc
CHANGED
@@ -8,6 +8,37 @@
|
|
8
8
|
The guidelines for writing this changelog is based from link:https://common-changelog.org[Common Changelog].
|
9
9
|
|
10
10
|
|
11
|
+
== [1.1.0] - 2023-11-01
|
12
|
+
|
13
|
+
=== Removed
|
14
|
+
|
15
|
+
* Remove preprocessor extension from Git blob include processor.
|
16
|
+
Thus, `doccontentref` document attribute has been removed. ({commit-url}/a95b09a81f623554e4e747063befcf5a14fd060e[`a95b09a`]) (Gabriel Arazas)
|
17
|
+
|
18
|
+
=== Updated
|
19
|
+
|
20
|
+
* Update the default behavior of several extensions where it will create a network request in all cases, not just when the caption is unset.
|
21
|
+
It will now throw an error once it detected no object given from a service.
|
22
|
+
These extensions are the Flathub link inline macro, the F-Droid link inline macro, and the MusicBrainz link inline macro.
|
23
|
+
For example, `flathub:com.example.NonExistentApp[example app]` will now throw an error since the given app doesn't exist from Flathub. ({commit-url}/924fd9eac5653a14d6105bc8f27f99fabe955f98[`924fd9e`]) (Gabriel Arazas)
|
24
|
+
|
25
|
+
* Revise the default text for manpages for man inline macro. ({commit-url}/928cd80561957a529551e42cad8123840aa6afa0[`928cd80`]) (Gabriel Arazas)
|
26
|
+
|
27
|
+
=== Added
|
28
|
+
|
29
|
+
* Add 'openbsd' option for man inline macro for easily linking manpages from https://man.openbsd.org. ({commit-url}/fcb06be49fba5d3251e6c68e5fdaf934034dcf41[`fcb06be`]) (Gabriel Arazas)
|
30
|
+
|
31
|
+
* Add 'issue' option for GitLab link inline macro enabling users to link to issues from GitLab instances easily. ({commit-url}/cf8a942011cbd6b26785689d0ee4b8eff67f947e[`cf8a942`]) (Gabriel Arazas)
|
32
|
+
|
33
|
+
=== Fixed
|
34
|
+
|
35
|
+
* Fix the Git repo discovery processor of the Git blob include processor with `gitrepo` attribute.
|
36
|
+
By default, it will try to discover it through the base directory of the document. ({commit-url}/a95b09a81f623554e4e747063befcf5a14fd060e[`a95b09a`]) (Gabriel Arazas)
|
37
|
+
|
38
|
+
* Make the extensions inherit part of the parent's (or if possible, the document) attributes.
|
39
|
+
This should fix some things such as setting the `avatarstype` document attribute for chat block processor extension. ({commit-url}/de3ced3d3a237870f9d57279649db71feaba975c[`de3ced3`]) (Gabriel Arazas)
|
40
|
+
|
41
|
+
|
11
42
|
== [1.0.1] - 2023-07-09
|
12
43
|
|
13
44
|
=== Updated
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = 'asciidoctor-foodogsquared-extensions'
|
3
|
-
s.version = '1.0
|
3
|
+
s.version = '1.1.0'
|
4
4
|
s.licenses = ['MIT']
|
5
5
|
s.summary = "foo-dogsquared's custom Asciidoctor extensions"
|
6
6
|
s.description = <<-DESC
|
@@ -19,4 +19,6 @@ Gem::Specification.new do |s|
|
|
19
19
|
|
20
20
|
s.add_runtime_dependency 'asciidoctor', '~> 2.0'
|
21
21
|
s.add_runtime_dependency 'rugged', '~> 1.0'
|
22
|
+
|
23
|
+
s.add_development_dependency 'rspec', '~> 3.0'
|
22
24
|
end
|
@@ -17,13 +17,15 @@ class ChatBlock < Asciidoctor::Extensions::BlockProcessor
|
|
17
17
|
# contains two output: the dialog image of our avatar and its content.
|
18
18
|
attrs['name'] ||= attrs['avatar']
|
19
19
|
|
20
|
-
block << (create_html_fragment block,
|
20
|
+
block << (create_html_fragment block, <<~HTML
|
21
21
|
<div role="figure" class="dialogblock dialogblock__box dialogblock__avatar--#{attrs['avatar']} #{attrs['role']}">
|
22
22
|
<div class="dialogblock dialogblock__avatar">
|
23
|
-
|
23
|
+
HTML
|
24
|
+
|
25
|
+
)
|
24
26
|
|
25
27
|
attrs['avatarsdir'] ||= File.expand_path('./avatars', attrs['iconsdir'])
|
26
|
-
attrs['avatarstype'] ||= 'avif'
|
28
|
+
attrs['avatarstype'] ||= parent.attributes['avatarstype'] || 'avif'
|
27
29
|
|
28
30
|
avatar_sticker = "#{attrs['avatar'].to_kebab}/#{attrs['state'].to_kebab}.#{attrs['avatarstype']}"
|
29
31
|
avatar_img_attrs = {
|
@@ -33,18 +35,20 @@ class ChatBlock < Asciidoctor::Extensions::BlockProcessor
|
|
33
35
|
avatar_imgblock = create_image_block block, avatar_img_attrs
|
34
36
|
|
35
37
|
block << avatar_imgblock
|
36
|
-
block << (create_html_fragment block,
|
38
|
+
block << (create_html_fragment block, <<~HTML
|
37
39
|
</div>
|
38
40
|
<div class="dialogblock dialogblock__text">
|
39
41
|
<small class="dialogblock dialogblock__avatar-name">#{attrs['name']}</small>
|
40
|
-
|
42
|
+
HTML
|
43
|
+
)
|
41
44
|
|
42
45
|
parse_content block, reader
|
43
46
|
|
44
|
-
block << (create_html_fragment block,
|
47
|
+
block << (create_html_fragment block, <<~HTML
|
45
48
|
</div>
|
46
49
|
</div>
|
47
|
-
|
50
|
+
HTML
|
51
|
+
)
|
48
52
|
|
49
53
|
block
|
50
54
|
end
|
@@ -16,10 +16,8 @@ class FDroidLinkInlineMacro < Asciidoctor::Extensions::InlineMacroProcessor
|
|
16
16
|
app_id = target
|
17
17
|
app_metadata_uri = %(https://gitlab.com/fdroid/fdroiddata/-/raw/master/metadata/#{app_id}.yml)
|
18
18
|
|
19
|
-
|
20
|
-
|
21
|
-
attrs['caption'] = metadata['AutoName']
|
22
|
-
end
|
19
|
+
metadata = OpenURI.open_uri(app_metadata_uri) { |f| YAML.safe_load(f.read) }
|
20
|
+
attrs['caption'] ||= metadata['AutoName']
|
23
21
|
|
24
22
|
url = %(https://f-droid.org/#{attrs['lang']}/packages/#{app_id})
|
25
23
|
doc.register :links, url
|
@@ -23,10 +23,8 @@ class FlathubLinkInlineMacro < Asciidoctor::Extensions::InlineMacroProcessor
|
|
23
23
|
'User-Agent' => ::Asciidoctor::FoodogsquaredCustomExtensions::USER_AGENT
|
24
24
|
}
|
25
25
|
|
26
|
-
|
27
|
-
|
28
|
-
attrs['caption'] = metadata['name']
|
29
|
-
end
|
26
|
+
metadata = OpenURI.open_uri(app_metadata_uri, headers) { |f| JSON.parse(f.read) }
|
27
|
+
attrs['caption'] ||= metadata['name']
|
30
28
|
|
31
29
|
url = %(https://flathub.org/apps/#{app_id})
|
32
30
|
doc.register :links, url
|
@@ -23,6 +23,9 @@ If the resulting operation ends in an error (i.e., non-existing revision, file,
|
|
23
23
|
|
24
24
|
== Attributes
|
25
25
|
|
26
|
+
- `gitrepo` is the path to the Git repo.
|
27
|
+
By default, it is the base directory of the document.
|
28
|
+
|
26
29
|
- `path` is the filepath to be retrieved from the revision.
|
27
30
|
When used with `diff`, it changes into a semicolon-delimited (`;`) list of files to make diffs with multiple files.
|
28
31
|
|
@@ -43,25 +46,11 @@ You can give the following options through `opts` attribute (i.e., `opts="diff,r
|
|
43
46
|
- `reverse` reverses the sides to be compared.
|
44
47
|
|
45
48
|
|
46
|
-
== Extra notes
|
47
|
-
|
48
|
-
The extension is composed of two parts: an include processor and a preprocessor.
|
49
|
-
|
50
|
-
The preprocessor add a document attribute, `doccontentref`, which it gives the Git reference for that content.
|
51
|
-
`doccontentref` is the difference between the process working directory (`Dir.pwd`) and the base directory of the content to be converted.
|
52
|
-
In case the process working directory is not entirely consistent for several reasons, you could give the attribute `rootdir` as the basis for the comparison.
|
53
|
-
As another option, you could also manually set `doccontentref` in case it isn't applicable (i.e., for multilingual sites in Hugo projects).
|
54
|
-
|
55
|
-
The include processor also accepts an empty target with the prefix (i.e., `include::git:[]`) as a shorthand for `include::git:{doccontentref}`.
|
56
|
-
|
57
|
-
|
58
49
|
== Example usage
|
59
50
|
|
60
|
-
The following examples assume that `doccontentref` points to `content/posts/sample`.
|
61
|
-
|
62
51
|
- `include::git:HEAD[path=shell.nix]` should transclude the current iteration of `shell.nix`.
|
63
52
|
|
64
|
-
- `include::git:
|
53
|
+
- `include::git:v1.0.0[opts="diff", path=Gemfile]` should include a diff of the Gemfile from `content/posts/sample` branch (assuming that Gemfile has changed).
|
65
54
|
|
66
55
|
- `include::git:non-existing-rev[opts="diff"]` should result in a warning with the non-existing revision.
|
67
56
|
|
@@ -8,7 +8,8 @@ class GitBlobIncludeProcessor < Asciidoctor::Extensions::IncludeProcessor
|
|
8
8
|
end
|
9
9
|
|
10
10
|
def process(doc, reader, target, attrs)
|
11
|
-
|
11
|
+
attrs['gitrepo'] ||= doc.attributes['gitrepo'] || doc.base_dir
|
12
|
+
repo = Rugged::Repository.discover(attrs['gitrepo'])
|
12
13
|
|
13
14
|
git_object_ref = target.delete_prefix 'git:'
|
14
15
|
git_object_ref = doc.attributes['doccontentref'] if git_object_ref.empty?
|
@@ -63,17 +64,3 @@ class GitBlobIncludeProcessor < Asciidoctor::Extensions::IncludeProcessor
|
|
63
64
|
reader
|
64
65
|
end
|
65
66
|
end
|
66
|
-
|
67
|
-
class GitContentBranchAttributePreprocessor < Asciidoctor::Extensions::Preprocessor
|
68
|
-
def process(document, reader)
|
69
|
-
base_dir = Pathname.new(document.base_dir)
|
70
|
-
rootdir = if document.attributes['rootdir'].nil?
|
71
|
-
Dir.pwd
|
72
|
-
else
|
73
|
-
document.attributes['rootdir']
|
74
|
-
end
|
75
|
-
|
76
|
-
document.attributes['doccontentref'] = base_dir.relative_path_from(rootdir).to_s
|
77
|
-
reader
|
78
|
-
end
|
79
|
-
end
|
@@ -23,6 +23,9 @@ By default. it doesn't point to anything which should be in the default branch o
|
|
23
23
|
|
24
24
|
- `path` is the filepath to be linked.
|
25
25
|
|
26
|
+
- `issue` is the issue to be linked from the repo.
|
27
|
+
Take note issue has higher precedence so once `domain` and `issue` are both set, it will still link to an issue.
|
28
|
+
|
26
29
|
There are settings that is enabled with the link:https://docs.asciidoctor.org/asciidoc/latest/attributes/options/[options attribute].
|
27
30
|
|
28
31
|
- `repo` sets the default caption to be the repo part.
|
@@ -20,8 +20,14 @@ class GitLabLinkInlineMacro < Asciidoctor::Extensions::InlineMacroProcessor
|
|
20
20
|
text = attrs['caption'] || default_caption
|
21
21
|
uri = URI.parse %(https://#{attrs['domain']}/#{target})
|
22
22
|
|
23
|
-
|
24
|
-
|
23
|
+
if attrs.key? 'issue'
|
24
|
+
uri.path += %(/-/issues/#{attrs['issue']})
|
25
|
+
text << "##{attrs['issue']}" if text == target
|
26
|
+
else
|
27
|
+
uri.path += %(/-/tree/#{attrs['rev']}) if attrs.key? 'rev'
|
28
|
+
uri.path += %(/#{attrs['path']}) if attrs.key? 'path'
|
29
|
+
text << "@#{attrs['rev']}" if attrs.key?('rev') && text == target
|
30
|
+
end
|
25
31
|
|
26
32
|
target = uri.to_s
|
27
33
|
|
@@ -9,8 +9,10 @@ class ManInlineMacro < Asciidoctor::Extensions::InlineMacroProcessor
|
|
9
9
|
|
10
10
|
def process(parent, target, attrs)
|
11
11
|
doc = parent.document
|
12
|
-
|
13
|
-
|
12
|
+
manname = target
|
13
|
+
volnum = attrs['volnum']
|
14
|
+
|
15
|
+
text = %(#{manname}(#{volnum}))
|
14
16
|
|
15
17
|
if doc.basebackend? 'html'
|
16
18
|
domain = case attrs['service']
|
@@ -22,6 +24,8 @@ class ManInlineMacro < Asciidoctor::Extensions::InlineMacroProcessor
|
|
22
24
|
'https://manpages.opensuse.org'
|
23
25
|
when 'voidlinux'
|
24
26
|
'https://man.voidlinux.org'
|
27
|
+
when 'openbsd'
|
28
|
+
'https://man.openbsd.org'
|
25
29
|
when 'none'
|
26
30
|
nil
|
27
31
|
else
|
@@ -33,13 +37,14 @@ class ManInlineMacro < Asciidoctor::Extensions::InlineMacroProcessor
|
|
33
37
|
doc.register :links, target
|
34
38
|
node = create_anchor parent, text, type: :link, target: target
|
35
39
|
else
|
36
|
-
node = create_inline parent, :quoted,
|
40
|
+
node = create_inline parent, :quoted, text
|
37
41
|
end
|
38
42
|
elsif doc.backend == 'manpage'
|
39
|
-
node = create_inline parent, :quoted,
|
43
|
+
node = create_inline parent, :quoted, text, type: :strong
|
40
44
|
else
|
41
|
-
node = create_inline parent, :quoted,
|
45
|
+
node = create_inline parent, :quoted, text
|
42
46
|
end
|
43
|
-
|
47
|
+
|
48
|
+
node
|
44
49
|
end
|
45
50
|
end
|
@@ -23,17 +23,15 @@ class MusicBrainzLinkInlineMacro < Asciidoctor::Extensions::InlineMacroProcessor
|
|
23
23
|
|
24
24
|
uri = %(#{root_endpoint}/#{attrs['type']}/#{target})
|
25
25
|
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
end
|
36
|
-
end
|
26
|
+
metadata = OpenURI.open_uri(uri, headers) { |f| JSON.parse(f.read) }
|
27
|
+
attrs['caption'] ||= case attrs['type']
|
28
|
+
when 'artist', 'area', 'events', 'genre', 'instrument', 'label', 'place', 'series'
|
29
|
+
metadata['name']
|
30
|
+
when 'recording', 'release-group', 'release', 'cdstub', 'work'
|
31
|
+
metadata['title']
|
32
|
+
when 'url'
|
33
|
+
metadata['resource']
|
34
|
+
end
|
37
35
|
|
38
36
|
target = %(https://musicbrainz.org/#{attrs['type']}/#{target})
|
39
37
|
doc.register :links, target
|
@@ -0,0 +1,26 @@
|
|
1
|
+
= SPDX link inline macro
|
2
|
+
:toc:
|
3
|
+
|
4
|
+
It's an inline macro for easily creating licenses from SPDX license data.
|
5
|
+
|
6
|
+
|
7
|
+
== Synopsis
|
8
|
+
|
9
|
+
[source, asciidoc]
|
10
|
+
----
|
11
|
+
spdx:$LICENSE_ID[$CAPTION]
|
12
|
+
----
|
13
|
+
|
14
|
+
Where...
|
15
|
+
|
16
|
+
* `$LICENSE_ID` is the identifier for the license.
|
17
|
+
|
18
|
+
* `$CAPTION` is the link caption to be used.
|
19
|
+
By default, it will use the name of the license.
|
20
|
+
|
21
|
+
|
22
|
+
== Example usage
|
23
|
+
|
24
|
+
* `spdx:MIT[]` will result to the link:https://spdx.org/licenses/MIT.html[MIT license page on SPDX] with the caption `MIT License`.
|
25
|
+
|
26
|
+
* `spdx:MIT[the MIT license]` is the same as the previous example but with a different caption of `the MIT license`.
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: asciidoctor-foodogsquared-extensions
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Gabriel Arazas
|
@@ -38,6 +38,20 @@ dependencies:
|
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '1.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '3.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '3.0'
|
41
55
|
description: |2
|
42
56
|
foo-dogsquared's set of Asciidoctor extensions as a Gem. This is where I
|
43
57
|
implemented several pet features that will most likely never be a part of
|
@@ -79,6 +93,7 @@ files:
|
|
79
93
|
- lib/asciidoctor/package-indices-link-macro/extension.rb
|
80
94
|
- lib/asciidoctor/repology-link-inline-macro/README.adoc
|
81
95
|
- lib/asciidoctor/repology-link-inline-macro/extension.rb
|
96
|
+
- lib/asciidoctor/spdx-link-inline-macro/README.adoc
|
82
97
|
- lib/asciidoctor/swhid-include-processor/README.adoc
|
83
98
|
- lib/asciidoctor/swhid-include-processor/extension.rb
|
84
99
|
- lib/asciidoctor/swhid-inline-macro/README.adoc
|