asciidoctor-lists 1.0.6 → 1.0.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.adoc +8 -3
- data/lib/asciidoctor-lists/extensions.rb +24 -16
- data/lib/asciidoctor-lists/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ac525c818bc5254204312158fee82493102b5d61477c3d17e8f6d4a1b6049ebd
|
4
|
+
data.tar.gz: cc8dd13be8fbc15c04627733a0784c2963ddbad3689a2d180af25a15c2b1ef45
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c6c3a5fd8b0ff322ad297070ed7796d758e4ad0c4d5efb1e285272f12b7b0b9323e90417852f3196aa700cdedb4ae9b5213192598b6f456c59bc55cc6ce4056c
|
7
|
+
data.tar.gz: 8677b62b1edbf1e6024f91422e6ca8670eff647258ac1ced4d8db03f3af9749685f5c1179da3cfbe7dcdf36598b4233ac1ee7b7a7ccfcce2ab1c6d0c39fb2f37
|
data/README.adoc
CHANGED
@@ -8,7 +8,7 @@ image:https://img.shields.io/github/stars/Alwinator/asciidoctor-lists[Stars, lin
|
|
8
8
|
|
9
9
|
An https://asciidoctor.org/[asciidoctor] extension that adds a list of figures, a list of tables, or a list of anything you want!
|
10
10
|
|
11
|
-
*Pull
|
11
|
+
*Pull Requests are always welcome! :)*
|
12
12
|
|
13
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
14
|
|
@@ -41,15 +41,20 @@ image::img/sample.png[Sample,width=400]
|
|
41
41
|
|
42
42
|
== Parameters
|
43
43
|
=== element
|
44
|
-
Specifies the element
|
44
|
+
Specifies the element to be listed
|
45
45
|
|
46
46
|
Sample: link:samples/list-sample.adoc[]
|
47
47
|
|
48
48
|
=== enhanced_rendering (experimental)
|
49
|
-
Allows
|
49
|
+
Allows rendering links in the caption
|
50
50
|
|
51
51
|
Sample: link:samples/enhanced-rendering.adoc[]
|
52
52
|
|
53
|
+
=== hide_empty_section
|
54
|
+
Removes the section when no elements are found
|
55
|
+
|
56
|
+
Sample: link:samples/hide-if-empty-list-sample.adoc
|
57
|
+
|
53
58
|
== Docker
|
54
59
|
[source,bash]
|
55
60
|
----
|
@@ -12,12 +12,14 @@ module AsciidoctorLists
|
|
12
12
|
use_dsl
|
13
13
|
named :"list-of"
|
14
14
|
name_positional_attributes 'enhanced_rendering'
|
15
|
+
name_positional_attributes 'hide_empty_section'
|
15
16
|
|
16
17
|
def process(parent, target, attrs)
|
17
18
|
uuid = SecureRandom.uuid
|
18
19
|
ListMacroAttributes[uuid] = {
|
19
20
|
element: target,
|
20
|
-
enhanced_rendering: attrs['enhanced_rendering']
|
21
|
+
enhanced_rendering: attrs['enhanced_rendering'],
|
22
|
+
hide_empty_section: attrs['hide_empty_section']
|
21
23
|
}
|
22
24
|
create_paragraph parent, uuid, {}
|
23
25
|
end
|
@@ -36,28 +38,34 @@ module AsciidoctorLists
|
|
36
38
|
|
37
39
|
params = ListMacroAttributes[block.lines[0]]
|
38
40
|
enhanced_rendering = params[:enhanced_rendering]
|
41
|
+
hide_empty_section = params[:hide_empty_section]
|
39
42
|
|
40
|
-
document.find_by(context: params[:element].to_sym)
|
43
|
+
elements = document.find_by(context: params[:element].to_sym)
|
44
|
+
if elements.length > 0
|
45
|
+
elements.each do |element|
|
41
46
|
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
47
|
+
if element.caption or element.title
|
48
|
+
unless element.id
|
49
|
+
element.id = SecureRandom.uuid
|
50
|
+
end
|
46
51
|
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
+
if enhanced_rendering
|
53
|
+
if element.caption
|
54
|
+
references_asciidoc << %(xref:#{element.id}[#{element.caption}]#{element.instance_variable_get(:@title)} +)
|
55
|
+
else element.caption
|
56
|
+
references_asciidoc << %(xref:#{element.id}[#{element.instance_variable_get(:@title)}] +)
|
57
|
+
end
|
58
|
+
else
|
59
|
+
if element.caption
|
60
|
+
references_asciidoc << %(xref:#{element.id}[#{element.caption}]#{element.title} +)
|
61
|
+
else element.caption
|
62
|
+
references_asciidoc << %(xref:#{element.id}[#{element.title}] +)
|
52
63
|
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
64
|
end
|
59
65
|
end
|
60
66
|
end
|
67
|
+
elsif hide_empty_section
|
68
|
+
block.parent.parent.blocks.delete block.parent
|
61
69
|
end
|
62
70
|
|
63
71
|
block_index = block.parent.blocks.index do |b|
|
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.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alwin Schuster
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-04-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: asciidoctor
|