Class: Coradoc::Html::Spa

Inherits:
ConverterBase show all
Defined in:
lib/coradoc/html/spa.rb

Overview

SPA (Single Page Application) HTML converter

Converts Coradoc::CoreModel::StructuralElement to a modern Vue.js + Tailwind CSS single-page application with glass morphism aesthetics.

Features:

  • Vue.js 3 reactive components

  • Tailwind CSS styling

  • Glass morphism design

  • Dark/light theme toggle

  • Reading progress indicator

  • Sticky TOC sidebar

  • Copy code buttons

  • Smooth animations

Examples:

Basic usage

doc = Coradoc.parse_file('document.adoc')
html = Coradoc::Html::Spa.convert(doc)

With configuration

config = Coradoc::Html::Spa::Configuration.new(
  theme_variant: :glass,
  primary_color: '#6366f1',
  theme_toggle: true,
  reading_progress: true
)
html = Coradoc::Html::Spa.convert(doc, config)

Write to file

Coradoc::Html::Spa.to_file(doc, 'output.html', config)

Defined Under Namespace

Classes: Configuration

Instance Attribute Summary

Attributes inherited from ConverterBase

#config, #document

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from ConverterBase

convert, #converter_name, #initialize, #to_file, to_file

Constructor Details

This class inherits a constructor from Coradoc::Html::ConverterBase

Class Method Details

.processor_execute(input, options = {}) ⇒ Hash

Output processor interface: execute the conversion

Parameters:

  • input (Hash)

    Input from the converter (contains document)

  • options (Hash) (defaults to: {})

    Output options

Returns:

  • (Hash)

    Hash with nil => HTML output



300
301
302
303
304
305
306
# File 'lib/coradoc/html/spa.rb', line 300

def self.processor_execute(input, options = {})
  # Handle hash input from converter pipeline
  document = input.is_a?(Hash) ? (input[:document] || input.values.first) : input
  html = convert(document, options)
  # Return in format expected by converter (hash with filename => content)
  { nil => html }
end

.processor_idSymbol

Output processor interface: unique identifier

Returns:

  • (Symbol)

    Processor identifier



283
284
285
# File 'lib/coradoc/html/spa.rb', line 283

def self.processor_id
  :html_spa
end

.processor_match?(filename) ⇒ Boolean

Output processor interface: check if this processor handles the file

Parameters:

  • filename (String)

    Output filename

Returns:

  • (Boolean)

    true if this processor can handle the file



291
292
293
# File 'lib/coradoc/html/spa.rb', line 291

def self.processor_match?(filename)
  filename.downcase.end_with?('.html', '.htm')
end

Instance Method Details

#convertString

Convert document to SPA HTML

Returns:

  • (String)

    Complete HTML5 document with Vue.js application



253
254
255
256
257
258
259
260
# File 'lib/coradoc/html/spa.rb', line 253

def convert
  # Build options hash for ModernRenderer
  options = @config.to_renderer_options

  # Use ModernRenderer to generate HTML
  renderer = Html::Theme::ModernRenderer.new(@document, options)
  renderer.render_html5
end