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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 91209fcab613ba19c6917659a8b528c0390f35f421e8dca23a39863710ee7fbd
4
- data.tar.gz: 55c77e4a5a78fe415605ea94ce08c29531f7ca9550797fba8c96ddc7b1cd3d35
3
+ metadata.gz: b9cdb3021862916257b05b2690050744ccbd65af0a872e94b67b1b2c13df5391
4
+ data.tar.gz: '059ab2fb1d8ce26edaa8768d98b9d8fea1e720e4212980a40127ab01bb0c8be3'
5
5
  SHA512:
6
- metadata.gz: 1c66ea906439d1a2720fa32187d55e4f4e701c4e78e989b4f602787fbb1c68f71447960286bc90f9519018b7e39c267f3f50a37bee8b012e9edd6c3babf52d37
7
- data.tar.gz: 7efe24289f4e643c5f6d424463b0ceeb4222d1e41cdd4508ad53b04cc72428feeefc77629ebd5ea93f851da892b7cec57c51348be8b1bd08918ee7bf5c1067d3
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
- element_list::[element=image]
28
+ list-of::image[]
27
29
 
28
30
  === List of tables
29
- element_list::[element=table]
31
+ list-of::table[]
30
32
 
31
33
  === List of code snippets
32
- element_list::[element=listing]
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
- MacroPlaceholder = Hash.new
8
+ ListMacroAttributes = Hash.new
9
9
 
10
- # Replaces element_list::[element=...] 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"
15
14
  name_positional_attributes 'enhanced_rendering'
16
15
 
17
- def process(parent, _target, attrs)
16
+ def process(parent, target, attrs)
18
17
  uuid = SecureRandom.uuid
19
- MacroPlaceholder[uuid] = {
20
- element: attrs['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 figures and replaced ListOfFiguresMacroPlaceholder with the list of figures
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 ListOfFiguresTreeprocessor < ::Asciidoctor::Extensions::Treeprocessor
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
- && (MacroPlaceholder.keys.include?(b.lines[0]))
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 = MacroPlaceholder[block.lines[0]]
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: eval(element_name)).each do |element|
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::ListOfFiguresMacro
94
- tree_processor AsciidoctorLists::Asciidoctor::ListOfFiguresTreeprocessor
91
+ block_macro AsciidoctorLists::Asciidoctor::ListMacro
92
+ tree_processor AsciidoctorLists::Asciidoctor::ListTreeprocessor
95
93
  end
@@ -1,3 +1,3 @@
1
1
  module AsciidoctorLists
2
- VERSION = '1.0.5'
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.5
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-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