asciidoctor-lists 1.0.3 → 1.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7eeaecee95733de1e2291f1047db511b54c07079d55f910857226b87d0d5e522
4
- data.tar.gz: b24e5796859234bb3da27c82b5081433c502970ab1d5146e9a51dbbf158338ee
3
+ metadata.gz: 91209fcab613ba19c6917659a8b528c0390f35f421e8dca23a39863710ee7fbd
4
+ data.tar.gz: 55c77e4a5a78fe415605ea94ce08c29531f7ca9550797fba8c96ddc7b1cd3d35
5
5
  SHA512:
6
- metadata.gz: 2dd9fa38be20f3c80cc53ee06146ad906121a3ed15617fd979d7a5fa856f453b1a068ecbe4509312d45d40cd8981a3e6b5a4dfda9a9d74a59671ef32f19e07db
7
- data.tar.gz: 4b4c5db93c285ddd289d1f6b5e48d0c369ad94c2ed1b47d17482da5e75891ade0dbec50a3733a5eb36420c4c59de2948dc446c5e90cbe3bf70234baaeb3ace4e
6
+ metadata.gz: 1c66ea906439d1a2720fa32187d55e4f4e701c4e78e989b4f602787fbb1c68f71447960286bc90f9519018b7e39c267f3f50a37bee8b012e9edd6c3babf52d37
7
+ data.tar.gz: 7efe24289f4e643c5f6d424463b0ceeb4222d1e41cdd4508ad53b04cc72428feeefc77629ebd5ea93f851da892b7cec57c51348be8b1bd08918ee7bf5c1067d3
data/README.adoc CHANGED
@@ -3,6 +3,8 @@
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
 
@@ -20,32 +22,32 @@ gem install asciidoctor-lists
20
22
  ----
21
23
  ...
22
24
 
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
25
  === List of figures
39
26
  element_list::[element=image]
40
27
 
41
28
  === List of tables
42
29
  element_list::[element=table]
43
30
 
31
+ === List of code snippets
32
+ element_list::[element=listing]
44
33
  ----
45
34
 
35
+ See link:samples/list-sample.adoc[]
36
+
46
37
  === Rendered
47
38
  image::img/sample.png[Sample,width=400]
48
39
 
40
+ == Parameters
41
+ === element
42
+ Specifies the element which should be listed
43
+
44
+ Sample: link:samples/list-sample.adoc[]
45
+
46
+ === enhanced_rendering (experimental)
47
+ Allows to render links in the caption
48
+
49
+ Sample: link:samples/enhanced-rendering.adoc[]
50
+
49
51
  == Docker
50
52
  [source,bash]
51
53
  ----
@@ -69,4 +71,4 @@ asciidoctor -r ./lib/asciidoctor-lists.rb samples/list-sample.adoc
69
71
  ----
70
72
  gem build asciidoctor-lists.gemspec
71
73
  gem install asciidoctor-lists-x.x.x.gem
72
- ----
74
+ ----
@@ -7,15 +7,19 @@ module AsciidoctorLists
7
7
 
8
8
  MacroPlaceholder = Hash.new
9
9
 
10
- # Replaces tof::[] with ListOfFiguresMacroPlaceholder
10
+ # Replaces element_list::[element=...] with ListOfFiguresMacroPlaceholder
11
11
  class ListOfFiguresMacro < ::Asciidoctor::Extensions::BlockMacroProcessor
12
12
  use_dsl
13
13
  named :element_list
14
14
  name_positional_attributes 'element'
15
+ name_positional_attributes 'enhanced_rendering'
15
16
 
16
17
  def process(parent, _target, attrs)
17
18
  uuid = SecureRandom.uuid
18
- MacroPlaceholder[uuid] = {element: attrs['element']}
19
+ MacroPlaceholder[uuid] = {
20
+ element: attrs['element'],
21
+ enhanced_rendering: attrs['enhanced_rendering']
22
+ }
19
23
  create_paragraph parent, uuid, {}
20
24
  end
21
25
  end
@@ -30,14 +34,31 @@ module AsciidoctorLists
30
34
  end
31
35
  tof_blocks.each do |block|
32
36
  references_asciidoc = []
33
- element_name = ":" + MacroPlaceholder[block.lines[0]][:element]
37
+
38
+ params = MacroPlaceholder[block.lines[0]]
39
+ element_name = ":" + params[:element]
40
+ enhanced_rendering = params[:enhanced_rendering]
41
+
34
42
  document.find_by(context: eval(element_name)).each do |element|
35
43
 
36
- if element.caption
44
+ if element.caption or element.title
37
45
  unless element.id
38
46
  element.id = SecureRandom.uuid
39
47
  end
40
- references_asciidoc << %(xref:#{element.id}[#{element.caption}]#{element.title} +)
48
+
49
+ if enhanced_rendering
50
+ if element.caption
51
+ references_asciidoc << %(xref:#{element.id}[#{element.caption}]#{element.instance_variable_get(:@title)} +)
52
+ else element.caption
53
+ references_asciidoc << %(xref:#{element.id}[#{element.instance_variable_get(:@title)}] +)
54
+ end
55
+ else
56
+ if element.caption
57
+ references_asciidoc << %(xref:#{element.id}[#{element.caption}]#{element.title} +)
58
+ else element.caption
59
+ references_asciidoc << %(xref:#{element.id}[#{element.title}] +)
60
+ end
61
+ end
41
62
  end
42
63
  end
43
64
 
@@ -1,3 +1,3 @@
1
1
  module AsciidoctorLists
2
- VERSION = '1.0.3'
2
+ VERSION = '1.0.5'
3
3
  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.3
4
+ version: 1.0.5
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-01-20 00:00:00.000000000 Z
11
+ date: 2022-03-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: asciidoctor
@@ -37,7 +37,7 @@ files:
37
37
  - lib/asciidoctor-lists/version.rb
38
38
  homepage: https://github.com/Alwinator/asciidoctor-lists
39
39
  licenses:
40
- - MIT
40
+ - MPL-2
41
41
  metadata: {}
42
42
  post_install_message:
43
43
  rdoc_options: []