Class: Neo4j::AsciidoctorExtensions::RevealJsLinearNavigationTreeProcessor

Inherits:
Extensions::TreeProcessor
  • Object
show all
Defined in:
lib/neo4j/asciidoctor/extensions/revealjs_linear_navigation/extension.rb

Overview

A tree process that “flatten” a reveal.js presentation to use a linear navigation. By default, the reveal.js converter will use a vertical navigation for the second levels of section titles (and below). This extension will effectively prevent that by using only first level section titles.

Instance Method Summary collapse

Instance Method Details

#process(document) ⇒ Object



17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/neo4j/asciidoctor/extensions/revealjs_linear_navigation/extension.rb', line 17

def process(document)
  if document.backend == 'revealjs'
    document.find_by(context: :section) { |section| section.level > 1 }.reverse_each do |section|
      section.parent.blocks.delete(section)
      parent_section = section.parent
      parent_section = parent_section.parent while parent_section.parent && parent_section.parent.context == :section
      section.level = 1
      document.blocks.insert(parent_section.index + 1, section)
    end
  end
  document
end