cebe / markdown

A super fast, highly extensible markdown parser for PHP

Home Page:http://markdown.cebe.cc/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

GFM: Line break using a backslash

ArthaTi opened this issue · comments

commented

The GFM spec specifies that to make a line break, a backslash can be used so it is more visible. It also better because some editors automatically remove trailing whitespace.

The GithubMarkdown class doesn't support those. Only double-space breaks are allowed. It would be really nice if that feature would be added.

I tried doing this myself, but renderText receives line text and the backslash as separate blocks, so I kinda failed there. Also, what would be the preferred way to do this? Is changing the escape code parser necessary?

The GithubMarkdown class doesn't support those. Only double-space breaks are allowed. It would be really nice if that feature would be added.

seems it is a newly added feature.

  • \ is a marker for the parseEscape function, so extending it should allow implementing this:

markdown/Parser.php

Lines 368 to 378 in eeb1bf6

/**
* Parses escaped special characters.
* @marker \
*/
protected function parseEscape($text)
{
if (isset($text[1]) && in_array($text[1], $this->escapeCharacters)) {
return [['text', $text[1]], 2];
}
return [['text', $text[0]], 1];
}

have not checked it in detail though.