module NoContent

This is for annotations which do not have any content, i.e. no enclosed text or other annotations. This is mostly relevant for stripping where this means that simply removing the annotation would leave an extra space.

Prepending this module to processors for these kinds of annotations prevents that.

Public Instance Methods

join_parts(prefix, text, suffix) click to toggle source
Calls superclass method
# File lib/ssmd/processors/concerns/no_content.rb, line 9
def join_parts(prefix, text, suffix)
  leading_ws = /\A\s/
  trailing_ws = /\s\z/

  if text == ""
    if prefix =~ trailing_ws && suffix =~ leading_ws
      prefix.sub(trailing_ws, "") + suffix
    elsif prefix == ""
      suffix.sub(leading_ws, "")
    elsif suffix == ""
      prefix.sub(trailing_ws, "")
    else
      super
    end
  else
    super
  end
end