@@ -318,14 +318,16 @@ describe('parseIncompleteMarkdown', () => {
318318 } ) ;
319319
320320 describe ( 'KaTeX inline formatting ($)' , ( ) => {
321- it ( 'should complete incomplete inline KaTeX' , ( ) => {
321+ it ( 'should NOT complete single dollar signs (likely currency)' , ( ) => {
322+ // Single dollar signs are likely currency, not math
322323 expect ( parseIncompleteMarkdown ( 'Text with $formula' ) ) . toBe (
323- 'Text with $formula$ '
324+ 'Text with $formula'
324325 ) ;
325- expect ( parseIncompleteMarkdown ( '$incomplete' ) ) . toBe ( '$incomplete$ ' ) ;
326+ expect ( parseIncompleteMarkdown ( '$incomplete' ) ) . toBe ( '$incomplete' ) ;
326327 } ) ;
327328
328- it ( 'should keep complete inline KaTeX unchanged' , ( ) => {
329+ it ( 'should keep text with paired dollar signs unchanged' , ( ) => {
330+ // Even paired dollar signs are preserved but not treated as math
329331 const text = 'Text with $x^2 + y^2 = z^2$' ;
330332 expect ( parseIncompleteMarkdown ( text ) ) . toBe ( text ) ;
331333 } ) ;
@@ -335,20 +337,23 @@ describe('parseIncompleteMarkdown', () => {
335337 expect ( parseIncompleteMarkdown ( text ) ) . toBe ( text ) ;
336338 } ) ;
337339
338- it ( 'should complete odd number of inline KaTeX markers' , ( ) => {
340+ it ( 'should NOT complete odd number of dollar signs' , ( ) => {
341+ // We don't auto-complete dollar signs anymore
339342 expect ( parseIncompleteMarkdown ( '$first$ and $second' ) ) . toBe (
340- '$first$ and $second$ '
343+ '$first$ and $second'
341344 ) ;
342345 } ) ;
343346
344- it ( 'should not confuse single $ with block $$' , ( ) => {
347+ it ( 'should not complete single $ but should complete block $$' , ( ) => {
348+ // Block math $$ is completed, single $ is not
345349 expect ( parseIncompleteMarkdown ( '$$block$$ and $inline' ) ) . toBe (
346- '$$block$$ and $inline$ '
350+ '$$block$$ and $inline'
347351 ) ;
348352 } ) ;
349353
350- it ( 'should handle inline KaTeX at start of text' , ( ) => {
351- expect ( parseIncompleteMarkdown ( '$x + y = z' ) ) . toBe ( '$x + y = z$' ) ;
354+ it ( 'should NOT complete dollar sign at start of text' , ( ) => {
355+ // Single dollar sign is likely currency
356+ expect ( parseIncompleteMarkdown ( '$x + y = z' ) ) . toBe ( '$x + y = z' ) ;
352357 } ) ;
353358
354359 it ( 'should handle escaped dollar signs' , ( ) => {
@@ -542,10 +547,10 @@ describe('parseIncompleteMarkdown', () => {
542547 ) ;
543548 } ) ;
544549
545- it ( 'should handle KaTeX inside other formatting' , ( ) => {
546- // Bold gets closed first, then KaTeX
550+ it ( 'should handle dollar sign inside other formatting' , ( ) => {
551+ // Bold gets closed, dollar sign stays as-is (likely currency)
547552 expect ( parseIncompleteMarkdown ( '**bold with $x^2' ) ) . toBe (
548- '**bold with $x^2**$ '
553+ '**bold with $x^2**'
549554 ) ;
550555 } ) ;
551556
@@ -610,11 +615,12 @@ describe('parseIncompleteMarkdown', () => {
610615 'The formula $E = mc^2$ shows' ,
611616 ] ;
612617
618+ // Single dollar signs are not auto-completed (likely currency)
613619 expect ( parseIncompleteMarkdown ( chunks [ 0 ] ) ) . toBe ( chunks [ 0 ] ) ;
614- expect ( parseIncompleteMarkdown ( chunks [ 1 ] ) ) . toBe ( 'The formula $E$ ' ) ;
615- expect ( parseIncompleteMarkdown ( chunks [ 2 ] ) ) . toBe ( 'The formula $E = mc$ ' ) ;
620+ expect ( parseIncompleteMarkdown ( chunks [ 1 ] ) ) . toBe ( 'The formula $E' ) ;
621+ expect ( parseIncompleteMarkdown ( chunks [ 2 ] ) ) . toBe ( 'The formula $E = mc' ) ;
616622 expect ( parseIncompleteMarkdown ( chunks [ 3 ] ) ) . toBe (
617- 'The formula $E = mc^2$ '
623+ 'The formula $E = mc^2'
618624 ) ;
619625 expect ( parseIncompleteMarkdown ( chunks [ 4 ] ) ) . toBe ( chunks [ 4 ] ) ;
620626 } ) ;
@@ -656,10 +662,10 @@ describe('parseIncompleteMarkdown', () => {
656662 } ) ;
657663
658664 it ( 'should not add underscore when math block has incomplete underscore' , ( ) => {
659- // Incomplete math blocks get completed by handleIncompleteInlineKatex
660- // The underscore inside should not be treated as italic
665+ // We no longer auto-complete single dollar signs
666+ // The underscore inside is not treated as italic since it's likely part of a variable name
661667 const text = 'Math expression $x_' ;
662- expect ( parseIncompleteMarkdown ( text ) ) . toBe ( 'Math expression $x_$ ' ) ;
668+ expect ( parseIncompleteMarkdown ( text ) ) . toBe ( 'Math expression $x_' ) ;
663669
664670 const text2 = '$$formula_' ;
665671 expect ( parseIncompleteMarkdown ( text2 ) ) . toBe ( '$$formula_$$' ) ;
@@ -791,7 +797,7 @@ describe('parseIncompleteMarkdown', () => {
791797 expect ( parseIncompleteMarkdown ( 'text**' ) ) . toBe ( 'text****' ) ;
792798 expect ( parseIncompleteMarkdown ( 'text*' ) ) . toBe ( 'text**' ) ;
793799 expect ( parseIncompleteMarkdown ( 'text`' ) ) . toBe ( 'text``' ) ;
794- expect ( parseIncompleteMarkdown ( 'text$' ) ) . toBe ( 'text$$ ' ) ;
800+ expect ( parseIncompleteMarkdown ( 'text$' ) ) . toBe ( 'text$' ) ; // Single dollar not completed
795801 expect ( parseIncompleteMarkdown ( 'text~~' ) ) . toBe ( 'text~~~~' ) ;
796802 } ) ;
797803
0 commit comments