code: func ScanString(r io.RuneScanner) (string, error) {
  	ending, _, err := r.ReadRune()
  	if err != nil {
  		return "", errBadString
  	}
  
  	var buf bytes.Buffer
  	for {
  		ch0, _, err := r.ReadRune()
  		if ch0 == ending {
  			return buf.String(), nil
  		} else if err != nil || ch0 == '\n' {
  			return buf.String(), errBadString
  		} else if ch0 == '\\' {
  			// If the next character is an escape then write the escaped char.
  			// If it's not a valid escape then return an error.
  			ch1, _, _ := r.ReadRune()
  			if ch1 == 'n' {
  				_, _ = buf.WriteRune('\n')
  			} else if ch1 == '\\' {
  				_, _ = buf.WriteRune('\\')
  			} else if ch1 == '"' {
  				_, _ = buf.WriteRune('"')
  			} else if ch1 == '\'' {
  				_, _ = buf.WriteRune('\'')
  			} else {
  				return string(ch0) + string(ch1), errBadEscape
  			}
  		} else {
  			_, _ = buf.WriteRune(ch0)
  		}
  	}
  }
docs: // ScanString reads a quoted string from a rune reader.