asciidoctor-lists 1.0.2 → 1.0.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.adoc +22 -18
- data/lib/asciidoctor-lists/extensions.rb +35 -16
- data/lib/asciidoctor-lists/version.rb +1 -1
- metadata +7 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b9cdb3021862916257b05b2690050744ccbd65af0a872e94b67b1b2c13df5391
|
4
|
+
data.tar.gz: '059ab2fb1d8ce26edaa8768d98b9d8fea1e720e4212980a40127ab01bb0c8be3'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e3e0da424fe5aa1c14338ee7bc92c3af8e088883494845381b9ef66e46447a962ad0397626aa50f6ee0f57b6410679ce76697dead5f9015d4c6337a9c463abf5
|
7
|
+
data.tar.gz: 15770d886027bd2a790839a07993d35d7705472221decee9213e59feee2cd43fd58f5443098ff3bf0009cad06b06686388cdaa7d9eb6be2dd5afed23475b0427
|
data/README.adoc
CHANGED
@@ -3,11 +3,15 @@
|
|
3
3
|
image:https://github.com/Alwinator/asciidoctor-lists/actions/workflows/test.yml/badge.svg[Test, link=https://github.com/Alwinator/asciidoctor-lists/actions/workflows/test.yml]
|
4
4
|
image:https://github.com/Alwinator/asciidoctor-lists/actions/workflows/publish_gem.yml/badge.svg[Build, link=https://github.com/Alwinator/asciidoctor-lists/actions/workflows/publish_gem.yml]
|
5
5
|
image:https://img.shields.io/gem/v/asciidoctor-lists.svg[Latest Release, link=https://rubygems.org/gems/asciidoctor-lists]
|
6
|
+
image:https://img.shields.io/github/stars/Alwinator/asciidoctor-lists[Stars, link=https://github.com/Alwinator/asciidoctor-lists]
|
7
|
+
|
6
8
|
|
7
9
|
An https://asciidoctor.org/[asciidoctor] extension that adds a list of figures, a list of tables, or a list of anything you want!
|
8
10
|
|
9
11
|
*Pull Request are always welcome! :)*
|
10
12
|
|
13
|
+
IMPORTANT: With version 1.0.6 the syntax was changed from `element_list::[element=image]` to `list-of::image[]` to make it more intuitive.
|
14
|
+
|
11
15
|
== Install
|
12
16
|
[source,asciidoc]
|
13
17
|
----
|
@@ -20,32 +24,32 @@ gem install asciidoctor-lists
|
|
20
24
|
----
|
21
25
|
...
|
22
26
|
|
23
|
-
.And this is the second one
|
24
|
-
|===
|
25
|
-
|Column 1, Header Row |Column 2, Header Row
|
26
|
-
|
27
|
-
|Cell in column 1, row 1
|
28
|
-
|Cell in column 2, row 1
|
29
|
-
|
30
|
-
|Cell in column 1, row 2
|
31
|
-
|Cell in column 2, row 2
|
32
|
-
|===
|
33
|
-
|
34
|
-
|
35
|
-
.Another wikipedia SVG image
|
36
|
-
image::https://upload.wikimedia.org/wikipedia/commons/thumb/4/4f/SVG_Logo.svg/400px-SVG_Logo.svg.png[SVG,100,100]
|
37
|
-
|
38
27
|
=== List of figures
|
39
|
-
|
28
|
+
list-of::image[]
|
40
29
|
|
41
30
|
=== List of tables
|
42
|
-
|
31
|
+
list-of::table[]
|
43
32
|
|
33
|
+
=== List of code snippets
|
34
|
+
list-of::listing[]
|
44
35
|
----
|
45
36
|
|
37
|
+
See link:samples/list-sample.adoc[]
|
38
|
+
|
46
39
|
=== Rendered
|
47
40
|
image::img/sample.png[Sample,width=400]
|
48
41
|
|
42
|
+
== Parameters
|
43
|
+
=== element
|
44
|
+
Specifies the element which should be listed
|
45
|
+
|
46
|
+
Sample: link:samples/list-sample.adoc[]
|
47
|
+
|
48
|
+
=== enhanced_rendering (experimental)
|
49
|
+
Allows to render links in the caption
|
50
|
+
|
51
|
+
Sample: link:samples/enhanced-rendering.adoc[]
|
52
|
+
|
49
53
|
== Docker
|
50
54
|
[source,bash]
|
51
55
|
----
|
@@ -69,4 +73,4 @@ asciidoctor -r ./lib/asciidoctor-lists.rb samples/list-sample.adoc
|
|
69
73
|
----
|
70
74
|
gem build asciidoctor-lists.gemspec
|
71
75
|
gem install asciidoctor-lists-x.x.x.gem
|
72
|
-
----
|
76
|
+
----
|
@@ -5,39 +5,58 @@ require 'securerandom'
|
|
5
5
|
module AsciidoctorLists
|
6
6
|
module Asciidoctor
|
7
7
|
|
8
|
-
|
8
|
+
ListMacroAttributes = Hash.new
|
9
9
|
|
10
|
-
# Replaces
|
11
|
-
class
|
10
|
+
# Replaces list-of::element[] with UUID and saves attributes in ListMacroPlaceholder
|
11
|
+
class ListMacro < ::Asciidoctor::Extensions::BlockMacroProcessor
|
12
12
|
use_dsl
|
13
|
-
named :
|
14
|
-
name_positional_attributes '
|
13
|
+
named :"list-of"
|
14
|
+
name_positional_attributes 'enhanced_rendering'
|
15
15
|
|
16
|
-
def process(parent,
|
16
|
+
def process(parent, target, attrs)
|
17
17
|
uuid = SecureRandom.uuid
|
18
|
-
|
18
|
+
ListMacroAttributes[uuid] = {
|
19
|
+
element: target,
|
20
|
+
enhanced_rendering: attrs['enhanced_rendering']
|
21
|
+
}
|
19
22
|
create_paragraph parent, uuid, {}
|
20
23
|
end
|
21
24
|
end
|
22
|
-
# Searches for the
|
25
|
+
# Searches for the elements and replaced the UUIDs with the lists
|
23
26
|
# Inspired by https://github.com/asciidoctor/asciidoctor-bibtex/blob/master/lib/asciidoctor-bibtex/extensions.rb#L162
|
24
|
-
class
|
27
|
+
class ListTreeprocessor < ::Asciidoctor::Extensions::Treeprocessor
|
25
28
|
def process(document)
|
26
29
|
tof_blocks = document.find_by do |b|
|
27
30
|
# for fast search (since most searches shall fail)
|
28
31
|
(b.content_model == :simple) && (b.lines.size == 1) \
|
29
|
-
&& (
|
32
|
+
&& (ListMacroAttributes.keys.include?(b.lines[0]))
|
30
33
|
end
|
31
34
|
tof_blocks.each do |block|
|
32
35
|
references_asciidoc = []
|
33
|
-
element_name = ":" + MacroPlaceholder[block.lines[0]][:element]
|
34
|
-
document.find_by(context: eval(element_name)).each do |element|
|
35
36
|
|
36
|
-
|
37
|
+
params = ListMacroAttributes[block.lines[0]]
|
38
|
+
enhanced_rendering = params[:enhanced_rendering]
|
39
|
+
|
40
|
+
document.find_by(context: params[:element].to_sym).each do |element|
|
41
|
+
|
42
|
+
if element.caption or element.title
|
37
43
|
unless element.id
|
38
44
|
element.id = SecureRandom.uuid
|
39
45
|
end
|
40
|
-
|
46
|
+
|
47
|
+
if enhanced_rendering
|
48
|
+
if element.caption
|
49
|
+
references_asciidoc << %(xref:#{element.id}[#{element.caption}]#{element.instance_variable_get(:@title)} +)
|
50
|
+
else element.caption
|
51
|
+
references_asciidoc << %(xref:#{element.id}[#{element.instance_variable_get(:@title)}] +)
|
52
|
+
end
|
53
|
+
else
|
54
|
+
if element.caption
|
55
|
+
references_asciidoc << %(xref:#{element.id}[#{element.caption}]#{element.title} +)
|
56
|
+
else element.caption
|
57
|
+
references_asciidoc << %(xref:#{element.id}[#{element.title}] +)
|
58
|
+
end
|
59
|
+
end
|
41
60
|
end
|
42
61
|
end
|
43
62
|
|
@@ -69,6 +88,6 @@ end
|
|
69
88
|
|
70
89
|
# Register the extensions to asciidoctor
|
71
90
|
Asciidoctor::Extensions.register do
|
72
|
-
block_macro AsciidoctorLists::Asciidoctor::
|
73
|
-
tree_processor AsciidoctorLists::Asciidoctor::
|
91
|
+
block_macro AsciidoctorLists::Asciidoctor::ListMacro
|
92
|
+
tree_processor AsciidoctorLists::Asciidoctor::ListTreeprocessor
|
74
93
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: asciidoctor-lists
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alwin Schuster
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-03-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: asciidoctor
|
@@ -24,7 +24,8 @@ dependencies:
|
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '2.0'
|
27
|
-
description:
|
27
|
+
description: An asciidoctor extension that adds a list of figures, a list of tables,
|
28
|
+
or a list of anything you want!
|
28
29
|
email:
|
29
30
|
executables: []
|
30
31
|
extensions: []
|
@@ -36,7 +37,7 @@ files:
|
|
36
37
|
- lib/asciidoctor-lists/version.rb
|
37
38
|
homepage: https://github.com/Alwinator/asciidoctor-lists
|
38
39
|
licenses:
|
39
|
-
-
|
40
|
+
- MPL-2
|
40
41
|
metadata: {}
|
41
42
|
post_install_message:
|
42
43
|
rdoc_options: []
|
@@ -56,5 +57,6 @@ requirements: []
|
|
56
57
|
rubygems_version: 3.1.2
|
57
58
|
signing_key:
|
58
59
|
specification_version: 4
|
59
|
-
summary: An
|
60
|
+
summary: An asciidoctor extension that adds a list of figures, a list of tables, or
|
61
|
+
a list of anything you want!
|
60
62
|
test_files: []
|