Class: Coradoc::Markdown::Serializer::Serializers::Comment

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

Overview

Comments are editorial annotations, not document content. The Markdown Serialization Spec (§Comments) requires that comments be suppressed by default.

Behavior:

suppress_comments == true  → '' (no output)
suppress_comments == false → '<!-- text -->'

Instance Method Summary collapse

Methods inherited from ElementSerializer

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

Instance Method Details

#call(element, ctx) ⇒ Object



19
20
21
22
23
24
25
26
# File 'lib/coradoc/markdown/serializer/serializers/comment.rb', line 19

def call(element, ctx)
  return '' if ctx.config.suppress_comments

  text = element.text.to_s.strip
  return '<!---->' if text.empty?

  "<!-- #{text} -->"
end