P->addMode('gfm_emphasis_strong_underscore', new GfmEmphasisStrongUnderscore()); $this->P->parse('Foo ___Bar___ Baz'); $calls = [ ['document_start', []], ['p_open', []], ['cdata', ["\nFoo "]], ['emphasis_open', []], ['strong_open', []], ['cdata', ['Bar']], ['strong_close', []], ['emphasis_close', []], ['cdata', [' Baz']], ['p_close', []], ['document_end', []], ]; $this->assertCalls($calls, $this->H->calls); } function testSingleCharacter() { $this->P->addMode('gfm_emphasis_strong_underscore', new GfmEmphasisStrongUnderscore()); $this->P->parse('___a___'); $this->assertContains('emphasis_open', array_column($this->H->calls, 0)); $this->assertContains('strong_open', array_column($this->H->calls, 0)); } function testLeadingWhitespaceDoesNotMatch() { $this->P->addMode('gfm_emphasis_strong_underscore', new GfmEmphasisStrongUnderscore()); $this->P->parse('___ foo___'); $this->assertNotContains('emphasis_open', array_column($this->H->calls, 0)); } function testTrailingWhitespaceDoesNotMatch() { $this->P->addMode('gfm_emphasis_strong_underscore', new GfmEmphasisStrongUnderscore()); $this->P->parse('___foo ___'); $this->assertNotContains('emphasis_open', array_column($this->H->calls, 0)); } function testDoesNotSpanParagraphBoundary() { $this->P->addMode('gfm_emphasis_strong_underscore', new GfmEmphasisStrongUnderscore()); $this->P->parse("___foo\n\nbar___"); $this->assertNotContains('emphasis_open', array_column($this->H->calls, 0)); } function testLongerSymmetricRunDoesNotMatch() { $this->P->addMode('gfm_emphasis_strong_underscore', new GfmEmphasisStrongUnderscore()); $this->P->parse('____foo____'); $this->assertNotContains('emphasis_open', array_column($this->H->calls, 0)); } function testAsymmetricDoesNotMatch() { $this->P->addMode('gfm_emphasis_strong_underscore', new GfmEmphasisStrongUnderscore()); $this->P->parse('___foo__'); $this->assertNotContains('emphasis_open', array_column($this->H->calls, 0)); } function testIntrawordDoesNotMatch() { $this->P->addMode('gfm_emphasis_strong_underscore', new GfmEmphasisStrongUnderscore()); $this->P->parse('abc___foo___'); $this->assertNotContains('emphasis_open', array_column($this->H->calls, 0)); } function testMultibyteIntrawordDoesNotMatch() { $this->P->addMode('gfm_emphasis_strong_underscore', new GfmEmphasisStrongUnderscore()); $this->P->parse('für___etwas___'); $this->assertNotContains('emphasis_open', array_column($this->H->calls, 0)); } function testMultibyteContentInside() { $this->P->addMode('gfm_emphasis_strong_underscore', new GfmEmphasisStrongUnderscore()); $this->P->parse('foo ___für___ bar'); $this->assertContains('emphasis_open', array_column($this->H->calls, 0)); $this->assertContains('strong_open', array_column($this->H->calls, 0)); } function testSortValue() { $this->assertSame(65, (new GfmEmphasisStrongUnderscore())->getSort()); } }