Here’s the macro in use:
rml::blah[]
And here’s the equivalent in-place listing block:
require 'eg'
puts 'blah'
class MyListingBlockMacro < Asciidoctor::Extensions::BlockMacroProcessor | |
use_dsl | |
named :rml | |
def process(parent, target, attrs) | |
listing = create_listing_block(parent, "require 'eg'\n\nputs '#{target}'\n", attrs) | |
listing.style = 'source' | |
listing.set_attr 'language', 'ruby' | |
listing.commit_subs | |
$stderr.puts listing.content | |
listing | |
end | |
end | |
Asciidoctor::Extensions.register do | |
block_macro MyListingBlockMacro | |
end |
#!/bin/sh | |
asciidoctor -r ./listing-block.rb eg.adoc |