asciidoctor-lists 1.0.0 → 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: c74f8ace24bdf759b089f51c96bdd3e8762d89d8e57ab8ebfa383ba953f61df3
4
- data.tar.gz: acc23cc76d994d3d1c52e07c452e708aab39fa48518e998a3caec94a29fb4646
3
+ metadata.gz: 91209fcab613ba19c6917659a8b528c0390f35f421e8dca23a39863710ee7fbd
4
+ data.tar.gz: 55c77e4a5a78fe415605ea94ce08c29531f7ca9550797fba8c96ddc7b1cd3d35
5
5
  SHA512:
6
- metadata.gz: 7669ee5f782c0f0ac76a872733a762568e1587dc88a57b96f4aa338244211d4cf5073a2702dbd8c8309e3744dac906a742b17b56b3af33796a836e8b34fad9f7
7
- data.tar.gz: 59128a63e22e7af55146a9e19e94e0e112deb00c24b303bcd9953c4b2f6e1fc06c25a33851407b41fae6aceb4e19df79c0cd54590206a512da9ee8f28e43bd7c
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,12 +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
37
- element.id = SecureRandom.uuid
38
- references_asciidoc << %(xref:#{element.id}[#{element.caption}]#{element.title} +)
44
+ if element.caption or element.title
45
+ unless element.id
46
+ element.id = SecureRandom.uuid
47
+ end
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
39
62
  end
40
63
  end
41
64
 
@@ -1,3 +1,3 @@
1
1
  module AsciidoctorLists
2
- VERSION = '1.0.0'
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.0
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: 2021-11-08 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
@@ -24,7 +24,8 @@ dependencies:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: '2.0'
27
- description: Adds lists
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
- - MIT
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 Asciidoctor extension that adds bibtex integration to AsciiDoc
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: []