From 1ab48be9eea4637a057d969c2c02f8c76b2f8bcf Mon Sep 17 00:00:00 2001 From: Garion Herman Date: Wed, 29 Jun 2016 15:48:27 +1200 Subject: [PATCH] Added support for variable line endings (fixes parsing of documents with Windows line endings). --- code/DocumentationParser.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/code/DocumentationParser.php b/code/DocumentationParser.php index 8d476a3..da0e444 100755 --- a/code/DocumentationParser.php +++ b/code/DocumentationParser.php @@ -69,7 +69,7 @@ class DocumentationParser $end = false; $debug = false; - $lines = explode("\n", $md); + $lines = preg_split('/\\r\\n|\\r|\\n/', $md); $output = array(); foreach ($lines as $i => $line) { @@ -394,7 +394,7 @@ class DocumentationParser $headingText .= "-" . self::$heading_counts[$headingText]; } - return sprintf("%s {#%s}", preg_replace('/\n/', '', $heading), self::generate_html_id($headingText)); + return sprintf("%s {#%s}", preg_replace('/\\r\\n|\\r|\\n/', '', $heading), self::generate_html_id($headingText)); } /**