asciidoctor-foodogsquared-extensions 1.0.0 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f9f519d0ae3e0ac0e73c26e85acb925d53b9b937019d0361ee82b47fa4f8466a
4
- data.tar.gz: b25430e1aeb1dee8b2563dc859a45879ed283698e4cdadef73f534a9a9876aaa
3
+ metadata.gz: 903ca29ce450d3aad60571b57c851fbfcf11524f9fcda8ae3ba388e9c619fdf0
4
+ data.tar.gz: 405bfafa852a1bc66ebf46c1242bee986cc949c78289d699c987dacda17feac0
5
5
  SHA512:
6
- metadata.gz: 307b4db3e7bc66f0ea323344fb177d90c65c3141aa714891277b76cfb656fc501f7ca7e9788e7dbeee7141637e2ec0cea2d0f13b409679f854840ae1b76c0163
7
- data.tar.gz: 63dfa05bd984ea781cb53791a155303e162c1b6b6f582140b28f1804bc20c86fdeee7aaae523c5ec410266417130dba8852801b50d2cc5cc1e727e656a530b9a
6
+ metadata.gz: 63bc0807247b017729d2b4177796a32ffa34635fb373020552028827ff3b4cfdcea22c958e1abeb084f2c6f6d3e44a5bd154b6e5c479af94425e86c69aeed067
7
+ data.tar.gz: bed6effd30c18654a20582ddb383c249ed6f6ddf83ee751c10e4f1f01c98ab0551b7e3fcb095997893a16bf6bfa05e91f28d37986923c59b7fb6190882c5997f
data/CHANGELOG.adoc ADDED
@@ -0,0 +1,79 @@
1
+ = Changelog
2
+ :toc:
3
+
4
+ :github-repo: asciidoctor-foodogsquared-extensions
5
+ :commit-url: https://github.com/foo-dogsquared/{github-repo}/commit
6
+
7
+
8
+ The guidelines for writing this changelog is based from link:https://common-changelog.org[Common Changelog].
9
+
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
+
42
+ == [1.0.1] - 2023-07-09
43
+
44
+ === Updated
45
+
46
+ * Update the gem metadata. (link:{commit-url}/b052cddf56397489c4eb9c7908bfbadbce2c080f[`b052cddf`]) (Gabriel Arazas)
47
+
48
+ === Fixed
49
+
50
+ * Fix the `avatarstype` attribute override for the chat block extension.
51
+ This is considered a bug since it is more intended as a project-wide attribute. (link:{commit-url}/1faf4d45ec9891532254867c219ffb5094781948[`1faf4d45`]) (Gabriel Arazas)
52
+
53
+
54
+ == [1.0.0] - 2023-07-07
55
+
56
+ The initial version of the extension set.
57
+
58
+ === Added
59
+
60
+ * Add `man:` inline macro for online manual pages (link:{commit-url}/4201e1c6e8a028618ab4cb4c6e54af5c3990aa27[`4201e1c6e`] footnote:[Hehe...]) (Gabriel Arazas)
61
+ * Add `rfc:` inline macro for IETF RFCs (link:{commit-url}/0def42d0675dc73ead13491d61ec0220d888462c[`0def42d0`]) (Gabriel Arazas)
62
+ * Add `swh:` inline macro for linking SWHIDs (link:{commit-url}/e18383275ed691d992e5894301534a869e0ccded[`e18383275`]) (Gabriel Arazas)
63
+ * Add `github:` inline macro for adding GitHub links (link:{commit-url}/d846aaa15990ed009261caa6f9d9f1b72a09a727[`d846aaa1`]) (Gabriel Arazas)
64
+ * Add `gitlab:` inline macro for adding GitLab links (link:{commit-url}/e36e3ef452a34f985e974fc56474da1124256649[`e36e3ef45`]) (Gabriel Arazas)
65
+ * Add `wikipedia:` inline macro for adding Wikipedia links (link:{commit-url}/fb35866b30f6266c540541ad6d5c71f58f8bd401[`fb35866b`]) (Gabriel Arazas)
66
+ * Add `ctan:` inline macro for linking CTAN packages (link:{commit-url}/50a9c33f8c55925d690a29f9c3812a79c1a19087[`50a9c33f`]) (Gabriel Arazas)
67
+ * Add `pypi:` inline macro for linking Pypi packages (link:{commit-url}/50a9c33f8c55925d690a29f9c3812a79c1a19087[`50a9c33f`]) (Gabriel Arazas)
68
+ * Add `cratesio:` inline macro for linking crates.io packages (link:{commit-url}/50a9c33f8c55925d690a29f9c3812a79c1a19087[`50a9c33f`]) (Gabriel Arazas)
69
+ * Add `flathub:` inline macro for Flathub packages (link:{commit-url}/ebbde1491c2a0df40938d507b28c6f958ce4fef2[`ebbde149`]) (Gabriel Arazas)
70
+ * Add `fdroid:` inline macro for F-Droid apps (link:{commit-url}/7ddcd9be707833f2958da5e8ba839a0cfceefc92[`7ddcd9be`]) (Gabriel Arazas)
71
+ * Add `musicbrainz:` inline macro for MusicBrainz database objects (link:{commit-url}/ca82f674af87363bda64d8e7795ce0a2b7ef2fe6[`ca82f674`]) (Gabriel Arazas)
72
+ * Add `repology:` inline macro for Repology projects (link:{commit-url}/cef163c722c8af5fa7db2588cfbaf4b3a6fd1f55[`cef163c7`]) (Gabriel Arazas)
73
+ * Add HTML-backend exclusive chat block.
74
+ * Add include processor for SWHIDs (link:{commit-url}/567c52d80aafdd940e095bc8f3708ec4aa9a5097[`567c52d8`]) (Gabriel Arazas)
75
+ * Add include processor for GitHub content (link:{commit-url}/88902f6540a67916eb9233ac5cfe174219017af4[`88902f65`]) (Gabriel Arazas)
76
+
77
+ * Add include processor for GitLab content (link:{commit-url}/d03f1ca7008bb8928de0ec8538d8c110516b68f7[`d03f1ca7`]) (Gabriel Arazas)
78
+ * Add include processor for Git blob objects (link:{commit-url}/02bebfef70d7b2424377bed497671ba1bc8be84d[`02bebfef`]) (Gabriel Arazas)
79
+ * Add preprocessor as prerequisite for `GitBlobIncludeProcessor` (link:{commit-url}/02bebfef70d7b2424377bed497671ba1bc8be84d[`02bebfef`]) (Gabriel Arazas)
data/LICENSE ADDED
@@ -0,0 +1,19 @@
1
+ Copyright (c) 2023 Gabriel Arazas <foodogsquared@foodogsquared.one>
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ of this software and associated documentation files (the "Software"), to deal
5
+ in the Software without restriction, including without limitation the rights
6
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
+ copies of the Software, and to permit persons to whom the Software is
8
+ furnished to do so, subject to the following conditions:
9
+
10
+ The above copyright notice and this permission notice shall be included in
11
+ all copies or substantial portions of the Software.
12
+
13
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
+ THE SOFTWARE.
data/README.adoc ADDED
@@ -0,0 +1,40 @@
1
+ = asciidoctor-foodogsquared-extensions
2
+ :toc:
3
+
4
+
5
+ A set of link:https://asciidoctor.org/[Asciidoctor] extensions mainly for personal use of its author (foodogsquared). :)
6
+
7
+ Despite being v1.0.0, treat this as almost unstable because it is only aimed for its author.
8
+ However, feel free to leave suggestions and improvements.
9
+ Who knows, parts of the set might develop into a more presentable and stable extension of its own.
10
+
11
+
12
+ == Prerequisites
13
+
14
+ The extension is required to be used with Ruby 3.0 and above.
15
+ (At least until I can test and confirm it works on the previous versions.)
16
+
17
+ In order to use it, you have to install it first in your Ruby environment.
18
+ It is available as a gem in RubyGems as `asciidoctor-foodogsquared-extensions` so you can add the following line in `Gemfile`.
19
+
20
+ [source, ruby]
21
+ ----
22
+ gem 'asciidoctor-foodogsquared-extensions'
23
+ ----
24
+
25
+ Somewhere in your Ruby codebase, you can just import it with the following line.
26
+
27
+ [source, ruby]
28
+ ----
29
+ require 'asciidoctor-foodogsquared-extensions'
30
+ ----
31
+
32
+ And bada-bing-bada-boom, you now have the Asciidoctor extensions.
33
+ If installed in the environment, you can now use the extension with the following Asciidoctor command.
34
+
35
+ [source, shell]
36
+ ----
37
+ asciidoctor -r asciidoctor-foodogsquared-extensions ./document.adoc
38
+ ----
39
+
40
+ For now, there's no documentation for the individual macros but you can look into the README files for each macro at link:./lib/asciidoctor/[`./lib/asciidoctor/`].
@@ -1,22 +1,24 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'asciidoctor-foodogsquared-extensions'
3
- s.version = '1.0.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
7
- foo-dogsquared's custom Asciidoctor extensions as a Gem. This is not meant
8
- to be used in production or as a public Gem. This is used since Hugo
9
- doesn't allow loading Asciidoctor extensions with path separators.
7
+ foo-dogsquared's set of Asciidoctor extensions as a Gem. This is where I
8
+ implemented several pet features that will most likely never be a part of
9
+ Asciidoctor.
10
10
  DESC
11
11
 
12
12
  s.required_ruby_version = '>= 3.0.0'
13
13
 
14
14
  s.authors = ['Gabriel Arazas']
15
15
  s.email = 'foodogsquared@foodogsquared.one'
16
- s.metadata = { 'source_code_uri' => 'https://github.com/foo-dogsquared/foo-dogsquared.github.io' }
16
+ s.metadata = { 'source_code_uri' => 'https://github.com/foo-dogsquared/asciidoctor-foodogsquared-extensions' }
17
17
 
18
- s.files = Dir['lib/**/*', '*.gemspec']
18
+ s.files = Dir['lib/**/*', '*.gemspec', 'LICENSE', 'CHANGELOG.adoc', 'README.adoc']
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
@@ -6,7 +6,7 @@ class ChatBlock < Asciidoctor::Extensions::BlockProcessor
6
6
  named :chat
7
7
  on_context :example
8
8
  name_positional_attributes 'avatar', 'state'
9
- default_attributes 'state' => 'default', 'avatarstype' => 'avif'
9
+ default_attributes 'state' => 'default'
10
10
 
11
11
  def process(parent, reader, attrs)
12
12
  block = create_block parent, :pass, nil, attrs, content_model: :compound
@@ -17,12 +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'])
28
+ attrs['avatarstype'] ||= parent.attributes['avatarstype'] || 'avif'
26
29
 
27
30
  avatar_sticker = "#{attrs['avatar'].to_kebab}/#{attrs['state'].to_kebab}.#{attrs['avatarstype']}"
28
31
  avatar_img_attrs = {
@@ -32,18 +35,20 @@ class ChatBlock < Asciidoctor::Extensions::BlockProcessor
32
35
  avatar_imgblock = create_image_block block, avatar_img_attrs
33
36
 
34
37
  block << avatar_imgblock
35
- block << (create_html_fragment block, %(
38
+ block << (create_html_fragment block, <<~HTML
36
39
  </div>
37
40
  <div class="dialogblock dialogblock__text">
38
41
  <small class="dialogblock dialogblock__avatar-name">#{attrs['name']}</small>
39
- ))
42
+ HTML
43
+ )
40
44
 
41
45
  parse_content block, reader
42
46
 
43
- block << (create_html_fragment block, %(
47
+ block << (create_html_fragment block, <<~HTML
44
48
  </div>
45
49
  </div>
46
- ))
50
+ HTML
51
+ )
47
52
 
48
53
  block
49
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
- if attrs['caption'].nil?
20
- metadata = OpenURI.open_uri(app_metadata_uri) { |f| YAML.safe_load(f.read) }
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
- if attrs['caption'].nil?
27
- metadata = OpenURI.open_uri(app_metadata_uri, headers) { |f| JSON.parse(f.read) }
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
@@ -37,7 +37,6 @@ Asciidoctor::Extensions.register do
37
37
  include_processor GitLabRawIncludeProcessor
38
38
 
39
39
  include_processor GitBlobIncludeProcessor
40
- preprocessor GitContentBranchAttributePreprocessor
41
40
 
42
41
  inline_macro WikipediaInlineMacro
43
42
 
@@ -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:{doccontentref}[opts="diff", path=Gemfile]` should include a diff of the Gemfile from `content/posts/sample` branch (assuming that Gemfile has changed).
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
- repo = Rugged::Repository.discover(__dir__)
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
- uri.path += %(/-/tree/#{attrs['rev']}) if attrs['rev']
24
- uri.path += %(/#{attrs['path']}) if attrs['path']
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
- text = manname = target
13
- suffix = (volnum = attrs['volnum']) ? %((#{volnum})) : ''
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, manname
40
+ node = create_inline parent, :quoted, text
37
41
  end
38
42
  elsif doc.backend == 'manpage'
39
- node = create_inline parent, :quoted, manname, type: :strong
43
+ node = create_inline parent, :quoted, text, type: :strong
40
44
  else
41
- node = create_inline parent, :quoted, manname
45
+ node = create_inline parent, :quoted, text
42
46
  end
43
- create_inline parent, :quoted, %(#{node.convert}#{suffix})
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
- if attrs['caption'].nil?
27
- metadata = OpenURI.open_uri(uri, headers) { |f| JSON.parse(f.read) }
28
- attrs['caption'] ||= case attrs['type']
29
- when 'artist', 'area', 'events', 'genre', 'instrument', 'label', 'place', 'series'
30
- metadata['name']
31
- when 'recording', 'release-group', 'release', 'cdstub', 'work'
32
- metadata['title']
33
- when 'url'
34
- metadata['resource']
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.0
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gabriel Arazas
@@ -38,15 +38,32 @@ 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
- foo-dogsquared's custom Asciidoctor extensions as a Gem. This is not meant
43
- to be used in production or as a public Gem. This is used since Hugo
44
- doesn't allow loading Asciidoctor extensions with path separators.
56
+ foo-dogsquared's set of Asciidoctor extensions as a Gem. This is where I
57
+ implemented several pet features that will most likely never be a part of
58
+ Asciidoctor.
45
59
  email: foodogsquared@foodogsquared.one
46
60
  executables: []
47
61
  extensions: []
48
62
  extra_rdoc_files: []
49
63
  files:
64
+ - CHANGELOG.adoc
65
+ - LICENSE
66
+ - README.adoc
50
67
  - asciidoctor-foodogsquared-extensions.gemspec
51
68
  - lib/asciidoctor-foodogsquared-extensions.rb
52
69
  - lib/asciidoctor/chat-block-processor/README.adoc
@@ -76,6 +93,7 @@ files:
76
93
  - lib/asciidoctor/package-indices-link-macro/extension.rb
77
94
  - lib/asciidoctor/repology-link-inline-macro/README.adoc
78
95
  - lib/asciidoctor/repology-link-inline-macro/extension.rb
96
+ - lib/asciidoctor/spdx-link-inline-macro/README.adoc
79
97
  - lib/asciidoctor/swhid-include-processor/README.adoc
80
98
  - lib/asciidoctor/swhid-include-processor/extension.rb
81
99
  - lib/asciidoctor/swhid-inline-macro/README.adoc
@@ -86,7 +104,7 @@ homepage:
86
104
  licenses:
87
105
  - MIT
88
106
  metadata:
89
- source_code_uri: https://github.com/foo-dogsquared/foo-dogsquared.github.io
107
+ source_code_uri: https://github.com/foo-dogsquared/asciidoctor-foodogsquared-extensions
90
108
  post_install_message:
91
109
  rdoc_options: []
92
110
  require_paths: