Skip to content

Commit

Permalink
cosmetics
Browse files Browse the repository at this point in the history
  • Loading branch information
peterschubert committed Apr 21, 2017
1 parent 8f19921 commit 317b9ed
Showing 1 changed file with 13 additions and 9 deletions.
22 changes: 13 additions & 9 deletions transformer.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,18 @@ import (
"strings"
)

var interactiveGraphicsRegex = regexp.MustCompile(`(?s)<div[\s]*class="interactive-comp">(.*?)</div>`)
var pullTagRegex = regexp.MustCompile(`(?s)<pull-quote(\s|>).*?</pull-quote>`)
var nbspRegex = regexp.MustCompile(`&nbsp;`)
var scriptRegex = regexp.MustCompile(`(?i)(?s)<script[^>]*>(.*?)</script>`)
var tagRegex = regexp.MustCompile(`<[^>]*>`)
var embedRegex = regexp.MustCompile(`embed\d+`)
var squaredCaptionRegex = regexp.MustCompile(`\[/?caption[^]]*]`)
var duplicateWhiteSpaceRegex = regexp.MustCompile(`\s+`)
const singleSpace = " "

var (
interactiveGraphicsRegex = regexp.MustCompile(`(?s)<div[\s]*class="interactive-comp">(.*?)</div>`)
pullTagRegex = regexp.MustCompile(`(?s)<pull-quote(\s|>).*?</pull-quote>`)
nbspRegex = regexp.MustCompile(`&nbsp;`)
scriptRegex = regexp.MustCompile(`(?i)(?s)<script[^>]*>(.*?)</script>`)
tagRegex = regexp.MustCompile(`<[^>]*>`)
embedRegex = regexp.MustCompile(`embed\d+`)
squaredCaptionRegex = regexp.MustCompile(`\[/?caption[^]]*]`)
duplicateWhiteSpaceRegex = regexp.MustCompile(`\s+`)
)

type textTransformer func(string) string

Expand Down Expand Up @@ -56,5 +60,5 @@ func squaredCaptionReplacer(input string) string {

}
func duplicateWhiteSpaceRemover(input string) string {
return duplicateWhiteSpaceRegex.ReplaceAllString(input, " ")
return duplicateWhiteSpaceRegex.ReplaceAllString(input, singleSpace)
}

0 comments on commit 317b9ed

Please sign in to comment.