Class: KBuilder::Commands::CodeSyntaxHighlighterCommand

Inherits:
BaseCommand
  • Object
show all
Defined in:
lib/k_builder/commands/code_syntax_highlighter_command.rb

Overview

Run CodeSyntaxHighlighter against source code and produce a styled HTML representation

Alternatives to Highlighter-js could be carbon-now and ray.so

Instance Attribute Summary collapse

Attributes inherited from BaseCommand

#builder, #valid

Instance Method Summary collapse

Methods inherited from BaseCommand

#debug, #guard, #valid?

Constructor Details

#initialize(source_code, **opts) ⇒ CodeSyntaxHighlighterCommand

Returns a new instance of CodeSyntaxHighlighterCommand.



12
13
14
15
16
# File 'lib/k_builder/commands/code_syntax_highlighter_command.rb', line 12

def initialize(source_code, **opts)
  super(**opts)

  self.source_code = source_code
end

Instance Attribute Details

#formatted_codeObject (readonly)

Returns the value of attribute formatted_code.



10
11
12
# File 'lib/k_builder/commands/code_syntax_highlighter_command.rb', line 10

def formatted_code
  @formatted_code
end

#source_codeObject

Returns the value of attribute source_code.



9
10
11
# File 'lib/k_builder/commands/code_syntax_highlighter_command.rb', line 9

def source_code
  @source_code
end

Instance Method Details

#executeObject



18
19
20
21
22
# File 'lib/k_builder/commands/code_syntax_highlighter_command.rb', line 18

def execute
  return unless valid?

  run
end