mirror of
https://github.com/cirosantilli/linux-kernel-module-cheat.git
synced 2026-01-23 02:05:57 +01:00
30 lines
620 B
Ruby
Executable File
30 lines
620 B
Ruby
Executable File
#!/usr/bin/env ruby
|
|
|
|
# https://cirosantilli.com/linux-kernel-module-cheat#asciidoctor-extract-header-ids
|
|
|
|
require 'asciidoctor'
|
|
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
|
|
end
|
|
process_blocks block if block.blocks?
|
|
end
|
|
end
|
|
end
|
|
|
|
Asciidoctor::Extensions.register do
|
|
treeprocessor Main
|
|
end
|
|
|
|
(Asciidoctor.load_file(ARGV[0])).convert
|