Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
*/
class ConvertsMarkdownToPlainText
{
protected const ATX_HEADERS = ['/^(\n)?\s{0,}#{1,6}\s+| {0,}(\n)?\s{0,}#{0,} {0,}(\n)?\s{0,}$/m' => '$1$2$3'];
protected const ATX_HEADERS = ['/^[ \t]*#{1,6}[ \t]+|[ \t]+#{1,6}[ \t]*$/m' => ''];
protected const SETEXT_HEADERS = ['/\n={2,}/' => "\n"];
protected const HORIZONTAL_RULES = ['/^(-\s*?|\*\s*?|_\s*?){3,}\s*/m' => ''];
protected const HTML_TAGS = ['/<[^>]*>/' => ''];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,24 @@ public function testItRemovesHeadings()
$this->assertSame($text, $this->convert($markdown));
}

public function testItRemovesHeadingsFromLongMarkdownDocuments()
{
$markdown = <<<'MD'
# Customizing Your Site

## Introduction

| Collection Type | Facade Method | Returned Object Type | File Extension |
|---------------------------------------|----------------|----------------------------------------------------------------------------------------------------------------------------------------------------------|-----------------------|
MD;

$text = $this->convert($markdown);

$this->assertStringContainsString("Customizing Your Site\n\nIntroduction", $text);
$this->assertStringNotContainsString('# Customizing Your Site', $text);
$this->assertStringContainsString('Collection Type', $text);
}

public function testItRemovesHeadingsAlternateSyntax()
{
$markdown = <<<'MD'
Expand Down Expand Up @@ -509,7 +527,7 @@ public function testWithEmptyString()

public function testWithOnlyEmptyLines()
{
$this->assertSame("\n", $this->convert("\n\n\n"));
$this->assertSame("\n\n", $this->convert("\n\n\n"));
}

protected function convert(string $markdown): string
Expand Down
Loading