-
Notifications
You must be signed in to change notification settings - Fork 0
/
extension_test.go
40 lines (37 loc) · 1.38 KB
/
extension_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
package media
import (
"github.com/stretchr/testify/assert"
"github.com/yuin/goldmark"
"os"
"testing"
)
func TestExtensionWithDefaults(t *testing.T) {
md := goldmark.New(goldmark.WithExtensions(
WithDefaults(),
))
src := []byte(`
!v[Train火车](https://upload.wikimedia.org/wikipedia/commons/5/5d/KkStB_Class_310.webm)
!a[THE Anthem国歌](https://upload.wikimedia.org/wikipedia/commons/transcoded/5/59/State_Anthem_of_the_Soviet_Union_%281984%29.wav/State_Anthem_of_the_Soviet_Union_%281984%29.wav.mp3)
!p[Blossoms花朵](https://upload.wikimedia.org/wikipedia/commons/b/b8/Blossoming-Blackberries-P1400842_%2837396534302%29.jpg)
`)
err := md.Convert(src, os.Stdout)
assert.NoError(t, err)
}
func TestExtensionWithOptions(t *testing.T) {
md := goldmark.New(goldmark.WithExtensions(
WithOptions(Options{
MediaControls: true,
MediaAutoplay: true,
MediaLoop: true,
MediaMuted: true,
MediaPreload: "",
}),
))
src := []byte(`
!v[Train](https://upload.wikimedia.org/wikipedia/commons/5/5d/KkStB_Class_310.webm)
!a[THE Anthem](https://upload.wikimedia.org/wikipedia/commons/transcoded/5/59/State_Anthem_of_the_Soviet_Union_%281984%29.wav/State_Anthem_of_the_Soviet_Union_%281984%29.wav.mp3)
!p[Blossoms](https://upload.wikimedia.org/wikipedia/commons/b/b8/Blossoming-Blackberries-P1400842_%2837396534302%29.jpg)
`)
err := md.Convert(src, os.Stdout)
assert.NoError(t, err)
}