@@ -719,11 +719,18 @@ function replace_blank_lines(html: string) {
719719}
720720
721721const delimiter_substitutes = {
722- '---' : ' ' ,
723- '+++' : ' ' ,
724- ':::' : ' '
722+ '---' : ' ' ,
723+ '+++' : ' ' ,
724+ ':::' : ' '
725725} ;
726726
727+ const delimiter_patterns = Object . fromEntries (
728+ Object . entries ( delimiter_substitutes ) . map ( ( [ key , substitute ] ) => [
729+ key ,
730+ new RegExp ( `${ substitute } ([^ ][^]+?)${ substitute } ` , 'g' )
731+ ] )
732+ ) ;
733+
727734function highlight_spans ( content : string , classname : string ) {
728735 return content
729736 . split ( '\n' )
@@ -878,13 +885,13 @@ async function syntax_highlight({
878885 . replace ( ' tabindex="0"' , '' ) ;
879886
880887 html = html
881- . replace ( / { 13 } ( [ ^ ] [ ^ ] + ? ) { 13 } / g , ( _ , content ) => {
888+ . replace ( delimiter_patterns [ '---' ] , ( _ , content ) => {
882889 return highlight_spans ( content , 'highlight remove' ) ;
883890 } )
884- . replace ( / { 11 } ( [ ^ ] [ ^ ] + ? ) { 11 } / g , ( _ , content ) => {
891+ . replace ( delimiter_patterns [ '+++' ] , ( _ , content ) => {
885892 return highlight_spans ( content , 'highlight add' ) ;
886893 } )
887- . replace ( / { 9 } ( [ ^ ] [ ^ ] + ? ) { 9 } / g , ( _ , content ) => {
894+ . replace ( delimiter_patterns [ ':::' ] , ( _ , content ) => {
888895 return highlight_spans ( content , 'highlight' ) ;
889896 } ) ;
890897
0 commit comments