Asciidoctor PDF was not designed for this level of customization. However, it's possible to monkeypatch the converter to alter the behavior. I'll explain how to do that.
First, create a patched version of the converter in the file mypdfconverter.rb:
require 'asciidoctor-pdf'
module MyPdfConverter
def convert_listing node
code_background_color = @theme.code_background_color
@theme.code_background_color = '00ff00' if node.has_role? 'green'
super
@theme.code_background_color = code_background_color
end
end
class Asciidoctor::Pdf::Converter
prepend MyPdfConverter
end
Next, load this file when invoking asciidoctor-pdf:
asciidoctor-pdf -r ./mypdfconverter.rb document.adoc
You should see that the listing block with the role "green" now has a green background.
Note, the prepend command creates a hierarchy similar to extending the class, except creates the hierarchy in place.
Cheers,
-Dan