def custom_caps(text)
      # $1 and $2 are excluded HTML tags, $3 is the part before the caps and $4 is the caps match
      text.gsub(%r{
          (<[^/][^>]*?>)|                                      # Ignore any opening tag, so we don't mess up attribute values
          (\s|&nbsp;|^|'|"|>|)                                 # Make sure our capture is preceded by whitespace or quotes
          ([A-Z\d](?:(\.|'|-|&|&amp;|&\#38;)?[A-Z\d][\.']?){1,}) # Capture capital words, with optional dots, numbers or ampersands in between
          (?!\w)                                               # ...which must not be followed by a word character.
        }x) do |str|
        tag, before, caps = $1, $2, $3

        # Do nothing with the contents if ignored tags, the inside of an opening HTML element
        # so we don't mess up attribute values, or if our capture is only digits.
        if tag || caps =~ /^\d+\.?$/
          str
        elsif $3 =~ /^[\d\.]+$/
          before + caps
        else
          before + '<span class="caps">' + caps + '</span>'
        end
      end
    end
def custom_caps(text)
      # $1 and $2 are excluded HTML tags, $3 is the part before the caps and $4 is the caps match
      text.gsub(%r{
          (<[^/][^>]*?>)|                                      # Ignore any opening tag, so we don't mess up attribute values
          (\s|&nbsp;|^|'|"|>|)                                 # Make sure our capture is preceded by whitespace or quotes
          ([A-Z\d](?:(\.|'|-|&|&amp;|&\#38;)?[A-Z\d][\.']?){1,}) # Capture capital words, with optional dots, numbers or ampersands in between
          (?!\w)                                               # ...which must not be followed by a word character.
        }x) do |str|
        tag, before, caps = $1, $2, $3

        # Do nothing with the contents if ignored tags, the inside of an opening HTML element
        # so we don't mess up attribute values, or if our capture is only digits.
        if tag || caps =~ /^\d+\.?$/
          str
        elsif $3 =~ /^[\d\.]+$/
          before + caps
        else
          before + '<span class="caps">' + caps + '</span>'
        end
      end
    end
custom modules to jekyll-typogrify
 surrounds two or more consecutive capital letters, perhaps with
 interspersed digits and periods in a span with a styled class.

 @param [String] text input text
 @return [String] input text with caps wrapped