def _DLifyDescription(self, text):
    """Substitutes <DL> list into text based on patterns.

    Args:
      text: (string) the text to transform is assumed to be HTML escaped.

    Returns:
      Patterns that look like DLl lists will be replaced with HTML markup.
    """

    # Mark beginning of string with \n so we can catch things at the beginning
    # since we require a \n at the start of the first key.
    sentinel = '\n'

    # Look for pattern in the form \n<term> - <description>\n and extract
    # them out into a <dl> list.
    # Note that descriptions are normally HTML safe, but that check already
    # happened so this will actually produce HTML, which we want.

    # We'll partition the text by the DL lists.
    dl_partitions = DL_PATTERN_RE.split(sentinel + text)  # , 0, re.MULTILINE)
    dl_partitions[0] = dl_partitions[0][len(sentinel):]
    if len(dl_partitions) == 1:
      return text

    # We'll iterate over the partitions and attempt to split the DT/DD pairs.
    # If we cannot then the partition was between the lists in the split.
    # If we can, then we'll use that split to form the lines in the DL.
    result = []
    for partition in dl_partitions:
      dl = DT_DD_PATTERN_RE.split(partition)
      if len(dl) == 1:
        if dl[0]:  # skip empty strings
          result.append(dl[0])
          continue
      else:
        # we have a list in the form <seperator>, <dt value>, <dd value>
        # so iterate over those 3-group pairs and extract out the dt nd dd
        # values, adding them into a dl.
        # I'm calling these triples rather than 3-tupels because they are
        # not actually grouped as tuples.
        if result:
          result.append('\n')
        num_triples = len(dl) / 3
        if num_triples == 1:
          result.append(partition)
          continue

        runoff = ''  # Extra stuff past end of dl that regex cannot detect.
        result.append('<dl>\n')
        for i in range(num_triples):
          dt_value = dl[3 * i + 1].strip()
          dd_value = dl[3 * i + 2].strip()
          result.append('<dt>%s\n' % dt_value)
          if i < (num_triples - 1) or len(dd_value) < MAX_DD_LEN:
            # Make sure that dd's end with periods
            # but dont require dt's to.
            if not dd_value.endswith('.'):
              dd_value += '.'
            result.append('<dd>%s\n' % dd_value)
          else:
            period = dd_value.find('.')
            if period < 0:
              period = len(dd_value) - 1
            result.append('<dd>%s\n' % dd_value[0:period + 1])
            runoff = dd_value[period + 1:]

        result.append('</dl>\n')
        result.append(runoff)
    return ''.join(result)
dataset/ETHPy150Open google/apis-client-generator/src/googleapis/codegen/cpp_generator.py/CppGenerator._DLifyDescription/original