Class: Coradoc::Html::Theme::ClassicRenderer
- Defined in:
- lib/coradoc/html/theme/classic_renderer.rb
Overview
Classic theme renderer
This renderer wraps the existing Coradoc HTML generation system. It maintains backward compatibility with the classic theme while following the new theme system architecture.
The classic theme is the default theme and provides the same output as the original Coradoc HTML converter.
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
-
#render ⇒ String
Render document to HTML.
-
#render_html5 ⇒ String
Render complete HTML5 document.
-
#supported_features ⇒ Array<Symbol>
Supported features for classic theme.
-
#template_renderer ⇒ Coradoc::Html::Renderer?
Get the template renderer when templates are enabled.
-
#use_templates? ⇒ Boolean
Check if template rendering is enabled.
Methods inherited from Base
#initialize, #supports?, #theme_name
Constructor Details
This class inherits a constructor from Coradoc::Html::Theme::Base
Instance Method Details
#render ⇒ String
Render document to HTML
Generates HTML body content from the document. Uses the HTML Converters directly to avoid circular dependency. When templates are enabled, uses the template renderer instead.
63 64 65 66 67 68 69 |
# File 'lib/coradoc/html/theme/classic_renderer.rb', line 63 def render return template_renderer.render(@document) if use_templates? && template_renderer # Use HTML converters directly to convert document model to HTML # This avoids circular dependency with Coradoc::Output::Html Coradoc::Html::Converters::Document.to_html(@document, @options) end |
#render_html5 ⇒ String
Render complete HTML5 document
Builds the complete HTML5 document with head, body, and all assets.
75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 |
# File 'lib/coradoc/html/theme/classic_renderer.rb', line 75 def render_html5 html_body = render lang = @options[:lang] || 'en' body_classes = build_body_classes # Apply section numbering if enabled final_body = if @options[:sectnums] apply_section_numbering(html_body) else html_body end # Build TOC if enabled toc_html = build_toc # Insert TOC based on placement final_body = insert_toc(final_body, toc_html) # Add theme toggle button if enabled = <<~HTML <!DOCTYPE html> <html lang="#{lang}"> <head> #{build_head_content} </head> <body#{body_classes}> #{final_body} #{} </body> </html> HTML end |
#supported_features ⇒ Array<Symbol>
Supported features for classic theme
44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/coradoc/html/theme/classic_renderer.rb', line 44 def supported_features features = %i[ dark_mode theme_toggle syntax_highlighting table_of_contents section_numbering ] features << :template_rendering if use_templates? features end |
#template_renderer ⇒ Coradoc::Html::Renderer?
Get the template renderer when templates are enabled
32 33 34 35 36 37 38 39 |
# File 'lib/coradoc/html/theme/classic_renderer.rb', line 32 def template_renderer return nil unless use_templates? @template_renderer ||= begin dirs = @options[:template_dirs] || global_template_dirs Renderer.new(template_dirs: dirs) end end |
#use_templates? ⇒ Boolean
Check if template rendering is enabled
25 26 27 |
# File 'lib/coradoc/html/theme/classic_renderer.rb', line 25 def use_templates? @options[:use_templates] == true end |