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']; }
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!
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.
Thanks for this plugin! It is great.
I'd like to know -if possible- if there is a way to use it by linking a thumbnail to a larger image as opposed to just creating a text hyperlink. Right now I can modify the text/url and make it an anchor text via the wiki plugin as autolink does not offer this text add-on. I would also like to know if there is a way to automagically embed FLVs files into a comment. I know auotlink supports specific video sites like youtube and similar but want to know if in the future dropping an FLV url will get converted into a flash movie inside a comment.
@usor: I don't think I can make AutoLinks automatically embed flash, like it does with images, because, unlike images, the width and height of the flash object would need to be specified when embedding it. (Someone please correct me if I'm wrong!). What you could do though, if you have the HTML Formatter addon, is embed the flash object manually with HTML. As for thumbnails - I like the idea. I'll have to give some thought as to how you'd specify that you wanted a thumbnail rather than a text link or an embedded image. If you've got any ideas, feel free to post them!
@rayk: I'll look in to this when I've got a moment.
I don't know. V2 works very differently to V1, so it'll take a small amount of work (though it's not a complicated addon). I was going to take a look at it sometime and port it.
Comments
- Spam
- Abuse
- Troll
0 • Off Topic Insightful Awesome LOL •- Spam
- Abuse
- Troll
0 • Off Topic Insightful Awesome LOL •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!
- Spam
- Abuse
- Troll
0 • Off Topic Insightful Awesome LOL •Don't PM about development, I'm not currently taking on clients.
grep is your friend.
- Spam
- Abuse
- Troll
0 • Off Topic Insightful Awesome LOL •- Spam
- Abuse
- Troll
0 • Off Topic Insightful Awesome LOL •- Spam
- Abuse
- Troll
0 • Off Topic Insightful Awesome LOL •- Spam
- Abuse
- Troll
0 • Off Topic Insightful Awesome LOL •- Spam
- Abuse
- Troll
0 • Off Topic Insightful Awesome LOL •- Spam
- Abuse
- Troll
0 • Off Topic Insightful Awesome LOL •- 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.- Spam
- Abuse
- Troll
0 • Off Topic Insightful Awesome LOL •- Spam
- Abuse
- Troll
0 • Off Topic Insightful Awesome LOL •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.
- Spam
- Abuse
- Troll
0 • Off Topic Insightful Awesome LOL •The other greatest Vanilla plugin never invented is BlogThis by Spode...now if only they could work together we could blow this joint.
- Spam
- Abuse
- Troll
0 • Off Topic Insightful Awesome LOL •This is extension is HOT! Thank you.
- Spam
- Abuse
- Troll
0 • Off Topic Insightful Awesome LOL •- Spam
- Abuse
- Troll
0 • Off Topic Insightful Awesome LOL •- 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... :o)Can anyone think of any obvious video sites that aren't supported?
- Spam
- Abuse
- Troll
0 • Off Topic Insightful Awesome LOL •I love this extension. I wish someone will find a way to create one like Google video/audio chat
- Spam
- Abuse
- Troll
0 • Off Topic Insightful Awesome LOL •- Spam
- Abuse
- Troll
0 • Off Topic Insightful Awesome LOL •- Spam
- Abuse
- Troll
0 • Off Topic Insightful Awesome LOL •- Spam
- Abuse
- Troll
0 • Off Topic Insightful Awesome LOL •- Spam
- Abuse
- Troll
0 • Off Topic Insightful Awesome LOL •- Spam
- Abuse
- Troll
0 • Off Topic Insightful Awesome LOL •- made compatible with BlogThis extension
- added fullscreen buttons to google videos and youtube
- added support for LiveLeaks.com
@jefgodesky, @Raize: there you go! :o)- Spam
- Abuse
- Troll
0 • Off Topic Insightful Awesome LOL •- Spam
- Abuse
- Troll
0 • Off Topic Insightful Awesome LOL •- Spam
- Abuse
- Troll
0 • Off Topic Insightful Awesome LOL •- Spam
- Abuse
- Troll
0 • Off Topic Insightful Awesome LOL •Ultra-cool - works perfectly with YouTube! (on a plain Vanilla forum editor)
- Spam
- Abuse
- Troll
0 • Off Topic Insightful Awesome LOL •@rayk: I'll look in to this when I've got a moment.
- Spam
- Abuse
- Troll
0 • Off Topic Insightful Awesome LOL •- Spam
- Abuse
- Troll
0 • Off Topic Insightful Awesome LOL •- Spam
- Abuse
- Troll
0 • Off Topic Insightful Awesome LOL •