Skip to content

Commit

Permalink
add blank line after block end, make raw html parsing more flexible
Browse files Browse the repository at this point in the history
  • Loading branch information
adhocore committed Dec 23, 2015
1 parent cfbfb57 commit 3fea26c
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 16 deletions.
26 changes: 13 additions & 13 deletions readme.md
Expand Up @@ -33,24 +33,24 @@ It provides limited support to deep nested elements, supported items are:

## raw html

you can throw in your raw html but with all the lines with a `tag`. so there cant be a text node like such-
you can throw in your raw html but with a blank line at start and end to delimit the block at like so-

```html
<div>
<p>
this line is _not_ parsed as raw html by `htmlup`, rather as free text (codeblock mostly)
</p>
</div>
```

That _should_ be supported as per the markdown spec but for `htmlup` the raw html shoule be like such-
<dl>
<dt>
A
</dt>
<dd>Apple
</dd>
<dt>B
</dt>
<dd>
Ball</dd>
</dl>

```html
<div>
<p>this line _is_ parsed as raw html by `htmlup`</p>
</div>
```
`

## table

supports [GFM table syntax](https://help.github.com/articles/github-flavored-markdown/#tables), example:
Expand Down
15 changes: 12 additions & 3 deletions src/HtmlUp.php
Expand Up @@ -24,7 +24,7 @@ public function __construct($markdown)
// some normalisations
$this->Lines =
explode("\n", # the lines !
trim(# trim trailing \n
trim( # trim trailing \n
str_replace(array("\r\n", "\r"), "\n", # use standard newline
str_replace("\t", ' ', $markdown) # use 4 spaces for tab
), "\n"
Expand Down Expand Up @@ -73,14 +73,23 @@ public function parse()
$markup .= array_pop($stackTable);
}

$inList = $inQuote = $inPara = null;
$markup .= "\n";

$inList = $inQuote = $inPara = $inHtml = null;
$nestLevel = $quoteLevel = 0;
continue;
}

// raw html
if (preg_match('/^<\/?\w.*?\/?>/', $trimmedLine)) {
if (preg_match('/^<\/?\w.*?\/?>/', $trimmedLine) or
isset($inHtml)
) {
$markup .= "\n$line";
if (empty($inHtml) and
empty($this->Lines[$this->Pointer-1])
) {
$inHtml = true;
}
continue;
}

Expand Down

0 comments on commit 3fea26c

Please sign in to comment.