module Asciidoctor::Substitutors

def extract_attributes_from_text text, default_text = nil

attribute matches the attrlist, then the original text is returned.
If no attributes are detected aside from the first positional attribute, and the first positional
This method is used in cases when the attrlist can be mixed with the text of a macro.
def extract_attributes_from_text text, default_text = nil
  attrlist = (text.include? LF) ? (text.tr LF, ' ') : text
  if (resolved_text = (attrs = (AttributeList.new attrlist, self).parse)[1])
    # NOTE if resolved text remains unchanged, clear attributes and return unparsed text
    resolved_text == attrlist ? [text, attrs.clear] : [resolved_text, attrs]
  else
    [default_text, attrs]
  end
end