From c5b7a3dd9cd5fdbfce79ce81154f014d9adbec6d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ciro=20Santilli=20=E5=85=AD=E5=9B=9B=E4=BA=8B=E4=BB=B6=20?= =?UTF-8?q?=E6=B3=95=E8=BD=AE=E5=8A=9F?= Date: Wed, 24 Jul 2019 00:00:00 +0000 Subject: [PATCH] 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 --- README.adoc | 2 ++ asciidoctor/extract-header-ids | 13 ++++--------- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/README.adoc b/README.adoc index f6973e2..810811d 100644 --- a/README.adoc +++ b/README.adoc @@ -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. +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 diff --git a/asciidoctor/extract-header-ids b/asciidoctor/extract-header-ids index 94f5430..242514d 100755 --- a/asciidoctor/extract-header-ids +++ b/asciidoctor/extract-header-ids @@ -8,17 +8,12 @@ require 'asciidoctor/extensions' class Main < Asciidoctor::Extensions::TreeProcessor def process document return unless document.blocks? - process_blocks document - nil - end - - def process_blocks node - node.blocks.each_with_index do |block, i| - if block.context == :section - puts block.id + (document.find_by context: :section).each do |section| + if section.id + puts section.id end - process_blocks block if block.blocks? end + nil end end