File tree Expand file tree Collapse file tree 1 file changed +9
-7
lines changed
Expand file tree Collapse file tree 1 file changed +9
-7
lines changed Original file line number Diff line number Diff line change @@ -509,10 +509,10 @@ function generateListRule(
509509 let adjustedContent
510510 if ( thisItemIsAParagraph ) {
511511 state . inline = false
512- adjustedContent = content . replace ( LIST_ITEM_END_R , '\n\n' )
512+ adjustedContent = trimEnd ( content ) + '\n\n'
513513 } else {
514514 state . inline = true
515- adjustedContent = content . replace ( LIST_ITEM_END_R , '' )
515+ adjustedContent = trimEnd ( content )
516516 }
517517
518518 const result = parse ( adjustedContent , state )
@@ -576,7 +576,9 @@ const BLOCK_SYNTAXES = [
576576]
577577
578578function trimEnd ( str : string ) {
579- return str . replace ( / \s * $ / , '' )
579+ let end = str . length
580+ while ( end > 0 && str [ end - 1 ] <= ' ' ) end --
581+ return str . slice ( 0 , end )
580582}
581583
582584function containsBlockSyntax ( input : string ) {
@@ -1408,10 +1410,10 @@ export function compiler(
14081410 parse ( capture /*, parse, state*/ ) {
14091411 return {
14101412 lang : undefined ,
1411- text : capture [ 0 ]
1412- . replace ( / ^ { 4 } / gm , '' )
1413- . replace ( / \n + $ / , '' )
1414- . replace ( TEXT_UNESCAPE_R , '$1' ) ,
1413+ text : trimEnd ( capture [ 0 ] . replace ( / ^ { 4 } / gm , '' ) ) . replace (
1414+ TEXT_UNESCAPE_R ,
1415+ '$1'
1416+ ) ,
14151417 }
14161418 } ,
14171419
You can’t perform that action at this time.
0 commit comments