-
Notifications
You must be signed in to change notification settings - Fork 68
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor
mdplain
package to use yuin/goldmark
library for markdow…
…n processing (#332) * Add test for `PlainMarkdown()` * Refactor `mdplain` package implementation to use `yuin/goldmark` library
- Loading branch information
Showing
7 changed files
with
325 additions
and
172 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
// Copyright (c) HashiCorp, Inc. | ||
// SPDX-License-Identifier: MPL-2.0 | ||
|
||
package mdplain | ||
|
||
import ( | ||
"os" | ||
"testing" | ||
|
||
"github.com/google/go-cmp/cmp" | ||
) | ||
|
||
func TestPlainMarkdown(t *testing.T) { | ||
t.Parallel() | ||
|
||
input, err := os.ReadFile("testdata/markdown.md") | ||
if err != nil { | ||
t.Errorf("Error opening file: %s", err.Error()) | ||
return | ||
} | ||
|
||
expectedFile, err := os.ReadFile("testdata/mdplain.txt") | ||
if err != nil { | ||
t.Errorf("Error opening file: %s", err.Error()) | ||
return | ||
} | ||
|
||
expected := string(expectedFile) | ||
actual, err := PlainMarkdown(string(input)) | ||
if err != nil { | ||
t.Errorf("Error rendering markdown: %s", err.Error()) | ||
return | ||
} | ||
if !cmp.Equal(expected, actual) { | ||
t.Errorf(cmp.Diff(expected, actual)) | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.