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 = [
3636 { character : '"' , inConstruct : 'titleQuote' } ,
3737 // A number sign could start an ATX heading if it starts a line.
3838 { atBreak : true , character : '#' } ,
39+ { character : '#' , inConstruct : 'headingAtx' , after : '(?:[\r\n]|$)' } ,
3940 // Dollar sign and percentage are not used in markdown.
4041 // An ampersand could start a character reference.
4142 { 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) {
10781078 'should not escape a `>` at the start of phrasing in a heading'
10791079 )
10801080
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+
10811099 t . end ( )
10821100} )
10831101
You can’t perform that action at this time.
0 commit comments