Skip to content

Enabling replacements to work with windows style newlines #2

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 18, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions slack.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ func Slack(markdown string, options ...SlackConvertOptions) string {
// TODO: write proper regex
linkRegex := ".*"

// This makes sure all newlines are in the correct format, since this will otherwise cause issues with further replacements
markdown = strings.ReplaceAll(markdown, "\r\n", "\n")

// bold **TEXT** -> *TEXT*
re = regexp.MustCompile(`(?miU)((\*\*).+(\*\*))`)
markdown = re.ReplaceAllStringFunc(markdown, func(s string) string {
Expand Down
1 change: 1 addition & 0 deletions slack_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ func TestSlack(t *testing.T) {
`, Slack(`
### Features
`, optWithHeadlines))
assert.Equal("*Features*\n\nA feature", Slack("## Features\r\n\r\nA feature", optWithHeadlines))

msgSlackHeadlinesBold := `*<https://github.com/foo/boo/compare/v1.49.3...v1.50.0|1.50.0> (2015-02-12)*
*Features*
Expand Down