diff --git a/src/__tests__/normalizeLines.test.tsx b/src/__tests__/normalizeLines.test.tsx index 45e9d2dd..4f5a03db 100644 --- a/src/__tests__/normalizeLines.test.tsx +++ b/src/__tests__/normalizeLines.test.tsx @@ -6,9 +6,9 @@ describe('normalizeLines', () => { it('should handle single line markdown with no multi-line ranges', () => { const lines: Paragraph[] = [ { - text: '*Hello, world!*', + text: '**Hello, world!**', start: 0, - length: 13, + length: 15, markdownRanges: [], }, ]; @@ -17,42 +17,42 @@ describe('normalizeLines', () => { { type: 'syntax', start: 0, - length: 1, + length: 2, }, { type: 'bold', - start: 1, + start: 2, length: 11, }, { type: 'syntax', - start: 12, - length: 1, + start: 13, + length: 2, }, ]; const result = normalizeLines(lines, ranges); const paragraph = result[0] as Paragraph; expect(paragraph.markdownRanges).toEqual([ - {length: 1, start: 0, type: 'syntax'}, - {length: 11, start: 1, type: 'bold'}, - {length: 1, start: 12, type: 'syntax'}, + {length: 2, start: 0, type: 'syntax'}, + {length: 11, start: 2, type: 'bold'}, + {length: 2, start: 13, type: 'syntax'}, ]); - expect(paragraph.text).toEqual('*Hello, world!*'); + expect(paragraph.text).toEqual('**Hello, world!**'); }); it('should handle multiline line markdown with no multi-line ranges', () => { const lines: Paragraph[] = [ { - text: '*Hello', + text: '**Hello', start: 0, - length: 6, + length: 7, markdownRanges: [], }, { - text: 'world!*', - start: 7, - length: 7, + text: 'world!**', + start: 8, + length: 8, markdownRanges: [], }, ]; @@ -61,17 +61,17 @@ describe('normalizeLines', () => { { type: 'syntax', start: 0, - length: 1, + length: 2, }, { type: 'bold', start: 0, - length: 13, + length: 14, }, { type: 'syntax', - start: 13, - length: 1, + start: 14, + length: 2, }, ]; @@ -79,10 +79,10 @@ describe('normalizeLines', () => { expect(result.length).toBe(2); const firstParagraph = result[0] as Paragraph; const secondParagraph = result[1] as Paragraph; - expect(firstParagraph.text).toEqual('*Hello'); - expect(secondParagraph.text).toEqual('world!*'); - expect(firstParagraph.markdownRanges).toContainEqual({type: 'bold', start: 0, length: 6}); - expect(secondParagraph.markdownRanges).toContainEqual({type: 'bold', start: 7, length: 6}); + expect(firstParagraph.text).toEqual('**Hello'); + expect(secondParagraph.text).toEqual('world!**'); + expect(firstParagraph.markdownRanges).toContainEqual({type: 'bold', start: 0, length: 7}); + expect(secondParagraph.markdownRanges).toContainEqual({type: 'bold', start: 8, length: 6}); }); it('should merge lines when handling multi-line markdown ranges', () => { diff --git a/src/__tests__/parseExpensiMark.test.ts b/src/__tests__/parseExpensiMark.test.ts index 3c689a8d..ca6c662e 100644 --- a/src/__tests__/parseExpensiMark.test.ts +++ b/src/__tests__/parseExpensiMark.test.ts @@ -49,10 +49,10 @@ describe('parsing error', () => { }); test('bold', () => { - expect('Hello, *world*!').toBeParsedAs([ - {type: 'syntax', start: 7, length: 1}, - {type: 'bold', start: 8, length: 5}, - {type: 'syntax', start: 13, length: 1}, + expect('Hello, **world**!').toBeParsedAs([ + {type: 'syntax', start: 7, length: 2}, + {type: 'bold', start: 9, length: 5}, + {type: 'syntax', start: 14, length: 2}, ]); }); @@ -281,19 +281,19 @@ test('h1', () => { }); test('nested bold and italic', () => { - expect('*_Hello_*, _*world*_!').toBeParsedAs([ - {type: 'syntax', start: 0, length: 1}, - {type: 'bold', start: 1, length: 7}, - {type: 'syntax', start: 1, length: 1}, - {type: 'italic', start: 2, length: 5}, - {type: 'syntax', start: 7, length: 1}, + expect('**_Hello_**, _**world**_!').toBeParsedAs([ + {type: 'syntax', start: 0, length: 2}, + {type: 'bold', start: 2, length: 7}, + {type: 'syntax', start: 2, length: 1}, + {type: 'italic', start: 3, length: 5}, {type: 'syntax', start: 8, length: 1}, - {type: 'syntax', start: 11, length: 1}, - {type: 'italic', start: 12, length: 7}, - {type: 'syntax', start: 12, length: 1}, - {type: 'bold', start: 13, length: 5}, - {type: 'syntax', start: 18, length: 1}, - {type: 'syntax', start: 19, length: 1}, + {type: 'syntax', start: 9, length: 2}, + {type: 'syntax', start: 13, length: 1}, + {type: 'italic', start: 14, length: 9}, + {type: 'syntax', start: 14, length: 2}, + {type: 'bold', start: 16, length: 5}, + {type: 'syntax', start: 21, length: 2}, + {type: 'syntax', start: 23, length: 1}, ]); }); @@ -412,13 +412,13 @@ describe('trailing whitespace', () => { }); test('with another style inside', () => { - expect('>> Hello *world*').toBeParsedAs([ - {type: 'blockquote', start: 0, length: 16, depth: 2}, + expect('>> Hello **world**').toBeParsedAs([ + {type: 'blockquote', start: 0, length: 18, depth: 2}, {type: 'syntax', start: 0, length: 1}, {type: 'syntax', start: 1, length: 1}, - {type: 'syntax', start: 9, length: 1}, - {type: 'bold', start: 10, length: 5}, - {type: 'syntax', start: 15, length: 1}, + {type: 'syntax', start: 9, length: 2}, + {type: 'bold', start: 11, length: 5}, + {type: 'syntax', start: 16, length: 2}, ]); }); }); diff --git a/src/__tests__/singleLineInputFix.test.tsx b/src/__tests__/singleLineInputFix.test.tsx index 1b0c3b94..70baca67 100644 --- a/src/__tests__/singleLineInputFix.test.tsx +++ b/src/__tests__/singleLineInputFix.test.tsx @@ -34,7 +34,7 @@ describe('Single-line input fix validation', () => { }); it('should not generate BR elements for single-line markdown (isMultiline=false)', () => { - const text = 'hello *world* test'; + const text = 'hello **world** test'; const ranges = parseExpensiMark(text); const result = parseRangesToHTMLNodes(text, ranges, false, {}, true); @@ -100,7 +100,7 @@ describe('Single-line input fix validation', () => { it('should work correctly with markdown in single-line context', () => { // Test that our fix doesn't break markdown functionality - const markdownText = '*bold* normal `code`'; + const markdownText = '**bold** normal `code`'; const ranges = parseExpensiMark(markdownText); const result = parseRangesToHTMLNodes(markdownText, ranges, false, {}, true); diff --git a/src/__tests__/webParser.test.tsx b/src/__tests__/webParser.test.tsx index fbc77fd0..ed589759 100644 --- a/src/__tests__/webParser.test.tsx +++ b/src/__tests__/webParser.test.tsx @@ -44,8 +44,8 @@ test('no formatting', () => { }); test('bold', () => { - expect('Hello, *world*!').toBeParsedAsHTML( - '
Hello, *world*!
', + expect('Hello, **world**!').toBeParsedAsHTML( + 'Hello, **world**!
', ); }); @@ -224,8 +224,8 @@ test('heading', () => { }); test('nested bold and italic', () => { - expect('*_Hello_*, _*world*_!').toBeParsedAsHTML( - '*_Hello_*, _*world*_!
', + expect('**_Hello_**, _**world**_!').toBeParsedAsHTML( + '**_Hello_**, _**world**_!
', ); }); diff --git a/src/parseExpensiMark.ts b/src/parseExpensiMark.ts index 6a5d4762..473756e0 100644 --- a/src/parseExpensiMark.ts +++ b/src/parseExpensiMark.ts @@ -134,9 +134,9 @@ function parseTreeToTextAndRanges(tree: StackItem): [string, MarkdownRange[]] { if (node.tag === '<>') { processChildren(node); } else if (node.tag === '') { - appendSyntax('*'); + appendSyntax('**'); addChildrenWithStyle(node, 'bold'); - appendSyntax('*'); + appendSyntax('**'); } else if (node.tag === '') { appendSyntax('_'); addChildrenWithStyle(node, 'italic');