asciidoctor-lists 1.0.2 → 1.0.6

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: 938bd9392b0c912ac112ced82ebef41f9bbf0772215f7d1a5f5bc1b5fdfa0a9a
4
- data.tar.gz: 45b6506f0adfc38b3ae52077e26a1ee4f8d8bc3bcded0c8a99e1b98ac5696a77
3
+ metadata.gz: b9cdb3021862916257b05b2690050744ccbd65af0a872e94b67b1b2c13df5391
4
+ data.tar.gz: '059ab2fb1d8ce26edaa8768d98b9d8fea1e720e4212980a40127ab01bb0c8be3'
5
5
  SHA512:
6
- metadata.gz: 82b2c2dd1b85bd0d4b163110033c801f023795a2b42133639f5449541916fba75b66ab06ddef1c1e13de40c3b122d471fe7a1d2a9fe9c0b7fa893036fb965d87
7
- data.tar.gz: cd5ed1b976130783ba8ff6badc212eadc123d6a0906ea4575020e55fdebee56189a78015838d2ce001bbe63041997843aeb0bcff0b53027fe278e738b10704cf
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
- element_list::[element=image]
28
+ list-of::image[]
40
29
 
41
30
  === List of tables
42
- element_list::[element=table]
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
- MacroPlaceholder = Hash.new
8
+ ListMacroAttributes = Hash.new
9
9
 
10
- # Replaces tof::[] with ListOfFiguresMacroPlaceholder
11
- class ListOfFiguresMacro < ::Asciidoctor::Extensions::BlockMacroProcessor
10
+ # Replaces list-of::element[] with UUID and saves attributes in ListMacroPlaceholder
11
+ class ListMacro < ::Asciidoctor::Extensions::BlockMacroProcessor
12
12
  use_dsl
13
- named :element_list
14
- name_positional_attributes 'element'
13
+ named :"list-of"
14
+ name_positional_attributes 'enhanced_rendering'
15
15
 
16
- def process(parent, _target, attrs)
16
+ def process(parent, target, attrs)
17
17
  uuid = SecureRandom.uuid
18
- MacroPlaceholder[uuid] = {element: attrs['element']}
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 figures and replaced ListOfFiguresMacroPlaceholder with the list of figures
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 ListOfFiguresTreeprocessor < ::Asciidoctor::Extensions::Treeprocessor
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
- && (MacroPlaceholder.keys.include?(b.lines[0]))
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
- if element.caption
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
- references_asciidoc << %(xref:#{element.id}[#{element.caption}]#{element.title} +)
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::ListOfFiguresMacro
73
- tree_processor AsciidoctorLists::Asciidoctor::ListOfFiguresTreeprocessor
91
+ block_macro AsciidoctorLists::Asciidoctor::ListMacro
92
+ tree_processor AsciidoctorLists::Asciidoctor::ListTreeprocessor
74
93
  end
@@ -1,3 +1,3 @@
1
1
  module AsciidoctorLists
2
- VERSION = '1.0.2'
2
+ VERSION = '1.0.6'
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.2
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: 2021-12-16 00:00:00.000000000 Z
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: 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: []