From 99ae736aa5b332d3a85d05c637ecd962c2e21105 Mon Sep 17 00:00:00 2001 From: Andrew Date: Wed, 5 Feb 2014 17:48:19 +0300 Subject: [PATCH] added option not to parse links --- Parsedown.php | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/Parsedown.php b/Parsedown.php index aafc32b..f840f4e 100755 --- a/Parsedown.php +++ b/Parsedown.php @@ -48,6 +48,18 @@ class Parsedown private $breaks_enabled = false; + + # Switch links parsing. + + function set_parse_links($flag) + { + $this->parse_links = $flag; + + return $this; + } + + private $parse_links = true; + # # Synopsis # @@ -969,7 +981,7 @@ class Parsedown if (strpos($text, '>') !== false) { - if ($text[1] === 'h' and preg_match('/^<(https?:[\/]{2}[^\s]+?)>/i', $text, $matches)) + if ($this->parse_links and $text[1] === 'h' and preg_match('/^<(https?:[\/]{2}[^\s]+?)>/i', $text, $matches)) { $element_url = $matches[1]; $element_url = str_replace('&', '&', $element_url); @@ -1046,7 +1058,7 @@ class Parsedown case 'http': - if (preg_match('/^https?:[\/]{2}[^\s]+\b/ui', $text, $matches)) + if ($this->parse_links and preg_match('/^https?:[\/]{2}[^\s]+\b/ui', $text, $matches)) { $element_url = $matches[0]; $element_url = str_replace('&', '&', $element_url);