Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Try Vanilla Forums Cloud product
Vanilla 1 is no longer supported or maintained. If you need a copy, you can get it here.


This discussion is related to the AutoLinks addon.
edamedam New
edited October 2009 in Vanilla 1.0 Help


  • Uploaded version 1.0 of AutoLinks.
  • Uploaded version 1.1 of AutoLinks.
  • 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("<", "&lt;", $String); // $String = str_replace(">", "&gt;", $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:

    It can support anything you want and works on the server, client side or both.

    grep is your friend.

  • good job. but I need support for Attachments 2.1 (image or mpeg or flv..). please??
  • 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 ));
  • does it support video?
  • i found that it doesn't support metacafe
  • Uploaded version 1.2 of AutoLinks.
  • version 1.2:
    • 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.
  • thanks for the metacafe.
  • 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.
  • RaizeRaize vancouver ✭✭
    This is one of the greatest Vanilla plugins ever invented. Thank you Edam!

    The other greatest Vanilla plugin never invented is BlogThis by if only they could work together we could blow this joint.
  • Forgive my stupid question but what do you mean by AutoLinks?

    This is extension is HOT! Thank you.
  • Uploaded version 1.3 of AutoLinks.
  • version 1.3:
    • force creation of a link rather than embedding by prefixing the URL with a '!'
    • added support for
    @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?
  • 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
  • Now I will make you responsible to rewrite it for Vanila2. :)
  • 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: 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.
  • Hmm, these two extension *should* work together. I'll look in to why they aren't...
  • Version number changed from 1.3 to 1.4.
  • Uploaded version 1.4 of AutoLinks.
  • version 1.4:
    • made compatible with BlogThis extension
    • added fullscreen buttons to google videos and youtube
    • added support for
    @jefgodesky, @Raize: there you go! :o)
  • Thank you! Works great!
  • 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.
  • Does this work with FCKeditor? For some reason I paste a youtube url and it doesn't turn it into embedded video. Thanks

  • Ultra-cool - works perfectly with YouTube! (on a plain Vanilla forum editor)
  • @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.
  • How difficult would be convert this addon into Vanila2?
  • 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.
Sign In or Register to comment.