@@ -62,6 +62,67 @@ test('mdast-util-from-markdown', function (t) {
62
62
'should parse a paragraph'
63
63
)
64
64
65
+ t . equal (
66
+ fromMarkdown ( Buffer . from ( [ 0x62 , 0x72 , 0xc3 , 0xa1 , 0x76 , 0x6f ] ) ) . children [ 0 ]
67
+ . children [ 0 ] . value ,
68
+ 'brávo' ,
69
+ 'should support buffers'
70
+ )
71
+
72
+ t . equal (
73
+ fromMarkdown ( Buffer . from ( [ 0x62 , 0x72 , 0xc3 , 0xa1 , 0x76 , 0x6f ] ) , 'ascii' )
74
+ . children [ 0 ] . children [ 0 ] . value ,
75
+ 'brC!vo' ,
76
+ 'should support encoding'
77
+ )
78
+
79
+ t . deepEqual (
80
+ fromMarkdown ( 'a\nb' , {
81
+ mdastExtensions : [
82
+ {
83
+ // Unknown objects are used, but have no effect.
84
+ unknown : undefined ,
85
+ enter : { lineEnding : lineEndingAsHardBreakEnter } ,
86
+ exit : { lineEnding : lineEndingAsHardBreakExit }
87
+ }
88
+ ]
89
+ } ) . children [ 0 ] . children ,
90
+ [
91
+ {
92
+ type : 'text' ,
93
+ value : 'a' ,
94
+ position : {
95
+ start : { line : 1 , column : 1 , offset : 0 } ,
96
+ end : { line : 1 , column : 2 , offset : 1 }
97
+ }
98
+ } ,
99
+ {
100
+ type : 'break' ,
101
+ position : {
102
+ start : { line : 1 , column : 2 , offset : 1 } ,
103
+ end : { line : 2 , column : 1 , offset : 2 }
104
+ }
105
+ } ,
106
+ {
107
+ type : 'text' ,
108
+ value : 'b' ,
109
+ position : {
110
+ start : { line : 2 , column : 1 , offset : 2 } ,
111
+ end : { line : 2 , column : 2 , offset : 3 }
112
+ }
113
+ }
114
+ ] ,
115
+ 'should support extensions'
116
+ )
117
+
118
+ function lineEndingAsHardBreakEnter ( token ) {
119
+ this . enter ( { type : 'break' } , token )
120
+ }
121
+
122
+ function lineEndingAsHardBreakExit ( token ) {
123
+ this . exit ( token )
124
+ }
125
+
65
126
t . deepEqual (
66
127
fromMarkdown ( '<tel:123>' ) . children [ 0 ] ,
67
128
{
0 commit comments