Skip to content

Commit

Permalink
Merge b78ebd6 into eeb1bf6
Browse files Browse the repository at this point in the history
  • Loading branch information
Soaku committed Apr 10, 2019
2 parents eeb1bf6 + b78ebd6 commit e072cab
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 3 deletions.
6 changes: 3 additions & 3 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ First of all, **thank you** for contributing, **you are awesome**! :)

If you have an idea or found a bug, please [open an issue](https://github.com/cebe/markdown/issues/new) on github.

If you want to contribute code, there a few rules to follow:
If you want to contribute code, there a few rules to follow:

- I am following a code style that is basically [PSR-2](http://www.php-fig.org/psr/2/) but with TABS indentation (yes, I really do that ;) ).
- I am following a code style that is basically [PSR-2](https://www.php-fig.org/psr/psr-2/) but with TABS indentation (yes, I really do that ;) ).
I am not going to nit-pick on all the details about the code style but indentation is a must. The important part is that code is readable.
Methods should be documented using phpdoc style.

Expand All @@ -31,6 +31,6 @@ where the input file contains the Markdown and the output file contains the expe
You can run the tests after initializing the lib with composer(`composer install`) with the following command:

vendor/bin/phpunit

To create a new test case, create a `.md` file a`.html` with the same base name in the subfolders of
the `/tests` directory. See existing files for examples.
24 changes: 24 additions & 0 deletions GithubMarkdown.php
Original file line number Diff line number Diff line change
Expand Up @@ -111,4 +111,28 @@ protected function renderText($text)
return parent::renderText($text);
}
}

/**
* @inheritDoc
*
* Allows escaping newlines to create line breaks.
*
* @marker \
*/
protected function parseEscape($text)
{
$br = $this->html5 ? "<br>\n" : "<br />\n";

# If the backslash is followed by a newline.
# Note: GFM doesn't allow spaces after the backslash.
if ($text[1] === "\n") {

# Return the line break
return [["text", $br], 2];
}

# Otherwise parse the sequence normally
return parent::parseEscape($text);

}
}
6 changes: 6 additions & 0 deletions tests/github-data/issue-169.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<p>test \
with trailing space</p>
<p>test <br />
without trailing space</p>
<p>test<br />
without leading space</p>
8 changes: 8 additions & 0 deletions tests/github-data/issue-169.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
test \
with trailing space

test \
without trailing space

test\
without leading space

0 comments on commit e072cab

Please sign in to comment.