Class: Neo4j::AsciidoctorExtensions::RevealJsSpeakerNotesAggregatorTreeProcessor
- Inherits:
-
Extensions::TreeProcessor
- Object
- Extensions::TreeProcessor
- Neo4j::AsciidoctorExtensions::RevealJsSpeakerNotesAggregatorTreeProcessor
- Defined in:
- lib/neo4j/asciidoctor/extensions/revealjs_speaker_notes_aggregator/extension.rb
Overview
A tree processor that aggregates multiple [notes] blocks in a section (slide).
Usage:
== Introduction
[.notes]
--
This is a speaker note.
--
Hello!
[.notes]
--
This is another speaker note.
--
Instance Method Summary collapse
Instance Method Details
#process(document) ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/neo4j/asciidoctor/extensions/revealjs_speaker_notes_aggregator/extension.rb', line 31 def process(document) if document.backend == 'revealjs' document.find_by(context: :section).each do |section| notes_blocks = section.blocks.select { |block| block.context == :open && block.roles.include?('notes') } next if notes_blocks.empty? agg_notes_block = Asciidoctor::Block.new(section, :open, attributes: { 'role' => 'notes' }) notes_blocks.each do |notes_block| section.blocks.delete(notes_block) notes_block.remove_role('notes') agg_notes_block << notes_block end section.blocks << agg_notes_block end end document end |