(section []byte)
| 251 | } |
| 252 | |
| 253 | func extractSectionName(section []byte) (string, error) { |
| 254 | scanner := bufio.NewScanner(bytes.NewReader(section)) |
| 255 | if !scanner.Scan() { |
| 256 | return "", xerrors.Errorf("section header was expected") |
| 257 | } |
| 258 | |
| 259 | header := scanner.Text()[2:] // Skip #<space> |
| 260 | return strings.TrimSpace(header), nil |
| 261 | } |
| 262 | |
| 263 | func toMdFilename(sectionName string) string { |
| 264 | return nonAlphanumericRegex.ReplaceAllLiteralString(strings.ReplaceAll(strings.ToLower(sectionName), " ", ""), "-") + ".md" |