Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix paragraph breaking condition #130

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
3 changes: 2 additions & 1 deletion GithubMarkdown.php
Original file line number Diff line number Diff line change
@@ -71,7 +71,8 @@ protected function consumeParagraph($lines, $current)
$this->identifyFencedCode($line, $lines, $i) ||
$this->identifyUl($line, $lines, $i) ||
$this->identifyOl($line, $lines, $i) ||
$this->identifyHr($line, $lines, $i)
$this->identifyHr($line, $lines, $i) ||
$this->identifyHtml($line, $lines, $i)
)
|| $this->identifyHeadline($line, $lines, $i))
{
12 changes: 10 additions & 2 deletions Markdown.php
Original file line number Diff line number Diff line change
@@ -92,9 +92,17 @@ protected function consumeParagraph($lines, $current)
break;
}

if ($line === '' || ltrim($line) === '' || $this->identifyHeadline($line, $lines, $i)) {
if (
$line === '' ||
ltrim($line) === '' ||
!ctype_alpha($line[0]) && (
$this->identifyQuote($line, $lines, $i) ||
$this->identifyHr($line, $lines, $i) ||
$this->identifyHtml($line, $lines, $i)
)
|| $this->identifyHeadline($line, $lines, $i)) {
break;
} elseif ($line[0] === "\t" || $line[0] === " " && strncmp($line, ' ', 4) === 0) {
} elseif ($this->identifyCode($line, $lines, $i)) {
// possible beginning of a code block
// but check for continued inline HTML
// e.g. <img src="file.jpg"
7 changes: 7 additions & 0 deletions tests/github-data/dense-block-markers.html
Original file line number Diff line number Diff line change
@@ -50,3 +50,10 @@ <h2>changelog 2</h2>
<ul>
<li>17-Feb-2013 re-design</li>
</ul>
<p>paragraph</p>
<blockquote><p>quote</p>
</blockquote>
<p>paragraph</p>
<hr />
<p>paragraph</p>
<div>html block</div>
11 changes: 10 additions & 1 deletion tests/github-data/dense-block-markers.md
Original file line number Diff line number Diff line change
@@ -53,4 +53,13 @@ headline2

----
## changelog 2
* 17-Feb-2013 re-design
* 17-Feb-2013 re-design

paragraph
> quote

paragraph
- - -

paragraph
<div>html block</div>
7 changes: 7 additions & 0 deletions tests/markdown-data/dense-block-markers.html
Original file line number Diff line number Diff line change
@@ -48,3 +48,10 @@ <h2>changelog 2</h2>
<ul>
<li>17-Feb-2013 re-design</li>
</ul>
<p>paragraph</p>
<blockquote><p>quote</p>
</blockquote>
<p>paragraph</p>
<hr />
<p>paragraph</p>
<div>html block</div>
11 changes: 10 additions & 1 deletion tests/markdown-data/dense-block-markers.md
Original file line number Diff line number Diff line change
@@ -53,4 +53,13 @@ headline2

----
## changelog 2
* 17-Feb-2013 re-design
* 17-Feb-2013 re-design

paragraph
> quote

paragraph
- - -

paragraph
<div>html block</div>
4 changes: 2 additions & 2 deletions tests/markdown-data/images.html
Original file line number Diff line number Diff line change
@@ -2,9 +2,9 @@
<img src="https://secure.travis-ci.org/cebe/markdown.png" alt="Build Status" title="test1" /></p>
<p>Here is an image tag: <img src="https://poser.pugx.org/cebe/markdown/downloads.png" alt="Total Downloads" />.</p>
<p>Images inside of links:
<a href="https://packagist.org/packages/cebe/markdown"><img src="https://poser.pugx.org/cebe/markdown/downloads.png" alt="Total Downloads" /></a>
<a href="https://packagist.org/packages/cebe/markdown"><img src="https://poser.pugx.org/cebe/markdown/downloads.png" alt="Total Downloads" /></a></p>
<!-- [![Scrutinizer Quality Score](https://scrutinizer-ci.com/g/cebe/markdown/badges/quality-score.png?s=17448ca4d140429fd687c58ff747baeb6568d528)](https://scrutinizer-ci.com/g/cebe/markdown/) -->
<a href="http://travis-ci.org/cebe/markdown"><img src="https://secure.travis-ci.org/cebe/markdown.png" alt="Build Status" title="test2" /></a>
<p><a href="http://travis-ci.org/cebe/markdown"><img src="https://secure.travis-ci.org/cebe/markdown.png" alt="Build Status" title="test2" /></a>
<a href="http://travis-ci.org/cebe/markdown" title="test4"><img src="https://secure.travis-ci.org/cebe/markdown.png" alt="Build Status" title="test3" /></a></p>
<p>This is not an image: ![[ :-)</p>
<p>This is not an image: ![[ :-)]]</p>