diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index 986f153..e1702d2 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -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.
@@ -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.
diff --git a/GithubMarkdown.php b/GithubMarkdown.php
index 23c9d1a..3ff6d51 100644
--- a/GithubMarkdown.php
+++ b/GithubMarkdown.php
@@ -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 ? "
\n" : "
\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);
+
+ }
}
diff --git a/tests/github-data/issue-169.html b/tests/github-data/issue-169.html
new file mode 100644
index 0000000..f05364e
--- /dev/null
+++ b/tests/github-data/issue-169.html
@@ -0,0 +1,6 @@
+
test \ +with trailing space
+test
+without trailing space
test
+without leading space