1 joebeone Dec 18, 2004 02:47
3 joebeone Dec 18, 2004 05:05
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/~jhall/b2evo_markdown/_markdown.renderer.php
this should work too (beyond when I leave Berkeley):
http://pobox.com/~joehall/b2evo_markdown/
Here is the 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() );
?>
4 mattbta Dec 18, 2004 15:23
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.
5 joebeone Dec 18, 2004 18:33
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/b2evo_markdown/b2evo_markdown.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/index.php/2004/12/17/b2evo_markdown
6 fumanchu Jan 27, 2005 02:27
+1 putting this in default distro
7 fumanchu Jan 27, 2005 22:19
Here's a version which works with the new plugin architecture in current CVS:
<?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;
}
}
?>
8 subzane Jul 25, 2006 14:07
How do I make this work for summer beta 1.8?
9 bjornbjorn Oct 10, 2006 07:57
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?
10 bjornbjorn Oct 10, 2006 20:50
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 ;)
- bjorn
11 village_idiot Oct 10, 2006 21:12
http://bie.no/blog/products/2006/10/markdown-extra-plugin-for-b2evolution/
there ya go, bjornbjorn it was *products* that was getting caught, btw :)
12 bjornbjorn Oct 11, 2006 07:58
haha, yeah I was wondering about that ;)
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 ;)
- bjorn
13 john Oct 11, 2006 08:13
@ bjornbjorn
Thanks for this.... I assume it for posting and cannot be applied to "comments" !
14 bjornbjorn Oct 11, 2006 08:57
That's right, it currently only works for posts.
I guess that's because [url=http://doc.b2evolution.net/v-1-8/plugins/Plugin.html#RenderItemAsHtml]RenderItemAsHtml[/url] 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...
15 yabba Oct 11, 2006 09:41
You want to use the FilterCommentContent hook ;)
function FilterCommentContent( & $params )
{
return $this->RenderItemAsHtml( $params )
}
¥
16 bjornbjorn Oct 11, 2006 11:28
Thanks! :-)
I'll implement this as an optional setting as I don't think everyone would want Markdown enabled for comments.
17 john Oct 11, 2006 12:11
I'll implement this as an optional setting as I don't think everyone would want Markdown enabled for comments.
Sounds good... look forward to it
18 bjornbjorn Oct 11, 2006 19:02
Ok, I've updated the plugin to support comments as well.
It's disabled by default - so after install you will need to enable it in the plugin config.
enjoy :-)
19 john Oct 11, 2006 19:44
@ bjornbjorn
I just downloaded it again and Winmerge picked up no differences. Is the original download URL the correct one for the updated files?
20 bjornbjorn Oct 12, 2006 08:59
ah, my bad, uploaded with wrong filename:
Here's the file:
http://www.bie.no/products/b2evo_markdown_extra.zip
Instructions if needed:
http://www.bie.no/blog/?p=57
- bjorn
21 john Oct 12, 2006 11:09
Sweet... does what it says on the label.
Thanks bjornbjorn
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?