original_docstring: Wrap instances of tag_value in text with <c.tag_type>tag_value</c> 
docstring: Wrap instances of tag_value in text with tag_value
docstring_tokens: Wrap instances of tag_value in text with tag_value
code: def wrap_tag(text, tag_value, tag_type):
      """Wrap instances of tag_value in text with <c.tag_type>tag_value</c> """
  
      # split out existing tags
      parts = TAG_RE_FULL.split(text)
  
      for i in range(len(parts)):
          # if it's already a tag, ignore
          if TAG_RE.match(parts[i]):
              continue
  
          # otherwise substitute for the tag
          # word boundaries (\b) don't work with macrons, because they're not
          # considered part of a word, but using lookaround is really slow.
          # We use word boundaries to make the match, but also capture the
          # previous and next characters and check they are not macron characters
  
          regex = r'(.?)\b(%s)\b(.?)' % tag_value
          # regex = r'(?<![%s])%s(?![%s])' % (MATCH_WORD, tag_value, MATCH_WORD)
  
          def sub(match):
              before, value, after = match.groups()
  
              # check the characters around it aren't vowels with macrons
              # return unchanged if so
              # NOTE before/after may be empty strings
              if before and WORD_RE.match(before) or \
                      after and WORD_RE.match(after):
                  return match.group()
  
              return '%s<c.%s>%s</c>%s' % (before, tag_type, value, after)
  
          parts[i] = re.sub(
              regex,
              sub,
              parts[i],
              flags=re.IGNORECASE)
  
      return ''.join(parts)
code_tokens: def wrap_tag ( text , tag_value , tag_type ) : parts = TAG_RE_FULL . split ( text ) for i in range ( len ( parts ) ) : if TAG_RE . match ( parts [ i ] ) : continue regex = r'(.?)\b(%s)\b(.?)' % tag_value def sub ( match ) : before , value , after = match . groups ( ) if before and WORD_RE . match ( before ) or after and WORD_RE . match ( after ) : return match . group ( ) return '%s<c.%s>%s</c>%s' % ( before , tag_type , value , after ) parts [ i ] = re . sub ( regex , sub , parts [ i ] , flags = re . IGNORECASE ) return '' . join ( parts )
short_docstring: Wrap instances of tag_value in text with <c.tag_type>tag_value</c>
short_docstring_tokens: Wrap instances of tag_value in text with <c . tag_type > tag_value< / c >
comment: """Wrap instances of tag_value in text with <c.tag_type>tag_value</c> """$SEP$# split out existing tags$SEP$# if it's already a tag, ignore$SEP$# otherwise substitute for the tag$SEP$# word boundaries (\b) don't work with macrons, because they're not$SEP$# considered part of a word, but using lookaround is really slow.$SEP$# We use word boundaries to make the match, but also capture the$SEP$# previous and next characters and check they are not macron characters$SEP$# regex = r'(?<![%s])%s(?![%s])' % (MATCH_WORD, tag_value, MATCH_WORD)$SEP$# check the characters around it aren't vowels with macrons$SEP$# return unchanged if so$SEP$# NOTE before/after may be empty strings