Class: Asciidoctor::Question::HTMLMultipleChoiceBlockProcessor

Inherits:
MultipleChoiceBlockProcessor show all
Defined in:
lib/asciidoctor-question/multiple_choice/extension.rb

Instance Method Summary collapse

Methods inherited from MultipleChoiceBlockProcessor

#process

Methods inherited from Extensions::BaseProcessor

inherited, #post_answers, #process_error, #process_error_push

Instance Method Details

#prepare_answer_lines(lines) ⇒ Object



86
87
88
89
90
91
92
93
94
95
# File 'lib/asciidoctor-question/multiple_choice/extension.rb', line 86

def prepare_answer_lines(lines)
  lines.map! do |answer|
    if answer =~ /^-\s?\[/ then
      answer.sub ']', '] +++ <span/> +++'
    else
      answer
    end
  end
  lines
end

#prepare_answers(answers_block, tag) ⇒ Object



97
98
99
100
101
102
103
104
105
106
# File 'lib/asciidoctor-question/multiple_choice/extension.rb', line 97

def prepare_answers(answers_block, tag)
  id = tag[:id]
  aid = -1
  answers_block.attributes['id'] = "answers_mc_#{id}"

  answers_block.blocks.each do |answer|
    answer.attributes['id'] = "answer_mc_#{id}_#{aid += 1}"
  end
  answers_block
end