code: def computeSmartIndent(self, block, char):
          
          lineText = block.text()
          prevLineText = self._prevNonEmptyBlock(block).text()
  
          alignOnly = char == ''
  
          if alignOnly:
              # XML might be all in one line, in which case we want to break that up.
              tokens = re.split(r'>\s*<', lineText)
  
              if len(tokens) > 1:
  
                  prevIndent = self._lineIndent(prevLineText)
  
                  for index, newLine in enumerate(tokens):
                      if index > 0:
                          newLine = '<' + newLine
  
                      if index < len(tokens) - 1:
                          newLine = newLine + '>'
                      if re.match(r'^\s*</', newLine):
                          char = '/'
                      elif re.match(r'\\>[^<>]*$', newLine):
                          char = '>'
                      else:
                          char = '\n'
  
                      indentation = self.processChar(newLine, prevLineText, char)
                      newLine = indentation + newLine
  
                      tokens[index] = newLine
                      prevLineText = newLine;
  
                  self._qpart.lines[block.blockNumber()] =  '\n'.join(tokens)
                  return None
              else:  # no tokens, do not split line, just compute indent
                  if re.search(r'^\s*</', lineText):
                      char = '/'
                  elif re.search(r'>[^<>]*', lineText):
                      char = '>'
                  else:
                      char = '\n'
  
          return self.processChar(lineText, prevLineText, char)
docs: Compute indent for the block