= Block Macro Processor Extension Example :navtitle: Block Macro Processor Purpose:: Create a block macro named `gist` for embedding a gist. == sample-with-gist-macro.adoc [source,asciidoc] ---- .My Gist gist::123456[] ---- == GistBlockMacro [source,ruby] ---- require 'asciidoctor' require 'asciidoctor/extensions' class GistBlockMacro < Asciidoctor::Extensions::BlockMacroProcessor use_dsl named :gist def process parent, target, attrs title_html = (attrs.has_key? 'title') ? %(
#{attrs['title']}
\n) : nil html = %(
#{title_html}
) create_pass_block parent, html, attrs, subs: nil end end ---- == Usage [source,ruby] ---- Asciidoctor::Extensions.register do block_macro GistBlockMacro if document.basebackend? 'html' end Asciidoctor.convert_file 'sample-with-gist.adoc', safe: :safe ----