parseParams parses the parameters from a single line. The string without parameters is returned, along with the typed ItemParams.
(s string)
| 107 | // The string without parameters is returned, along with the |
| 108 | // typed ItemParams. |
| 109 | func parseParams(s string) (string, ItemParams, error) { |
| 110 | params := defaultParams |
| 111 | pipeIndex := strings.Index(s, "|") |
| 112 | if pipeIndex < 0 { // no params |
| 113 | return s, params, nil |
| 114 | } |
| 115 | text := s[:pipeIndex] |
| 116 | paramStr := s[pipeIndex+1:] |
| 117 | if err := parseParamStr(¶ms, paramStr); err != nil { |
| 118 | return text, params, err |
| 119 | } |
| 120 | return text, params, nil |
| 121 | } |
| 122 | |
| 123 | // parseParamStr parses the parameter string, updating params. |
| 124 | func parseParamStr(params *ItemParams, s string) error { |