Class: ActionTextSyntaxHighlighter::HighlightedCodeBlock

Inherits:
ApplicationRecord
  • Object
show all
Includes:
ActionText::Attachable, SupportedLanguages
Defined in:
app/models/action_text_syntax_highlighter/highlighted_code_block.rb

Defined Under Namespace

Modules: SupportedLanguages

Instance Method Summary collapse

Instance Method Details

#content_typeObject



24
25
26
# File 'app/models/action_text_syntax_highlighter/highlighted_code_block.rb', line 24

def content_type
  "text/html"
end

#highlighted_contentObject



18
19
20
21
22
# File 'app/models/action_text_syntax_highlighter/highlighted_code_block.rb', line 18

def highlighted_content
  return content unless lexer.present?

  highlighter.format(lexer.lex(content)).html_safe
end

#languageObject



14
15
16
# File 'app/models/action_text_syntax_highlighter/highlighted_code_block.rb', line 14

def language
  super || ""
end

#to_trix_content_attachment_partial_pathObject



28
29
30
# File 'app/models/action_text_syntax_highlighter/highlighted_code_block.rb', line 28

def to_trix_content_attachment_partial_path
  "action_text_syntax_highlighter/highlighted_code_blocks/editor"
end