61 lines
1.3 KiB
Ruby
61 lines
1.3 KiB
Ruby
require 'asciidoctor/extensions'
|
|
|
|
class QuestionBlock < Asciidoctor::Extensions::BlockProcessor
|
|
use_dsl
|
|
named :QUESTION
|
|
on_context :example
|
|
|
|
def process parent, reader, attrs
|
|
attrs['name'] = 'question'
|
|
attrs['caption'] = 'Question'
|
|
admon = create_block parent, :admonition, nil, attrs, content_model: :compound
|
|
parse_content admon, reader
|
|
admon
|
|
end
|
|
end
|
|
|
|
class QuestionBlockCss < Asciidoctor::Extensions::DocinfoProcessor
|
|
use_dsl
|
|
|
|
def process doc
|
|
'<style>
|
|
.admonitionblock td.icon .icon-question:before{content:"\f128";color:#000}
|
|
</style>'
|
|
end
|
|
end
|
|
|
|
Asciidoctor::Extensions.register do
|
|
block QuestionBlock
|
|
docinfo_processor QuestionBlockCss
|
|
end
|
|
|
|
class AnswerBlock < Asciidoctor::Extensions::BlockProcessor
|
|
use_dsl
|
|
named :ANSWER
|
|
on_context :example
|
|
|
|
def process parent, reader, attrs
|
|
attrs['name'] = 'answer'
|
|
attrs['caption'] = 'Answer'
|
|
admon = create_block parent, :admonition, nil, attrs, content_model: :compound
|
|
parse_content admon, reader
|
|
admon
|
|
end
|
|
end
|
|
|
|
class AnswerBlockCss < Asciidoctor::Extensions::DocinfoProcessor
|
|
use_dsl
|
|
|
|
def process doc
|
|
'<style>
|
|
.admonitionblock td.icon .icon-answer:before{content:"\f0eb";color:#000}
|
|
</style>'
|
|
end
|
|
end
|
|
|
|
Asciidoctor::Extensions.register do
|
|
block AnswerBlock
|
|
docinfo_processor AnswerBlockCss
|
|
end
|
|
|