asciidoctor-lists 1.0.5 → 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 +5 -3
- data/lib/asciidoctor-lists/extensions.rb +14 -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: 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
@@ -10,6 +10,8 @@ An https://asciidoctor.org/[asciidoctor] extension that adds a list of figures,
|
|
10
10
|
|
11
11
|
*Pull Request are always welcome! :)*
|
12
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
|
+
|
13
15
|
== Install
|
14
16
|
[source,asciidoc]
|
15
17
|
----
|
@@ -23,13 +25,13 @@ gem install asciidoctor-lists
|
|
23
25
|
...
|
24
26
|
|
25
27
|
=== List of figures
|
26
|
-
|
28
|
+
list-of::image[]
|
27
29
|
|
28
30
|
=== List of tables
|
29
|
-
|
31
|
+
list-of::table[]
|
30
32
|
|
31
33
|
=== List of code snippets
|
32
|
-
|
34
|
+
list-of::listing[]
|
33
35
|
----
|
34
36
|
|
35
37
|
See link:samples/list-sample.adoc[]
|
@@ -5,41 +5,39 @@ 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 'element'
|
13
|
+
named :"list-of"
|
15
14
|
name_positional_attributes 'enhanced_rendering'
|
16
15
|
|
17
|
-
def process(parent,
|
16
|
+
def process(parent, target, attrs)
|
18
17
|
uuid = SecureRandom.uuid
|
19
|
-
|
20
|
-
element:
|
18
|
+
ListMacroAttributes[uuid] = {
|
19
|
+
element: target,
|
21
20
|
enhanced_rendering: attrs['enhanced_rendering']
|
22
21
|
}
|
23
22
|
create_paragraph parent, uuid, {}
|
24
23
|
end
|
25
24
|
end
|
26
|
-
# Searches for the
|
25
|
+
# Searches for the elements and replaced the UUIDs with the lists
|
27
26
|
# Inspired by https://github.com/asciidoctor/asciidoctor-bibtex/blob/master/lib/asciidoctor-bibtex/extensions.rb#L162
|
28
|
-
class
|
27
|
+
class ListTreeprocessor < ::Asciidoctor::Extensions::Treeprocessor
|
29
28
|
def process(document)
|
30
29
|
tof_blocks = document.find_by do |b|
|
31
30
|
# for fast search (since most searches shall fail)
|
32
31
|
(b.content_model == :simple) && (b.lines.size == 1) \
|
33
|
-
&& (
|
32
|
+
&& (ListMacroAttributes.keys.include?(b.lines[0]))
|
34
33
|
end
|
35
34
|
tof_blocks.each do |block|
|
36
35
|
references_asciidoc = []
|
37
36
|
|
38
|
-
params =
|
39
|
-
element_name = ":" + params[:element]
|
37
|
+
params = ListMacroAttributes[block.lines[0]]
|
40
38
|
enhanced_rendering = params[:enhanced_rendering]
|
41
39
|
|
42
|
-
document.find_by(context:
|
40
|
+
document.find_by(context: params[:element].to_sym).each do |element|
|
43
41
|
|
44
42
|
if element.caption or element.title
|
45
43
|
unless element.id
|
@@ -90,6 +88,6 @@ end
|
|
90
88
|
|
91
89
|
# Register the extensions to asciidoctor
|
92
90
|
Asciidoctor::Extensions.register do
|
93
|
-
block_macro AsciidoctorLists::Asciidoctor::
|
94
|
-
tree_processor AsciidoctorLists::Asciidoctor::
|
91
|
+
block_macro AsciidoctorLists::Asciidoctor::ListMacro
|
92
|
+
tree_processor AsciidoctorLists::Asciidoctor::ListTreeprocessor
|
95
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: 2022-03-
|
11
|
+
date: 2022-03-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: asciidoctor
|