55use PHPUnit \Framework \Attributes \Test ;
66use Tempest \Markdown \Parser ;
77use Tempest \Markdown \Rules \BoldRule ;
8+ use Tempest \Markdown \Rules \ItalicRule ;
9+ use Tempest \Markdown \Rules \NewLineRule ;
10+ use Tempest \Markdown \Rules \ParagraphRule ;
811use Tempest \Markdown \Tests \ParserTestCase ;
912
1013class BoldRuleTest extends ParserTestCase
@@ -17,10 +20,18 @@ public function test_lex_double_asterisk(): void
1720 $ this ->assertSame ('<strong>bold</strong> ' , $ html );
1821 }
1922
23+ #[Test]
24+ public function test_double_asterisk_must_be_terminated (): void
25+ {
26+ $ html = (string ) new Parser (highlighter: null , rules: [new NewLineRule (), new BoldRule (), new ParagraphRule ()])->parse ("Hello**world \n\nHi " );
27+
28+ $ this ->assertSame ("<p>Hello**world</p> \n\n<p>Hi</p> " , $ html );
29+ }
30+
2031 #[Test]
2132 public function test_lex_asterisk_with_underscore (): void
2233 {
23- $ html = (string ) new Parser (highlighter: null , rules: [new BoldRule ()])->parse ('**_bold_** ' );
34+ $ html = (string ) new Parser (highlighter: null , rules: [new BoldRule (), new ItalicRule () ])->parse ('**_bold_** ' );
2435
2536 $ this ->assertSame ('<strong><em>bold</em></strong> ' , $ html );
2637 }
@@ -41,6 +52,14 @@ public function test_lex_double_underscore(): void
4152 $ this ->assertSame ('<strong>bold</strong> ' , $ html );
4253 }
4354
55+ #[Test]
56+ public function test_double_underscore_must_be_terminated (): void
57+ {
58+ $ html = (string ) new Parser (highlighter: null , rules: [new NewLineRule (), new BoldRule (), new ParagraphRule ()])->parse ("Hello__world \n\nHi " );
59+
60+ $ this ->assertSame ("<p>Hello__world</p> \n\n<p>Hi</p> " , $ html );
61+ }
62+
4463 #[Test]
4564 public function test_does_not_lex_single_underscore (): void
4665 {
0 commit comments