[PLUGIN] Markdown comes to b2evo
Goto page 1, 2  Next
 
Post new topic   Reply to topic   printer-friendly view    b2evolution Forum Index -> Plugins & Extensions
View previous topic :: View next topic  
Author Message
joebeone
Seasoned Poster
Seasoned Poster

Joined: 14 Jul 2004
Posts: 56
Reputation: 41.1Reputation: 41.1Reputation: 41.1Reputation: 41.1 add or subtract from this member's reputationadd or subtract from this member's reputation
votes: 1

PostPosted: Fri Dec 17, 2004 20:47    Post subject: [PLUGIN] Markdown comes to b2evo Reply with quote

I've developed a simple plugin so that b2evo users can write posts in Markdown syntax. Here's the plugin:

http://www.sims.berkeley.edu/~..._markdown/

and here's more on markdown from John Gruber:

http://daringfireball.net/projects/markdown/
Back to top
View user's profile Send private message Visit poster's website
EdB
/bb|[^b]{2}/

Joined: 05 Jan 2004
Posts: 7123
Reputation: 140.9 add or subtract from this member's reputationadd or subtract from this member's reputation
votes: 90

PostPosted: Fri Dec 17, 2004 21:46    Post subject: Reply with quote

Got a link that works? The link in your post gives me what looks like an open directory with info about the plugin, but there is no way to get the plugin from the link in the top portion. The link following [plugin] : in the text (a pobox link) tells me "Unable to Complete Request". Can you save it as a .txt file and link to that, or maybe zip it up and link to the zip?
Back to top
View user's profile Send private message
joebeone
Seasoned Poster
Seasoned Poster

Joined: 14 Jul 2004
Posts: 56
Reputation: 41.1Reputation: 41.1Reputation: 41.1Reputation: 41.1 add or subtract from this member's reputationadd or subtract from this member's reputation
votes: 1

PostPosted: Fri Dec 17, 2004 23:05    Post subject: Reply with quote

sorry... the link was broken as posted. Here's a direct link (don't access this directly, right-click save as):

http://www.sims.berkeley.edu/~...nderer.php

this should work too (beyond when I leave Berkeley):

http://pobox.com/~joehall/b2evo_markdown/

Here is the code:
Code:

<?php

/**

 * This file implements John Gruber's Markdown language using Michel Fortin's PHP Markdown

 *

 * b2evolution - {@link http://b2evolution.net/}

 * Released under GNU GPL License - {@link http://b2evolution.net/about/license.html}

 * @copyright (c)2003-2004 by Francois PLANQUE - b2evolution - {@link http://fplanque.net/}

 * @copyright (c)2004 by John Gruber - Markdown - {@link http://daringfireball.net/projects/markdown/}

 * @copyright (c)2004 by Michel Fortin - PHP Markdown- {@link http://www.michelf.com/projects/php-markdown/}

 * @copyright (c)2004 by Joseph Lorenzo Hall - b2evo renderer- {@link http://pobox.com/~joehall/}

 *

 * @package plugins

 */

if( !defined('DB_USER') ) die( 'Please, do not access this page directly.' );



/**

 * Includes:

 */

require_once dirname(__FILE__).'/../renderer.class.php';

include_once "markdown.php";



/**

 * @package plugins

 */

class markdown_Rendererplugin extends RendererPlugin

{

   var $code = 'b2evMrkdwn';

   var $name = 'Markdown';

   var $priority = 60;



   var $apply_when = 'opt-out';

   var $apply_to_html = true;

   var $apply_to_xml = false;

   var $short_desc;

   var $long_desc;





   /**

    * Constructor

    *

    * {@internal markdown_Rendererplugin::markdown_Rendererplugin(-)}}

    */

   function markdown_Rendererplugin()

   {

      $this->short_desc = T_('Parse Markdown syntax and make HTML');

      $this->long_desc = T_('No description available');

   }





   /**

    * Perform rendering

    *

    * {@internal markdown_Rendererplugin::render(-)}}

    *

    * @param string content to render (by reference) / rendered content

    * @param string Output format, see {@link format_to_output()}

    * @return boolean true if we can render something for the required output format

    */

   function render( & $content, $format )

   {

      if( ! parent::render( $content, $format ) )

      {   // We cannot render the required format

         return false;

      }

   

      $content = Markdown( $content );

      

      return true;

   }

}



// Register the plugin:

$this->register( new markdown_Rendererplugin() );



?>
Back to top
View user's profile Send private message Visit poster's website
mattbta
Seasoned Poster
Seasoned Poster

Joined: 20 Jun 2004
Posts: 87
Reputation: 25.9Reputation: 25.9Reputation: 25.9 add or subtract from this member's reputationadd or subtract from this member's reputation

PostPosted: Sat Dec 18, 2004 9:23    Post subject: Reply with quote

Ok, two things on this.

1. Make a zip file for download with both your plugin and the markup.php file, and let the user know to extract both to their plugins/renderers dir for 'out of the box functionality'.

2. Since this creates paragraph tags automagically, you mighttell the users to disable auto-p plugin as I can't tell if this will have undesired side effects for posts. On my test with a single line there was no ill effects, but I'm not sure if things will be confused with many paragraph (EdB wordy) posts.


Other than that, looks like a good plugin. Nice job.
Back to top
View user's profile Send private message Send e-mail Visit poster's website
joebeone
Seasoned Poster
Seasoned Poster

Joined: 14 Jul 2004
Posts: 56
Reputation: 41.1Reputation: 41.1Reputation: 41.1Reputation: 41.1 add or subtract from this member's reputationadd or subtract from this member's reputation
votes: 1

PostPosted: Sat Dec 18, 2004 12:33    Post subject: slight changes Reply with quote

mattbta wrote:

1. Make a zip file for download with both your plugin and the markup.php file, and let the user know to extract both to their plugins/renderers dir for 'out of the box functionality'.

2. Since this creates paragraph tags automagically, you mighttell the users to disable auto-p plugin as I can't tell if this will have undesired side effects for posts. On my test with a single line there was no ill effects, but I'm not sure if things will be confused with many paragraph (EdB wordy) posts.


Done and done. The Zip file is here:

http://pobox.com/~joehall/b2ev...rkdown.zip

And by looking at the parent directory you should see the README file which tells users to disable all default plugins save "_autolinks.renderer.php":

http://pobox.com/~joehall/b2evo_markdown/

Finally, here's a post that uses the exact same syntax as the README file, but parsed via the plugin into HTML:

http://pobox.com/~joehall/nqb2...o_markdown
Back to top
View user's profile Send private message Visit poster's website
fumanchu
New Poster
New Poster

Joined: 26 Jan 2005
Posts: 6
Reputation: 15.6Reputation: 15.6 add or subtract from this member's reputationadd or subtract from this member's reputation

PostPosted: Wed Jan 26, 2005 20:27    Post subject: Reply with quote

+1 putting this in default distro
Back to top
View user's profile Send private message
fumanchu
New Poster
New Poster

Joined: 26 Jan 2005
Posts: 6
Reputation: 15.6Reputation: 15.6 add or subtract from this member's reputationadd or subtract from this member's reputation

PostPosted: Thu Jan 27, 2005 16:19    Post subject: Current CVS version Reply with quote

Here's a version which works with the new plugin architecture in current CVS:

Code:

<?php
/**
 * This file implements John Gruber's Markdown language using Michel Fortin's PHP Markdown
 *
 * b2evolution - {@link http://b2evolution.net/}
 * Released under GNU GPL License - {@link http://b2evolution.net/about/license.html}
 * @copyright (c)2003-2004 by Francois PLANQUE - b2evolution - {@link http://fplanque.net/}
 * @copyright (c)2004 by John Gruber - Markdown - {@link http://daringfireball.net/projects/markdown/}
 * @copyright (c)2004 by Michel Fortin - PHP Markdown- {@link http://www.michelf.com/projects/php-markdown/}
 * @copyright (c)2004 by Joseph Lorenzo Hall - b2evo renderer- {@link http://pobox.com/~joehall/}
 *
 * @package plugins
 */
if( !defined('DB_USER') ) die( 'Please, do not access this page directly.' );

/**
 * Includes:
 */
include_once "markdown.php";

/**
 * @package plugins
 */
class markdown_plugin extends Plugin
{
   var $code = 'b2evMrkdwn';
   var $name = 'Markdown';
   var $priority = 60;

   var $apply_when = 'opt-out';
   var $apply_to_html = true;
   var $apply_to_xml = false;
   var $short_desc;
   var $long_desc;


   /**
    * Constructor
    *
    * {@internal markdown_plugin::markdown_plugin(-)}}
    */
   function markdown_plugin()
   {
      $this->short_desc = T_('Parse Markdown syntax and make HTML');
      $this->long_desc = T_('No description available');
   }


   /**
    * Perform rendering
    *
    * {@internal markdown_plugin::Render(-)}}
    *
    * @param array Associative array of parameters
    *                      (Output format, see {@link format_to_output()})
    * @return boolean true if we can render something for the required output format
    */
   function Render( & $params )
   {
      if( ! parent::Render( $params ) )
      {   // We cannot render the required format
         return false;
      }
      
      $content = & $params['data'];
      $content = Markdown( $content );
      
      return true;
   }

}

?>
Back to top
View user's profile Send private message
subzane
New Poster
New Poster

Joined: 25 Jul 2006
Posts: 1
add or subtract from this member's reputationadd or subtract from this member's reputation

PostPosted: Tue Jul 25, 2006 7:07    Post subject: Reply with quote

How do I make this work for summer beta 1.8?
Back to top
View user's profile Send private message
bjornbjorn
New Poster
New Poster

Joined: 10 Oct 2006
Posts: 8
Reputation: 1.8 add or subtract from this member's reputationadd or subtract from this member's reputation

PostPosted: Tue Oct 10, 2006 0:57    Post subject: Reply with quote

I'd also like to know this :-)

Has anyone updated this plugin for 1.8 or can someone outline the steps needed to get this to work?
Back to top
View user's profile Send private message
bjornbjorn
New Poster
New Poster

Joined: 10 Oct 2006
Posts: 8
Reputation: 1.8 add or subtract from this member's reputationadd or subtract from this member's reputation

PostPosted: Tue Oct 10, 2006 13:50    Post subject: Reply with quote

Hi, I've implemented the PHP Markdown Extra from Michel Fortin as a plugin for b2evo.

It works with the latest version (1.8.2) and can be downloaded here:
http://bie.no/blog/?p=57

I needed to do Apply rendering: 'always' to get it to work properly .. let me know if I did something wrong Wink

- bjorn
Back to top
View user's profile Send private message
whoo
Forum Admin
Forum Admin

Joined: 25 Dec 2004
Posts: 1293
Reputation: 100.1 add or subtract from this member's reputationadd or subtract from this member's reputation
votes: 19

PostPosted: Tue Oct 10, 2006 14:12    Post subject: Reply with quote

http://bie.no/blog/products/20...evolution/

there ya go, bjornbjorn it was *products* that was getting caught, btw Smile

_________________

Do you use last.fm?
Try out my nifty badge generator!
Back to top
View user's profile Send private message Visit poster's website
bjornbjorn
New Poster
New Poster

Joined: 10 Oct 2006
Posts: 8
Reputation: 1.8 add or subtract from this member's reputationadd or subtract from this member's reputation

PostPosted: Wed Oct 11, 2006 0:58    Post subject: Reply with quote

haha, yeah I was wondering about that Wink

for those of you who don't know what we're talking about I submitted the form about three times but got a message that I was spamming Wink

- bjorn
Back to top
View user's profile Send private message
John
the uncertain

Joined: 22 Jun 2004
Posts: 2147
Reputation: 4.6Reputation: 4.6Reputation: 4.6Reputation: 4.6 add or subtract from this member's reputationadd or subtract from this member's reputation
votes: 27

PostPosted: Wed Oct 11, 2006 1:13    Post subject: Reply with quote

@ bjornbjorn
Thanks for this.... I assume it for posting and cannot be applied to "comments" !

_________________
See the Sites in in Venice
Back to top
View user's profile Send private message Visit poster's website
bjornbjorn
New Poster
New Poster

Joined: 10 Oct 2006
Posts: 8
Reputation: 1.8 add or subtract from this member's reputationadd or subtract from this member's reputation

PostPosted: Wed Oct 11, 2006 1:57    Post subject: Reply with quote

That's right, it currently only works for posts.

I guess that's because RenderItemAsHtml doesn't get called on comments.

Does comments call RenderItem()? - because then it would be pretty easy to make it work with comments as well...
Back to top
View user's profile Send private message
¥åßßå
Blonde Bimbo

Joined: 07 Jan 2005
Posts: 6579
Reputation: 29.5Reputation: 29.5Reputation: 29.5 add or subtract from this member's reputationadd or subtract from this member's reputation
votes: 115

PostPosted: Wed Oct 11, 2006 2:41    Post subject: Reply with quote

You want to use the FilterCommentContent hook Wink

Code:
   function FilterCommentContent( & $params )
   {
      return $this->RenderItemAsHtml( $params )
   }


¥

_________________
I may have opened the door but you entered of your own free will
normal life wrote:
yabba_hh: I think, I type, I read what I type, I think "fuck, what was I thinking when I typed that?!"
tuxnus: that's two more thoughts than I give you credit for
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    b2evolution Forum Index -> Plugins & Extensions All times are GMT - 5 Hours
Goto page 1, 2  Next
Page 1 of 2


 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
b2evolution Support Forum RSS Feed Forums powered by php Bulletin Board