From 1f347e17ebb5f591ec328482d43315c99b66a07d Mon Sep 17 00:00:00 2001 From: Haralan Dobrev Date: Tue, 12 Nov 2013 19:22:17 +0200 Subject: [PATCH] Allow multi-line emphasis. Fix #28. --- Parsedown.php | 8 ++++---- tests/data/emphasis.html | 6 +++++- tests/data/emphasis.md | 8 +++++++- 3 files changed, 16 insertions(+), 6 deletions(-) diff --git a/Parsedown.php b/Parsedown.php index 520cb77..4e07a15 100755 --- a/Parsedown.php +++ b/Parsedown.php @@ -678,14 +678,14 @@ class Parsedown if (strpos($text, '_') !== FALSE) { - $text = preg_replace('/__(?=\S)(.+?)(?<=\S)__/', '$1', $text); - $text = preg_replace('/_(?=\S)(.+?)(?<=\S)_/', '$1', $text); + $text = preg_replace('/__(?=\S)(.+?)(?<=\S)__/s', '$1', $text); + $text = preg_replace('/_(?=\S)(.+?)(?<=\S)_/s', '$1', $text); } if (strpos($text, '*') !== FALSE) { - $text = preg_replace('/\*\*(?=\S)(.+?)(?<=\S)\*\*/', '$1', $text); - $text = preg_replace('/\*(?=\S)(.+?)(?<=\S)\*/', '$1', $text); + $text = preg_replace('/\*\*(?=\S)(.+?)(?<=\S)\*\*/s', '$1', $text); + $text = preg_replace('/\*(?=\S)(.+?)(?<=\S)\*/s', '$1', $text); } $text = strtr($text, $map); diff --git a/tests/data/emphasis.html b/tests/data/emphasis.html index 4fd23e5..9a8481a 100644 --- a/tests/data/emphasis.html +++ b/tests/data/emphasis.html @@ -4,4 +4,8 @@

Here's one that uses underscores.

Here's a strong one that uses underscores.

This is not _ one _ neither is * this * neither is _ this_ neither is _this _.

-

An empty emphasis ** is not __ an emphasis.

\ No newline at end of file +

An empty emphasis ** is not __ an emphasis.

+

A multi-line +emphasis

+

A multi-line +strong emphasis

\ No newline at end of file diff --git a/tests/data/emphasis.md b/tests/data/emphasis.md index 1122723..e125c9d 100644 --- a/tests/data/emphasis.md +++ b/tests/data/emphasis.md @@ -10,4 +10,10 @@ Here's __a strong one that uses underscores__. This is not _ one _ neither is * this * neither is _ this_ neither is _this _. -An empty emphasis ** is not __ an emphasis. \ No newline at end of file +An empty emphasis ** is not __ an emphasis. + +A *multi-line +emphasis* + +A **multi-line +strong emphasis** \ No newline at end of file