asciidoctor-external-callout 0.0.6.pre.beta7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +13 -0
- data/CHANGELOG.md +12 -0
- data/CODE_OF_CONDUCT.md +84 -0
- data/Gemfile +10 -0
- data/LICENSE.txt +21 -0
- data/README.md +97 -0
- data/Rakefile +12 -0
- data/asciidoctor-external-callout.gemspec +37 -0
- data/bin/console +15 -0
- data/bin/setup +8 -0
- data/lib/asciidoctor-external-callout.rb +201 -0
- data/lib/version.rb +9 -0
- metadata +73 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 910479158955009faec89ab7797f5b30c5d97aff3433c276fb6bc34d0f1e10c2
|
4
|
+
data.tar.gz: e082c0a766caa8a2cd5f5f60f8063052f75ca398b2a6933afc06eb581c9c1e48
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: ce3c945787e12aef49a863250cbdab404e5a2c0ee7396c81c8a969829b724506c0c5cfec3bb42a407cac9bb017d03bb4d1979fd11d0539ee466339648f52f4a4
|
7
|
+
data.tar.gz: 4bf8d47eb9008153011617d1e3438b7c8bff86d1e70a0686dd8494f543fac7dc4f72c7cd75d4c8ae02b9a95ddea30f8ad665a4f23e7a208775e9e6f6fa5dd145
|
data/.gitignore
ADDED
data/CHANGELOG.md
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
# Changelog
|
2
|
+
|
3
|
+
Record of bug fixes, enhancements, and changes.
|
4
|
+
|
5
|
+
## [0.0.6-beta6] – 2022-06-11
|
6
|
+
|
7
|
+
### Changed
|
8
|
+
|
9
|
+
- Ordered lists were only processes if they occurred directly beneath a source listing block. This turns out to be quite restrictive, and doesn't follow Asciidoc's stance on processing standard callouts, which allows for intermediate blocks to separate the source list from the attached callout list.\
|
10
|
+
The processor will now allow intermediate blocks to separate the source listing from the ordered list containing callouts.
|
11
|
+
- Fixed a few spelling mistakes and a code line where I was picking up a formatted item, rather than a raw item.
|
12
|
+
|
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,84 @@
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
2
|
+
|
3
|
+
## Our Pledge
|
4
|
+
|
5
|
+
We as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for everyone, regardless of age, body size, visible or invisible disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, religion, or sexual identity and orientation.
|
6
|
+
|
7
|
+
We pledge to act and interact in ways that contribute to an open, welcoming, diverse, inclusive, and healthy community.
|
8
|
+
|
9
|
+
## Our Standards
|
10
|
+
|
11
|
+
Examples of behavior that contributes to a positive environment for our community include:
|
12
|
+
|
13
|
+
* Demonstrating empathy and kindness toward other people
|
14
|
+
* Being respectful of differing opinions, viewpoints, and experiences
|
15
|
+
* Giving and gracefully accepting constructive feedback
|
16
|
+
* Accepting responsibility and apologizing to those affected by our mistakes, and learning from the experience
|
17
|
+
* Focusing on what is best not just for us as individuals, but for the overall community
|
18
|
+
|
19
|
+
Examples of unacceptable behavior include:
|
20
|
+
|
21
|
+
* The use of sexualized language or imagery, and sexual attention or
|
22
|
+
advances of any kind
|
23
|
+
* Trolling, insulting or derogatory comments, and personal or political attacks
|
24
|
+
* Public or private harassment
|
25
|
+
* Publishing others' private information, such as a physical or email
|
26
|
+
address, without their explicit permission
|
27
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
28
|
+
professional setting
|
29
|
+
|
30
|
+
## Enforcement Responsibilities
|
31
|
+
|
32
|
+
Community leaders are responsible for clarifying and enforcing our standards of acceptable behavior and will take appropriate and fair corrective action in response to any behavior that they deem inappropriate, threatening, offensive, or harmful.
|
33
|
+
|
34
|
+
Community leaders have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, and will communicate reasons for moderation decisions when appropriate.
|
35
|
+
|
36
|
+
## Scope
|
37
|
+
|
38
|
+
This Code of Conduct applies within all community spaces, and also applies when an individual is officially representing the community in public spaces. Examples of representing our community include using an official e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event.
|
39
|
+
|
40
|
+
## Enforcement
|
41
|
+
|
42
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the community leaders responsible for enforcement at ray.offiah@couchbase.com. All complaints will be reviewed and investigated promptly and fairly.
|
43
|
+
|
44
|
+
All community leaders are obligated to respect the privacy and security of the reporter of any incident.
|
45
|
+
|
46
|
+
## Enforcement Guidelines
|
47
|
+
|
48
|
+
Community leaders will follow these Community Impact Guidelines in determining the consequences for any action they deem in violation of this Code of Conduct:
|
49
|
+
|
50
|
+
### 1. Correction
|
51
|
+
|
52
|
+
**Community Impact**: Use of inappropriate language or other behavior deemed unprofessional or unwelcome in the community.
|
53
|
+
|
54
|
+
**Consequence**: A private, written warning from community leaders, providing clarity around the nature of the violation and an explanation of why the behavior was inappropriate. A public apology may be requested.
|
55
|
+
|
56
|
+
### 2. Warning
|
57
|
+
|
58
|
+
**Community Impact**: A violation through a single incident or series of actions.
|
59
|
+
|
60
|
+
**Consequence**: A warning with consequences for continued behavior. No interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, for a specified period of time. This includes avoiding interactions in community spaces as well as external channels like social media. Violating these terms may lead to a temporary or permanent ban.
|
61
|
+
|
62
|
+
### 3. Temporary Ban
|
63
|
+
|
64
|
+
**Community Impact**: A serious violation of community standards, including sustained inappropriate behavior.
|
65
|
+
|
66
|
+
**Consequence**: A temporary ban from any sort of interaction or public communication with the community for a specified period of time. No public or private interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, is allowed during this period. Violating these terms may lead to a permanent ban.
|
67
|
+
|
68
|
+
### 4. Permanent Ban
|
69
|
+
|
70
|
+
**Community Impact**: Demonstrating a pattern of violation of community standards, including sustained inappropriate behavior, harassment of an individual, or aggression toward or disparagement of classes of individuals.
|
71
|
+
|
72
|
+
**Consequence**: A permanent ban from any sort of public interaction within the community.
|
73
|
+
|
74
|
+
## Attribution
|
75
|
+
|
76
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 2.0,
|
77
|
+
available at https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
|
78
|
+
|
79
|
+
Community Impact Guidelines were inspired by [Mozilla's code of conduct enforcement ladder](https://github.com/mozilla/diversity).
|
80
|
+
|
81
|
+
[homepage]: https://www.contributor-covenant.org
|
82
|
+
|
83
|
+
For answers to common questions about this code of conduct, see the FAQ at
|
84
|
+
https://www.contributor-covenant.org/faq. Translations are available at https://www.contributor-covenant.org/translations.
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2022 Ray Offiah
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,97 @@
|
|
1
|
+
# Asciidoctor External Callout
|
2
|
+
|
3
|
+
## Description
|
4
|
+
|
5
|
+
An [Asciidoctor](https://asciidoctor.org/) extension which adds support for callout tags added outside the listing block.
|
6
|
+
|
7
|
+
## Motivation
|
8
|
+
|
9
|
+
Aside from getting little practice around Ruby and JavaScript, I decided to have a crack at this to help with a problem that comes up at work every so often.
|
10
|
+
|
11
|
+
The [callout mechanism](https://docs.asciidoctor.org/asciidoc/latest/verbatim/callouts/) for Asciidoc works extremely well in 99% of the cases I run into:
|
12
|
+
|
13
|
+
```asciidoc
|
14
|
+
[source,ruby]
|
15
|
+
----
|
16
|
+
require 'sinatra' #<1>
|
17
|
+
|
18
|
+
get '/hi' do #<2> #<3>
|
19
|
+
"Hello World!"
|
20
|
+
end
|
21
|
+
----
|
22
|
+
<1> Library import
|
23
|
+
<2> URL mapping
|
24
|
+
<3> Response block
|
25
|
+
```
|
26
|
+
|
27
|
+
|
28
|
+
Great, but it does mean you have to add commented to the tags to the source code to register the callout in the following block. As I've said, this is fine, 99% of the time, but I've run across a few occasions when adding tags to the source code (either in-line or an included file) can be a little problematic:
|
29
|
+
|
30
|
+
1. Restricted access to the source code: as a humble tech-writer, you might not have access to the included source code to add your own tags.
|
31
|
+
1. The source code has to remain runnable, but doesn't have a commenting mechanism that works well with Asciidoc (shell scripts amd json files spring to mind.)
|
32
|
+
|
33
|
+
## A possible Solution
|
34
|
+
|
35
|
+
And that's where this extension comes in: it adds support adding tags outside the source listing block, like this:
|
36
|
+
|
37
|
+
```asciidoc
|
38
|
+
[source,ruby]
|
39
|
+
----
|
40
|
+
require 'sinatra'
|
41
|
+
|
42
|
+
get '/hi' do
|
43
|
+
"Hello World!"
|
44
|
+
end
|
45
|
+
----
|
46
|
+
. Library import @3
|
47
|
+
. URL mapping @5
|
48
|
+
. Response block @5
|
49
|
+
-----
|
50
|
+
```
|
51
|
+
|
52
|
+
Rather than tagging the code, you add a location token at the end of a list item, which will then add the tag at the specified line number. Run the source text through Asciidoctor+extension, and it'll spit the same source block complete with callouts.
|
53
|
+
|
54
|
+
Two types of location token are supported:
|
55
|
+
|
56
|
+
@_number_
|
57
|
+
: This format takes a numeric value indicating the line in the source block where the callout should appear. The callouts will appear at the end of the line. Multiple callouts on the same line will have a single space between them.
|
58
|
+
|
59
|
+
|
60
|
+
@/_text_/
|
61
|
+
: The text between the two slashes will be used in a regex search. A callout will be placed at the end of the first matching line.
|
62
|
+
If you have a large listing then it may be preferable to use the text search rather than counting all the lines. It may also be preferable to use a smaller listing, as a long listing might mean that your description is a bit too general. +
|
63
|
+
Using the text search method means that the location of the callout will move with the line; handy if you're referencing a source file that might get the occasional tweak outside your control.
|
64
|
+
|
65
|
+
## Installation
|
66
|
+
|
67
|
+
Add this line to your application's Gemfile:
|
68
|
+
|
69
|
+
```ruby
|
70
|
+
gem 'asciidoctor-external-callout'
|
71
|
+
```
|
72
|
+
|
73
|
+
And then execute:
|
74
|
+
|
75
|
+
$ bundle install
|
76
|
+
|
77
|
+
Or install it yourself as:
|
78
|
+
|
79
|
+
$ gem install asciidoctor-external-callout
|
80
|
+
|
81
|
+
## Usage
|
82
|
+
|
83
|
+
TODO: Write usage instructions here
|
84
|
+
|
85
|
+
## Development
|
86
|
+
|
87
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
88
|
+
|
89
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
90
|
+
|
91
|
+
## License
|
92
|
+
|
93
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
94
|
+
|
95
|
+
## Code of Conduct
|
96
|
+
|
97
|
+
Everyone interacting in the Asciidoctor::External::Callout project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/asciidoctor-external-callout/blob/master/CODE_OF_CONDUCT.md).
|
data/Rakefile
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "lib/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.name = "asciidoctor-external-callout"
|
7
|
+
spec.version = Asciidoctor::External::Callout::VERSION
|
8
|
+
spec.authors = ["Ray Offiah"]
|
9
|
+
spec.email = ["clogs-wrench-0z@icloud.com"]
|
10
|
+
|
11
|
+
spec.summary = "Asciidoc extension for adding callouts without marking up the source listing block."
|
12
|
+
# spec.description = "TODO: Write a longer description or delete this line."
|
13
|
+
spec.homepage = "https://github.com/RayOffiah/asciidoctor-external-callout-ruby"
|
14
|
+
spec.license = "MIT"
|
15
|
+
spec.required_ruby_version = Gem::Requirement.new(">= 2.3.0")
|
16
|
+
|
17
|
+
spec.metadata["homepage_uri"] = spec.homepage
|
18
|
+
spec.metadata["source_code_uri"] = "https://github.com/RayOffiah/asciidoctor-external-callout-ruby"
|
19
|
+
spec.metadata["changelog_uri"] = "https://github.com/RayOffiah/asciidoctor-external-callout-ruby/blob/main/CHANGELOG.md"
|
20
|
+
|
21
|
+
# Specify which files should be added to the gem when it is released.
|
22
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
23
|
+
spec.files = Dir.chdir(File.expand_path(__dir__)) do
|
24
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{\A(?:test|spec|features)/}) }
|
25
|
+
end
|
26
|
+
spec.bindir = "exe"
|
27
|
+
spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
|
28
|
+
spec.require_paths = ["lib"]
|
29
|
+
|
30
|
+
# Uncomment to register a new dependency of your gem
|
31
|
+
# spec.add_dependency "example-gem", "~> 1.0"
|
32
|
+
|
33
|
+
# For more information and examples about making a new gem, checkout our
|
34
|
+
# guide at: https://bundler.io/guides/creating_gem.html
|
35
|
+
|
36
|
+
spec.add_dependency "asciidoctor", "~>2.0"
|
37
|
+
end
|
data/bin/console
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
require "bundler/setup"
|
5
|
+
require "asciidoctor/external/callout"
|
6
|
+
|
7
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
8
|
+
# with your gem easier. You can also use a different console, if you like.
|
9
|
+
|
10
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
11
|
+
# require "pry"
|
12
|
+
# Pry.start
|
13
|
+
|
14
|
+
require "irb"
|
15
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
@@ -0,0 +1,201 @@
|
|
1
|
+
require 'asciidoctor/extensions' unless RUBY_ENGINE == 'opal'
|
2
|
+
|
3
|
+
include Asciidoctor
|
4
|
+
|
5
|
+
# Treeprocessor that adds external callout marks to source code
|
6
|
+
#
|
7
|
+
# [source, ruby]
|
8
|
+
# ----
|
9
|
+
# puts 'Hello World'
|
10
|
+
# puts 'Hello again'
|
11
|
+
# ---
|
12
|
+
# 1. Saying hello @1
|
13
|
+
# 2. And again @2
|
14
|
+
# 3. Text search @/again/
|
15
|
+
|
16
|
+
Asciidoctor::Extensions::register do
|
17
|
+
|
18
|
+
LOCATION_TOKEN_RX = /@(\d+)|@\/([^\/]+?)\//
|
19
|
+
LOCATION_TOKEN_ARRAY_RX = /^(@\d+|@\/[^\/]+?\/)((\s+@\d+)|(\s+@\/[^\/]+?\/))*$/
|
20
|
+
|
21
|
+
tree_processor do
|
22
|
+
|
23
|
+
process do |document|
|
24
|
+
|
25
|
+
begin
|
26
|
+
# set the traverse_documents option to look for ordered lists
|
27
|
+
# The makes sure it's the right kind of list.
|
28
|
+
document.find_by context: :olist do |list|
|
29
|
+
|
30
|
+
if external_callout_list? list
|
31
|
+
|
32
|
+
owner_block = owning_block list
|
33
|
+
|
34
|
+
owner_block.subs.replace(owner_block.subs + [:callouts]).uniq
|
35
|
+
|
36
|
+
process_callouts(list, owner_block)
|
37
|
+
|
38
|
+
list.context = :colist
|
39
|
+
|
40
|
+
end
|
41
|
+
|
42
|
+
end
|
43
|
+
|
44
|
+
rescue => e
|
45
|
+
warn e.message
|
46
|
+
ensure
|
47
|
+
|
48
|
+
document
|
49
|
+
|
50
|
+
end
|
51
|
+
|
52
|
+
end
|
53
|
+
|
54
|
+
# Checks the format of the list
|
55
|
+
# to make sure it's a callout list we should be
|
56
|
+
# dealing with.
|
57
|
+
# We also won't want any nested lists.
|
58
|
+
def external_callout_list?(list)
|
59
|
+
|
60
|
+
list.blocks.all? do |x|
|
61
|
+
|
62
|
+
item_under_test = x.instance_variable_get(:@text)
|
63
|
+
location_token_index = item_under_test.index(LOCATION_TOKEN_RX)
|
64
|
+
|
65
|
+
# if we don't find the start of the list of location tokens, or the token is the first item
|
66
|
+
# then we don't need to carry on any further; this is not the list we are looking for.
|
67
|
+
return false if location_token_index == nil or location_token_index == 0
|
68
|
+
|
69
|
+
# just look at the string of location tokens.
|
70
|
+
location_tokens = item_under_test[location_token_index..-1].strip
|
71
|
+
location_tokens.match(LOCATION_TOKEN_ARRAY_RX) && x.blocks.empty?
|
72
|
+
|
73
|
+
end
|
74
|
+
|
75
|
+
end
|
76
|
+
|
77
|
+
# Have a look at the next level up
|
78
|
+
# to find the block that our CO list belongs to
|
79
|
+
def owning_block(list)
|
80
|
+
|
81
|
+
list_parent = list.parent
|
82
|
+
|
83
|
+
raise "There is no block above the callout list" if list_parent == nil
|
84
|
+
|
85
|
+
index_back = list_parent.blocks.index { |x| x == list }
|
86
|
+
|
87
|
+
# We should be able to find our own block, but in case we can't …
|
88
|
+
raise "Error – could not locate our ordered list" if index_back == nil
|
89
|
+
|
90
|
+
while index_back > 0
|
91
|
+
|
92
|
+
index_back = index_back - 1
|
93
|
+
|
94
|
+
# We have found our matching block
|
95
|
+
return list_parent.blocks[index_back] if list_parent.blocks[index_back].context == :listing
|
96
|
+
|
97
|
+
# We have hit another callout list, but there was no list block first.
|
98
|
+
# Assume we have an error
|
99
|
+
raise "Callout list found while seeking listing block" if list_parent.blocks[index_back].context == :colist
|
100
|
+
|
101
|
+
end
|
102
|
+
|
103
|
+
# If we didn't find a listing then this document has probably got
|
104
|
+
# bits missing.
|
105
|
+
raise "No listing found"
|
106
|
+
|
107
|
+
end
|
108
|
+
|
109
|
+
def find_list_index_for_item (list_item)
|
110
|
+
|
111
|
+
list = list_item.parent
|
112
|
+
|
113
|
+
list_numeral = 1
|
114
|
+
index_of_this_item = list.blocks.index { |x| x == list_item }
|
115
|
+
index_of_this_item.times { list_numeral = list_numeral.next }
|
116
|
+
list_numeral
|
117
|
+
|
118
|
+
end
|
119
|
+
|
120
|
+
def process_callouts(list, owner_block)
|
121
|
+
list.blocks.each do |list_item|
|
122
|
+
|
123
|
+
# Don't call `list_item.text` because this returns
|
124
|
+
# the string in a formatted form. We want the
|
125
|
+
# raw string, so go straight to the instance variable.
|
126
|
+
item = list_item.instance_variable_get(:@text)
|
127
|
+
|
128
|
+
# No need to test the matcher; we tested
|
129
|
+
# the whole block of items when we started
|
130
|
+
|
131
|
+
location_token_index = item.index(LOCATION_TOKEN_RX)
|
132
|
+
location_tokens = item[location_token_index..-1].strip
|
133
|
+
phrase = item[0..location_token_index - 1].strip
|
134
|
+
|
135
|
+
locations = location_tokens.scan(LOCATION_TOKEN_RX).flatten.compact
|
136
|
+
|
137
|
+
line_numbers = Set.new
|
138
|
+
|
139
|
+
locations.each do |location|
|
140
|
+
|
141
|
+
if location.is_numeric?
|
142
|
+
|
143
|
+
number = location.to_i
|
144
|
+
|
145
|
+
if number <= owner_block.lines.length
|
146
|
+
line_numbers << (number - 1)
|
147
|
+
else
|
148
|
+
warn "Out of range ==> #{number}"
|
149
|
+
end
|
150
|
+
|
151
|
+
else
|
152
|
+
|
153
|
+
# Must be a string matcher then
|
154
|
+
|
155
|
+
number = find_matching_lines(location, owner_block)
|
156
|
+
|
157
|
+
if number != nil
|
158
|
+
|
159
|
+
line_numbers << number
|
160
|
+
|
161
|
+
else
|
162
|
+
warn "Search term not found ==> #{location}"
|
163
|
+
end
|
164
|
+
|
165
|
+
end
|
166
|
+
|
167
|
+
end
|
168
|
+
|
169
|
+
line_numbers.each do |line_number|
|
170
|
+
|
171
|
+
callout = find_list_index_for_item(list_item)
|
172
|
+
owner_block.lines[line_number] += " <#{callout}>"
|
173
|
+
|
174
|
+
end
|
175
|
+
|
176
|
+
list_item.text = phrase
|
177
|
+
|
178
|
+
end
|
179
|
+
|
180
|
+
end
|
181
|
+
|
182
|
+
def find_matching_lines(search_string, owner_block)
|
183
|
+
|
184
|
+
owner_block.lines.index { |x| x.match(%r[#{search_string}]) }
|
185
|
+
|
186
|
+
end
|
187
|
+
|
188
|
+
class String
|
189
|
+
def is_numeric?
|
190
|
+
self.match(/^\d+$/)
|
191
|
+
end
|
192
|
+
end
|
193
|
+
|
194
|
+
end
|
195
|
+
|
196
|
+
end
|
197
|
+
|
198
|
+
|
199
|
+
|
200
|
+
|
201
|
+
|
data/lib/version.rb
ADDED
metadata
ADDED
@@ -0,0 +1,73 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: asciidoctor-external-callout
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.6.pre.beta7
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Ray Offiah
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2022-06-11 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: asciidoctor
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '2.0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '2.0'
|
27
|
+
description:
|
28
|
+
email:
|
29
|
+
- clogs-wrench-0z@icloud.com
|
30
|
+
executables: []
|
31
|
+
extensions: []
|
32
|
+
extra_rdoc_files: []
|
33
|
+
files:
|
34
|
+
- ".gitignore"
|
35
|
+
- CHANGELOG.md
|
36
|
+
- CODE_OF_CONDUCT.md
|
37
|
+
- Gemfile
|
38
|
+
- LICENSE.txt
|
39
|
+
- README.md
|
40
|
+
- Rakefile
|
41
|
+
- asciidoctor-external-callout.gemspec
|
42
|
+
- bin/console
|
43
|
+
- bin/setup
|
44
|
+
- lib/asciidoctor-external-callout.rb
|
45
|
+
- lib/version.rb
|
46
|
+
homepage: https://github.com/RayOffiah/asciidoctor-external-callout-ruby
|
47
|
+
licenses:
|
48
|
+
- MIT
|
49
|
+
metadata:
|
50
|
+
homepage_uri: https://github.com/RayOffiah/asciidoctor-external-callout-ruby
|
51
|
+
source_code_uri: https://github.com/RayOffiah/asciidoctor-external-callout-ruby
|
52
|
+
changelog_uri: https://github.com/RayOffiah/asciidoctor-external-callout-ruby/blob/main/CHANGELOG.md
|
53
|
+
post_install_message:
|
54
|
+
rdoc_options: []
|
55
|
+
require_paths:
|
56
|
+
- lib
|
57
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 2.3.0
|
62
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
63
|
+
requirements:
|
64
|
+
- - ">"
|
65
|
+
- !ruby/object:Gem::Version
|
66
|
+
version: 1.3.1
|
67
|
+
requirements: []
|
68
|
+
rubygems_version: 3.2.3
|
69
|
+
signing_key:
|
70
|
+
specification_version: 4
|
71
|
+
summary: Asciidoc extension for adding callouts without marking up the source listing
|
72
|
+
block.
|
73
|
+
test_files: []
|