diff --git a/formatter.go b/formatter.go index 037983f..b929ba5 100644 --- a/formatter.go +++ b/formatter.go @@ -27,15 +27,18 @@ func (fileContent *FileContent) FormatContent() string { var buffer []byte data := []byte(content) re := regexp.MustCompile(`!?\[([^\]*]*)\]\(([^ ]*)\)`) - //re := regexp.MustCompile(`(? %s %d: %s\n", match[2], i+1, match[1]) - buffer = append(buffer, link...) + if "!" == string(match[0][0:1]) { + link := fmt.Sprintf("=> %s %s\n", match[2], match[1]) + data = bytes.Replace(data, match[0], []byte(link), 1) + } else { + replaceWithIndex := append(match[1], fmt.Sprintf("[%d]", i+1)...) + data = bytes.Replace(data, match[0], replaceWithIndex, 1) + // append entry to buffer to be added later + link := fmt.Sprintf("=> %s %d: %s\n", match[2], i+1, match[1]) + buffer = append(buffer, link...) + } } // append links to that paragraph if len(buffer) > 0 {