File tree Expand file tree Collapse file tree 2 files changed +19
-0
lines changed Expand file tree Collapse file tree 2 files changed +19
-0
lines changed Original file line number Diff line number Diff line change @@ -36,6 +36,7 @@ module.exports = [
36
36
{ character : '"' , inConstruct : 'titleQuote' } ,
37
37
// A number sign could start an ATX heading if it starts a line.
38
38
{ atBreak : true , character : '#' } ,
39
+ { character : '#' , inConstruct : 'headingAtx' , after : '(?:[\r\n]|$)' } ,
39
40
// Dollar sign and percentage are not used in markdown.
40
41
// An ampersand could start a character reference.
41
42
{ character : '&' , after : '[#A-Za-z]' , inConstruct : 'phrasing' } ,
Original file line number Diff line number Diff line change @@ -1078,6 +1078,24 @@ test('heading', function (t) {
1078
1078
'should not escape a `>` at the start of phrasing in a heading'
1079
1079
)
1080
1080
1081
+ t . equal (
1082
+ to ( { type : 'heading' , children : [ { type : 'text' , value : 'a #' } ] } ) ,
1083
+ '# a \\#\n' ,
1084
+ 'should escape a `#` at the end of a heading (1)'
1085
+ )
1086
+
1087
+ t . equal (
1088
+ to ( { type : 'heading' , children : [ { type : 'text' , value : 'a ##' } ] } ) ,
1089
+ '# a #\\#\n' ,
1090
+ 'should escape a `#` at the end of a heading (2)'
1091
+ )
1092
+
1093
+ t . equal (
1094
+ to ( { type : 'heading' , children : [ { type : 'text' , value : 'a # b' } ] } ) ,
1095
+ '# a # b\n' ,
1096
+ 'should not escape a `#` in a heading (2)'
1097
+ )
1098
+
1081
1099
t . end ( )
1082
1100
} )
1083
1101
You can’t perform that action at this time.
0 commit comments