Skip to content

Commit

Permalink
Add support for "~~ ~~" (strikethrough)
Browse files Browse the repository at this point in the history
  • Loading branch information
hugmouse committed Jan 22, 2023
1 parent 96a987a commit 098db9a
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions syntax/convert.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ var italicsRegexp = regexp.MustCompile(`\*(.*?)\*`)
var tableLikeHeader = regexp.MustCompile(`^\|\s.+\s\|$`)
var tableSeparator = regexp.MustCompile(`(:?-.-+:?)`)
var codeRegexp = regexp.MustCompile("`(.*)`")
var strikethroughRegexp = regexp.MustCompile(`~~(.*?)~~`)

func clearUlMode(ulMode *bool, rv *[]string) {
if *ulMode {
Expand Down Expand Up @@ -81,12 +82,23 @@ func processCode(input string) string {
return input
}

func processStrikethrough(input string) string {
if strikethroughRegexp.MatchString(input) {
matches := strikethroughRegexp.FindAllStringSubmatch(input, -1)
for _, m := range matches {
input = strings.Replace(input, m[0], fmt.Sprintf("<s>%s</s>", m[1]), 1)
}
}
return input
}

// Returns a sanitized output
func processDecoration(input string) string {
sane := processLinks(input)
sane = processBold(sane)
sane = processItalics(sane)
sane = processCode(sane)
sane = processStrikethrough(sane)
return sane
}

Expand Down

0 comments on commit 098db9a

Please sign in to comment.