code: func replaceAllInChunks(chunks []formatChunk, re *regexp.Regexp, repl func(string) template.HTML) []formatChunk {
  	var ret []formatChunk
  	for _, chunk := range chunks {
  		if len(chunk.html) != 0 {
  			ret = append(ret, chunk)
  			continue
  		}
  		s := chunk.str
  		for len(s) != 0 {
  			loc := re.FindStringIndex(s)
  			if loc == nil {
  				ret = append(ret, formatChunk{str: s})
  				break
  			}
  			if loc[0] > 0 {
  				ret = append(ret, formatChunk{str: s[:loc[0]]})
  			}
  			html := repl(s[loc[0]:loc[1]])
  			ret = append(ret, formatChunk{html: html})
  			s = s[loc[1]:]
  		}
  	}
  	return ret
  }
docs: // replaceAllInChunks behaves like Regexp.ReplaceAllStringFunc, but it only
  // acts on unprocessed elements of chunks. Already-processed elements are left
  // as-is. repl returns trusted HTML, performing any necessary escaping.