Class: Coradoc::Markdown::Serializer::Serializers::Literal

Inherits:
ElementSerializer show all
Defined in:
lib/coradoc/markdown/serializer/serializers/literal.rb

Overview

Literal block: preformatted text with no language hint. Uses an unlabeled fenced code block so the content survives VitePress’s Vue template parser (4-space indented code blocks only work in specific contexts and leak ‘<` characters when not separated by blank lines).

Instance Method Summary collapse

Methods inherited from ElementSerializer

call, handles?, #handles?, handles_type, #handles_type

Instance Method Details

#call(element, _ctx) ⇒ Object



17
18
19
20
21
# File 'lib/coradoc/markdown/serializer/serializers/literal.rb', line 17

def call(element, _ctx)
  body = element.content.to_s
  body = body.chomp + "\n" unless body.end_with?("\n")
  "```\n#{body}```\n"
end