asciidoctor/extract-header-ids: make work with definition lists

These were failing because the plugin was copied from an outdated documentation
and definition lists don't have the .context method:
https://github.com/asciidoctor/asciidoctor/issues/3363
This commit is contained in:
Ciro Santilli 六四事件 法轮功
2019-07-24 00:00:00 +00:00
parent 9252f53180
commit c5b7a3dd9c
2 changed files with 6 additions and 9 deletions

View File

@@ -16445,6 +16445,8 @@ explicitly-given
One application we have in mind for this is that as of 2.0.10 Asciidoctor does not warn on header ID collisions between auto-generated IDs: https://github.com/asciidoctor/asciidoctor/issues/3147 But this script doesn't solve that yet as it would require generating the section IDs without the `-N` suffix. Section generation happens at `Section.generate_id` in Asciidoctor code. One application we have in mind for this is that as of 2.0.10 Asciidoctor does not warn on header ID collisions between auto-generated IDs: https://github.com/asciidoctor/asciidoctor/issues/3147 But this script doesn't solve that yet as it would require generating the section IDs without the `-N` suffix. Section generation happens at `Section.generate_id` in Asciidoctor code.
Hastily hacked from: https://asciidoctor.org/docs/user-manual/#https://asciidoctor.org/docs/user-manual/#tree-processor-example until I noticed that that example had a bug at the time and so fixed it here: https://github.com/asciidoctor/asciidoctor/issues/3363
[[asciidoctor-link-target-up-rb]] [[asciidoctor-link-target-up-rb]]
=== asciidoctor/link-target-up.rb === asciidoctor/link-target-up.rb

View File

@@ -8,17 +8,12 @@ require 'asciidoctor/extensions'
class Main < Asciidoctor::Extensions::TreeProcessor class Main < Asciidoctor::Extensions::TreeProcessor
def process document def process document
return unless document.blocks? return unless document.blocks?
process_blocks document (document.find_by context: :section).each do |section|
nil if section.id
end puts section.id
def process_blocks node
node.blocks.each_with_index do |block, i|
if block.context == :section
puts block.id
end end
process_blocks block if block.blocks?
end end
nil
end end
end end