@@ -1646,8 +1646,8 @@ test('code (text)', (t) => {
1646
1646
)
1647
1647
1648
1648
t . equal (
1649
- to ( { type : 'inlineCode' , value : 'a\n-' } ) ,
1650
- '`a -`\n' ,
1649
+ to ( { type : 'inlineCode' , value : 'a\n- b ' } ) ,
1650
+ '`a - b `\n' ,
1651
1651
'should prevent breaking out of code (-)'
1652
1652
)
1653
1653
@@ -1664,14 +1664,14 @@ test('code (text)', (t) => {
1664
1664
)
1665
1665
1666
1666
t . equal (
1667
- to ( { type : 'inlineCode' , value : 'a\r-' } ) ,
1668
- '`a -`\n' ,
1667
+ to ( { type : 'inlineCode' , value : 'a\r- b ' } ) ,
1668
+ '`a - b `\n' ,
1669
1669
'should prevent breaking out of code (cr)'
1670
1670
)
1671
1671
1672
1672
t . equal (
1673
- to ( { type : 'inlineCode' , value : 'a\r\n-' } ) ,
1674
- '`a -`\n' ,
1673
+ to ( { type : 'inlineCode' , value : 'a\r\n- b ' } ) ,
1674
+ '`a - b `\n' ,
1675
1675
'should prevent breaking out of code (crlf)'
1676
1676
)
1677
1677
@@ -3031,12 +3031,6 @@ test('escape', (t) => {
3031
3031
'should escape what would otherwise be a character escape'
3032
3032
)
3033
3033
3034
- t . equal (
3035
- to ( { type : 'paragraph' , children : [ { type : 'text' , value : '+a' } ] } ) ,
3036
- '+a\n' ,
3037
- 'should not escape a `+` if it is not followed by a whitespace'
3038
- )
3039
-
3040
3034
t . equal (
3041
3035
to ( {
3042
3036
type : 'paragraph' ,
@@ -3171,18 +3165,50 @@ test('escape', (t) => {
3171
3165
'should escape what would otherwise be a list item (plus)'
3172
3166
)
3173
3167
3168
+ t . equal (
3169
+ to ( { type : 'paragraph' , children : [ { type : 'text' , value : '+a' } ] } ) ,
3170
+ '+a\n' ,
3171
+ 'should not escape `+` when not followed by whitespace'
3172
+ )
3173
+
3174
3174
t . equal (
3175
3175
to ( { type : 'paragraph' , children : [ { type : 'text' , value : '- a\n- b' } ] } ) ,
3176
3176
'\\- a\n\\- b\n' ,
3177
3177
'should escape what would otherwise be a list item (dash)'
3178
3178
)
3179
3179
3180
3180
t . equal (
3181
- to ( { type : 'paragraph' , children : [ { type : 'text' , value : '* a\n* b' } ] } ) ,
3182
- '\\* a\n\\* b\n' ,
3181
+ to ( { type : 'paragraph' , children : [ { type : 'text' , value : '-a' } ] } ) ,
3182
+ '-a\n' ,
3183
+ 'should not escape `-` when not followed by whitespace'
3184
+ )
3185
+
3186
+ t . equal (
3187
+ to ( { type : 'paragraph' , children : [ { type : 'text' , value : '--a' } ] } ) ,
3188
+ '\\--a\n' ,
3189
+ 'should escape `-` when followed by another `-` (as it looks like a thematic break, setext underline)'
3190
+ )
3191
+
3192
+ // Note: these are in titles, because the `*` case here is about flow nodes,
3193
+ // not phrasing (emphasis).
3194
+ t . equal (
3195
+ to ( { type : 'definition' , identifier : 'x' , url : 'y' , title : 'a\n* b\n* c' } ) ,
3196
+ '[x]: y "a\n\\* b\n\\* c"\n' ,
3183
3197
'should escape what would otherwise be a list item (asterisk)'
3184
3198
)
3185
3199
3200
+ t . equal (
3201
+ to ( { type : 'definition' , identifier : 'x' , url : 'y' , title : 'a\n*b' } ) ,
3202
+ '[x]: y "a\n*b"\n' ,
3203
+ 'should not escape `*` when not followed by whitespace'
3204
+ )
3205
+
3206
+ t . equal (
3207
+ to ( { type : 'definition' , identifier : 'x' , url : 'y' , title : 'a\n**b' } ) ,
3208
+ '[x]: y "a\n\\**b"\n' ,
3209
+ 'should escape `*` when followed by another `*` (as it looks like a thematic break)'
3210
+ )
3211
+
3186
3212
t . equal (
3187
3213
to ( { type : 'paragraph' , children : [ { type : 'text' , value : '1. a\n2. b' } ] } ) ,
3188
3214
'1\\. a\n2\\. b\n' ,
0 commit comments