code: func FormatText(w io.Writer, text []byte, line int, goSource bool, pattern string, selection Selection) {
  	var comments, highlights Selection
  	if goSource {
  		comments = commentSelection(text)
  	}
  	if pattern != "" {
  		highlights = regexpSelection(text, pattern)
  	}
  	if line >= 0 || comments != nil || highlights != nil || selection != nil {
  		var lineTag LinkWriter
  		if line >= 0 {
  			lineTag = func(w io.Writer, _ int, start bool) {
  				if start {
  					fmt.Fprintf(w, "<a id=\"L%d\"></a><span class=\"ln\">%6d</span>\t", line, line)
  					line++
  				}
  			}
  		}
  		FormatSelections(w, text, lineTag, lineSelection(text), selectionTag, comments, highlights, selection)
  	} else {
  		template.HTMLEscape(w, text)
  	}
  }
docs: // FormatText HTML-escapes text and writes it to w.
  // Consecutive text segments are wrapped in HTML spans (with tags as
  // defined by startTags and endTag) as follows:
  //
  //	- if line >= 0, line number (ln) spans are inserted before each line,
  //	  starting with the value of line
  //	- if the text is Go source, comments get the "comment" span class
  //	- each occurrence of the regular expression pattern gets the "highlight"
  //	  span class
  //	- text segments covered by selection get the "selection" span class
  //
  // Comments, highlights, and selections may overlap arbitrarily; the respective
  // HTML span classes are specified in the startTags variable.
  //