To get AutoLinks to work nicely with the Markdown Formatter, you need to also have the HTML Foramtter installed and you need to modify both the Markdown Formatter and the HTML Formatter. I will give full instructions below, but...
If you just want a get it working, you can download an already-modified versions of the Markdown Formatter 1.1.2 and the HTML Formatter 2.4 from here and here.
If you would rather make the modifications manually, here are the steps involved.
First, you need to get the Markdown Formatter to honour it's child formatters and accept HTML (which it should, as per the Markdown spec., but doesn't by default). This can be done with the following patch:--- default.php.orig 2009-03-13 15:57:59.000000000 +0000
+++ default.php 2009-03-19 15:10:45.000000000 +0000
@@ -17,13 +17,21 @@
class MarkdownFormatter extends StringFormatter {
function Parse($String, $Object, $FormatPurpose) {
if ($FormatPurpose == FORMAT_STRING_FOR_DISPLAY) {
- $String = $this->ProtectString($String);
- return Markdown($String);
+ $String = $this->ParseChildren($String, $Object, $FormatPurpose);
+ if( isset( $Object->Context->StringManipulator->Formatters[ "Html" ] ) ) {
+ $String = Markdown( $String );
+ $String = $Object->Context->StringManipulator->Formatters[ "Html" ]->Execute( $String, true );
+ }
+ else {
+ $String = $this->EscapeHtml( $String );
+ $String = Markdown( $String );
+ }
+ return $String;
} else {
return $String;
}
}
- function ProtectString ($String) {
+ function EscapeHtml ($String) {
//$String = str_replace("<", "<", $String);
// $String = str_replace(">", ">", $String);
$String = explode("\n", $String);
Second, you need to modify the HTML Formatter to allow the Markdown formatter to use it's parsing abilities. The following patch will achieve this:--- default.php.orig 2009-03-19 13:02:20.000000000 +0000
+++ default.php 2009-03-19 13:04:46.000000000 +0000
@@ -111,7 +111,7 @@
$this->TagArray = &$GLOBALS['Html_TagArray'];
}
- function Execute($String)
+ function Execute($String, $ParseOnly)
{
$this->TagArray = array('normal' => array(), 'extraclosing' => array());
$String = str_replace(chr(0), ' ', $String);
@@ -172,7 +172,7 @@
$sReturn
);
- if(HTML_CONVERT_NEWLINES)
+ if(HTML_CONVERT_NEWLINES && !$ParseOnly)
$sReturn = str_replace(
array("\r\n", "\r", "\n"),
'<br />',
@@ -389,7 +389,7 @@
function Parse($String, $Object, $FormatPurpose)
{
- if($FormatPurpose == FORMAT_STRING_FOR_DISPLAY) $sReturn = $this->Execute($String);
+ if($FormatPurpose == FORMAT_STRING_FOR_DISPLAY) $sReturn = $this->Execute($String, false);
else $sReturn = $String;
return $this->ParseChildren($sReturn, $Object, $FormatPurpose); Finally, you need to allow the "embed" tag through the HTML Formatter (which is disallowed by default). To achieve this, you need to remove 'embed' from the list of disallowed tags on line 76 in HTML Formatter's default.php. The following patch will achieve this:--- default.php.orig 2009-03-19 13:02:20.000000000 +0000
+++ default.php 2009-03-19 13:45:16.000000000 +0000
@@ -73,7 +73,7 @@
//which tags should simply be removed (be warned, most of these are here because they are not safe
//enough to allow/clean, remove at your own risk)
-$Html_DisallowedTags = array('link', 'iframe', 'frame', 'frameset', 'object', 'param', 'embed', 'style',
+$Html_DisallowedTags = array('link', 'iframe', 'frame', 'frameset', 'object', 'param', 'style',
'applet', 'meta', 'layer', 'import', 'xml', 'script', 'body', 'html', 'head', 'title', 'ilayer');
//don't parse anything in these tags Any problems with these instructions, just let me know!
you might not have noticed this:
http://lussumo.com/addons/index.php?PostBackAction=AddOn&AddOnID=434
It can support anything you want and works on the server, client side or both.
This seems to be PHP5 only because of the use of stripos() so i added a bit of code before the start of the class so that it becomes php4 and php5 compatible.
if (!function_exists('stripos')) {
function stripos($haystack, $needle){
return strpos($haystack, stristr( $haystack, $needle ));
}
}
fixed compatibility with PHP4 (thanks garethablett!)
@kelvin: you say you "need support for Attachments 2.1", what do you mean exactly? If you want mpg/flv attachments to display in-line, I think you should ask in the Inline Images 1.3 extension, or the Attachments 2.1 extension. The AutoLinks extension is only really for turning links in to embedded content.
this is just superb plugin!! i appreciate! could you please tell me how to add url w/ mp3 player. i'd like to provide listening inside the topic but file's address as well.
I guess it means image and YouTube links will automatically display I love this extension. I wish someone will find a way to create one like Google video/audio chat
Raize, you mentioned using AutoLinks and BlogThis. I'm using both of those addons, too, but AutoLinks doesn't seem to do anything for BlogThis. Example: rewild.info. Has anybody gotten these two to work together? Any ideas on how I might accomplish that? I'm not adverse to modifying some source code if need be, but any insight you can offer is much appreciated.
Comments
Getting AutoLinks to work with Markdown Formatter
To get AutoLinks to work nicely with the Markdown Formatter, you need to also have the HTML Foramtter installed and you need to modify both the Markdown Formatter and the HTML Formatter. I will give full instructions below, but...If you just want a get it working, you can download an already-modified versions of the Markdown Formatter 1.1.2 and the HTML Formatter 2.4 from here and here.
If you would rather make the modifications manually, here are the steps involved.
First, you need to get the Markdown Formatter to honour it's child formatters and accept HTML (which it should, as per the Markdown spec., but doesn't by default). This can be done with the following patch:
--- default.php.orig 2009-03-13 15:57:59.000000000 +0000 +++ default.php 2009-03-19 15:10:45.000000000 +0000 @@ -17,13 +17,21 @@ class MarkdownFormatter extends StringFormatter { function Parse($String, $Object, $FormatPurpose) { if ($FormatPurpose == FORMAT_STRING_FOR_DISPLAY) { - $String = $this->ProtectString($String); - return Markdown($String); + $String = $this->ParseChildren($String, $Object, $FormatPurpose); + if( isset( $Object->Context->StringManipulator->Formatters[ "Html" ] ) ) { + $String = Markdown( $String ); + $String = $Object->Context->StringManipulator->Formatters[ "Html" ]->Execute( $String, true ); + } + else { + $String = $this->EscapeHtml( $String ); + $String = Markdown( $String ); + } + return $String; } else { return $String; } } - function ProtectString ($String) { + function EscapeHtml ($String) { //$String = str_replace("<", "<", $String); // $String = str_replace(">", ">", $String); $String = explode("\n", $String);
Second, you need to modify the HTML Formatter to allow the Markdown formatter to use it's parsing abilities. The following patch will achieve this:
--- default.php.orig 2009-03-19 13:02:20.000000000 +0000 +++ default.php 2009-03-19 13:04:46.000000000 +0000 @@ -111,7 +111,7 @@ $this->TagArray = &$GLOBALS['Html_TagArray']; } - function Execute($String) + function Execute($String, $ParseOnly) { $this->TagArray = array('normal' => array(), 'extraclosing' => array()); $String = str_replace(chr(0), ' ', $String); @@ -172,7 +172,7 @@ $sReturn ); - if(HTML_CONVERT_NEWLINES) + if(HTML_CONVERT_NEWLINES && !$ParseOnly) $sReturn = str_replace( array("\r\n", "\r", "\n"), '<br />', @@ -389,7 +389,7 @@ function Parse($String, $Object, $FormatPurpose) { - if($FormatPurpose == FORMAT_STRING_FOR_DISPLAY) $sReturn = $this->Execute($String); + if($FormatPurpose == FORMAT_STRING_FOR_DISPLAY) $sReturn = $this->Execute($String, false); else $sReturn = $String; return $this->ParseChildren($sReturn, $Object, $FormatPurpose);
Finally, you need to allow the "embed" tag through the HTML Formatter (which is disallowed by default). To achieve this, you need to remove 'embed' from the list of disallowed tags on line 76 in HTML Formatter's default.php. The following patch will achieve this:
--- default.php.orig 2009-03-19 13:02:20.000000000 +0000 +++ default.php 2009-03-19 13:45:16.000000000 +0000 @@ -73,7 +73,7 @@ //which tags should simply be removed (be warned, most of these are here because they are not safe //enough to allow/clean, remove at your own risk) -$Html_DisallowedTags = array('link', 'iframe', 'frame', 'frameset', 'object', 'param', 'embed', 'style', +$Html_DisallowedTags = array('link', 'iframe', 'frame', 'frameset', 'object', 'param', 'style', 'applet', 'meta', 'layer', 'import', 'xml', 'script', 'body', 'html', 'head', 'title', 'ilayer'); //don't parse anything in these tags
Any problems with these instructions, just let me know!
grep is your friend.
- added support for metacafe
- fixed compatibility with PHP4 (thanks garethablett!)
@kelvin: you say you "need support for Attachments 2.1", what do you mean exactly? If you want mpg/flv attachments to display in-line, I think you should ask in the Inline Images 1.3 extension, or the Attachments 2.1 extension. The AutoLinks extension is only really for turning links in to embedded content.could you please tell me how to add url w/ mp3 player. i'd like to provide listening inside the topic but file's address as well.
The other greatest Vanilla plugin never invented is BlogThis by Spode...now if only they could work together we could blow this joint.
This is extension is HOT! Thank you.
- force creation of a link rather than embedding by prefixing the URL with a '!'
- added support for tangle.com
@Bentot: I thought "AutoLinks" sounds like it'll automatically create links. This doesn't really explain the embedding though...Can anyone think of any obvious video sites that aren't supported?
I love this extension. I wish someone will find a way to create one like Google video/audio chat