From 2aa67d67f508067fcb821ec9f816cdc921c18d8a Mon Sep 17 00:00:00 2001 From: Michael Vogel Date: Thu, 2 Aug 2012 01:46:28 +0200 Subject: [PATCH] Changed markdown to enable diaspora postings with images that contain links --- include/bb2diaspora.php | 6 +++--- include/markdownify/markdownify.php | 7 ++++++- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/include/bb2diaspora.php b/include/bb2diaspora.php index b95dee8f3b..9ede42f6c7 100644 --- a/include/bb2diaspora.php +++ b/include/bb2diaspora.php @@ -202,9 +202,9 @@ function bb2diaspora($Text,$preserve_nl = false, $fordiaspora = true) { // the following was added on 10-January-2012 due to an inability of Diaspora's // new javascript markdown processor to handle links with images as the link "text" // It is not optimal and may be removed if this ability is restored in the future - if ($fordiaspora) - $Text = preg_replace("/\[url\=([^\[\]]*)\]\s*\[img\](.*?)\[\/img\]\s*\[\/url\]/ism", - "[url]$1[/url]\n[img]$2[/img]", $Text); + //if ($fordiaspora) + // $Text = preg_replace("/\[url\=([^\[\]]*)\]\s*\[img\](.*?)\[\/img\]\s*\[\/url\]/ism", + // "[url]$1[/url]\n[img]$2[/img]", $Text); // Convert it to HTML - don't try oembed $Text = bbcode($Text, $preserve_nl, false); diff --git a/include/markdownify/markdownify.php b/include/markdownify/markdownify.php index 7bbf1cbbed..0d4429a013 100644 --- a/include/markdownify/markdownify.php +++ b/include/markdownify/markdownify.php @@ -686,6 +686,10 @@ class Markdownify { # [1]: mailto:mail@example.com Title $tag['href'] = 'mailto:'.$bufferDecoded; } + + $this->out('['.$buffer.']('.$tag['href'].' "'.$tag['title'].'")', true); + +/* # [This link][id] foreach ($this->stack['a'] as $tag2) { if ($tag2['href'] == $tag['href'] && $tag2['title'] === $tag['title']) { @@ -699,6 +703,7 @@ class Markdownify { } $this->out('['.$buffer.']['.$tag['linkID'].']', true); +*/ } } /** @@ -737,7 +742,7 @@ class Markdownify { // ![Alt text](/path/to/img.jpg "Optional title") if ($this->parser->tagAttributes['title'] != "") - $this->out('!['.$this->parser->tagAttributes['alt'].']('.$this->parser->tagAttributes['src'].'"'.$this->parser->tagAttributes['title'].'")', true); + $this->out('!['.$this->parser->tagAttributes['alt'].']('.$this->parser->tagAttributes['src'].' "'.$this->parser->tagAttributes['title'].'")', true); else $this->out('!['.$this->parser->tagAttributes['alt'].']('.$this->parser->tagAttributes['src'].')', true);