asciidoctor-lists 0.0.4 → 1.0.0

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: 0eaca66a3f98bc4f707f3a74344f8c6dac71c8d67d4058cc5d2252a526d311cf
4
- data.tar.gz: 4869f786e928690b0abdcbcd0f8b04817776de5ccc91db26a17c67ed782eac63
3
+ metadata.gz: c74f8ace24bdf759b089f51c96bdd3e8762d89d8e57ab8ebfa383ba953f61df3
4
+ data.tar.gz: acc23cc76d994d3d1c52e07c452e708aab39fa48518e998a3caec94a29fb4646
5
5
  SHA512:
6
- metadata.gz: 6693ed6dde5dea42bd91ddbb002f3e4885260af5dbb5ff4d5c9147660b2c3e03f153d3b227777ca01e4464a521f612797f43c60ae86323cc49cea3221fb8e838
7
- data.tar.gz: bfcd636f140795aaba03d0a44df02a44c32d5a5906c35c668808cdc9422ff94e1c2cbb03abbb3f8659685840ae5f0602a19c3b7116021d9a37b24ce28b4d5764
6
+ metadata.gz: 7669ee5f782c0f0ac76a872733a762568e1587dc88a57b96f4aa338244211d4cf5073a2702dbd8c8309e3744dac906a742b17b56b3af33796a836e8b34fad9f7
7
+ data.tar.gz: 59128a63e22e7af55146a9e19e94e0e112deb00c24b303bcd9953c4b2f6e1fc06c25a33851407b41fae6aceb4e19df79c0cd54590206a512da9ee8f28e43bd7c
data/README.adoc CHANGED
@@ -1,12 +1,12 @@
1
1
  = asciidoctor-lists
2
- :toc: macro
3
- :toclevels: 1
4
2
 
5
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]
6
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]
7
5
  image:https://img.shields.io/gem/v/asciidoctor-lists.svg[Latest Release, link=https://rubygems.org/gems/asciidoctor-lists]
8
6
 
9
- An https://asciidoctor.org/[asciidoctor] extension which adds a list of figures, list of tables or list of anything you want!
7
+ An https://asciidoctor.org/[asciidoctor] extension that adds a list of figures, a list of tables, or a list of anything you want!
8
+
9
+ *Pull Request are always welcome! :)*
10
10
 
11
11
  == Install
12
12
  [source,asciidoc]
@@ -46,14 +46,11 @@ element_list::[element=table]
46
46
  === Rendered
47
47
  image::img/sample.png[Sample,width=400]
48
48
 
49
- == What is planned next?
50
- * Link between image/table/element and list
51
-
52
49
  == Docker
53
50
  [source,bash]
54
51
  ----
55
52
  # Build container
56
- docker build --no-cache -t asciidoctor-lists .
53
+ docker build -t asciidoctor-lists .
57
54
  # Run Docker
58
55
  docker run -it --rm -v $(pwd):/work asciidoctor-lists
59
56
  # Build sample
@@ -61,6 +58,13 @@ asciidoctor-pdf -r asciidoctor-lists samples/list-sample.adoc
61
58
  ----
62
59
 
63
60
  == Dev setup
61
+ === Run
62
+ [source,bash]
63
+ ----
64
+ asciidoctor -r ./lib/asciidoctor-lists.rb samples/list-sample.adoc
65
+ ----
66
+
67
+ === Install Gem
64
68
  [source,bash]
65
69
  ----
66
70
  gem build asciidoctor-lists.gemspec
@@ -22,32 +22,33 @@ module AsciidoctorLists
22
22
  # Searches for the figures and replaced ListOfFiguresMacroPlaceholder with the list of figures
23
23
  # Inspired by https://github.com/asciidoctor/asciidoctor-bibtex/blob/master/lib/asciidoctor-bibtex/extensions.rb#L162
24
24
  class ListOfFiguresTreeprocessor < ::Asciidoctor::Extensions::Treeprocessor
25
- def process document
25
+ def process(document)
26
26
  tof_blocks = document.find_by do |b|
27
- # for fast search (since most searches shall fail)
28
- (b.content_model == :simple) && (b.lines.size == 1) \
27
+ # for fast search (since most searches shall fail)
28
+ (b.content_model == :simple) && (b.lines.size == 1) \
29
29
  && (MacroPlaceholder.keys.include?(b.lines[0]))
30
- end
31
- tof_blocks.each do |block|
32
- references_asciidoc = []
33
- element_name = ":" + MacroPlaceholder[block.lines[0]][:element]
34
- document.find_by(context: eval(element_name)).each do |element|
30
+ end
31
+ tof_blocks.each do |block|
32
+ references_asciidoc = []
33
+ element_name = ":" + MacroPlaceholder[block.lines[0]][:element]
34
+ document.find_by(context: eval(element_name)).each do |element|
35
35
 
36
- if element.caption
37
- references_asciidoc << %(#{element.caption}#{element.title} +)
38
- end
39
- end
36
+ if element.caption
37
+ element.id = SecureRandom.uuid
38
+ references_asciidoc << %(xref:#{element.id}[#{element.caption}]#{element.title} +)
39
+ end
40
+ end
40
41
 
41
- block_index = block.parent.blocks.index do |b|
42
- b == block
43
- end
44
- reference_blocks = parse_asciidoc block.parent, references_asciidoc
45
- reference_blocks.reverse.each do |b|
46
- block.parent.blocks.insert block_index, b
47
- end
48
- block.parent.blocks.delete_at block_index + reference_blocks.size
49
- end
50
- end
42
+ block_index = block.parent.blocks.index do |b|
43
+ b == block
44
+ end
45
+ reference_blocks = parse_asciidoc block.parent, references_asciidoc
46
+ reference_blocks.reverse.each do |b|
47
+ block.parent.blocks.insert block_index, b
48
+ end
49
+ block.parent.blocks.delete_at block_index + reference_blocks.size
50
+ end
51
+ end
51
52
  # This is an adapted version of Asciidoctor::Extension::parse_content,
52
53
  # where resultant blocks are returned as a list instead of attached to
53
54
  # the parent.
@@ -1,3 +1,3 @@
1
1
  module AsciidoctorLists
2
- VERSION = '0.0.4'
2
+ VERSION = '1.0.0'
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: 0.0.4
4
+ version: 1.0.0
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-04 00:00:00.000000000 Z
11
+ date: 2021-11-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: asciidoctor