Asciidoctor::Extensions.register do postprocessor do process do |doc, output| output = output.sub(/(]*>)/, '\1
') output = output.sub('', '
') # Comment out toggle button - TOC should always be visible # output = output.sub(/(]*id="toc"[^>]*>)/m, '\1') output = output.sub(/(]*id="footer"[^>]*>)/m, '\1') script_tag = <<~SCRIPT SCRIPT output = output.sub('', "#{script_tag}") output end end end