--
JosKunnekes - 11 Jun 2007
Thank you Jos for contributing this plugin and for sharing it with the
TWikiCommunity!
BTW, the
EditSyntaxPlugin could support the BB code. This can be done by creating a
BBCodeEditSyntaxRegex topic that translates the TML to BB code, and back to TML.
--
PeterThoeny - 12 Jun 2007
Ah, oke. I will have a look at it, and see if I can create a converter for bbcode.
--
JosKunnekes - 12 Jun 2007
I have found some issues and tried to fix them.
1. In code block, it still join lines ending in '\'
Modify
BBCodePlugin.pm to handle \\n at commonTagsHandler()
--- BBCodePlugin.pm-orig 2007-06-11 22:41:48.000000000 +0800
+++ BBCodePlugin.pm 2008-11-28 19:40:05.000000000 +0800
@@ -73,7 +73,22 @@ sub initPlugin {
sub commonTagsHandler {
# my ( $text, $topic, $web ) = @_;
-
+ # keira 20081128: avoid joining lines end with \ in code block
+ my $incode;
+ my @codeblock;
+ foreach my $line (split(/\r?\n/, $_[0])) {
+ if ( $line =~ /\[code[^\]]*\]/ ){
+ $incode = 1;}
+ if ( $line =~ /\[\/code\]/ ){
+ $incode = 0;
+ }
+ if ($incode){
+ $line =~ s/\\$/\\\\\n/gs;
+ }
+ push(@codeblock, $line);
+ }
+
+ $_[0] = join("\n", @codeblock)."\n";
}
sub preRenderingHandler {
2. it will add additional space in code block (before "[" and after "]")
Modify
BBCodePlugin/BBCode.pm
--- BBCode.pm-orig 2007-06-27 17:12:22.000000000 +0800
+++ BBCode.pm 2008-11-29 07:26:56.000000000 +0800
@@ -314,7 +315,8 @@ sub _do_BB {
# Closing tag is kinda useless, pop it
pop(@buf);
# Rest should be content;
- my $content = join(' ', @buf);
+ #my $content = join(' ', @buf);
+ my $content = join('', @buf); # modified by keirachen@zyxel 20081208 (fix the additional space issue)
# What are we dealing with anyway? Any attributes maybe?
if($open =~ /\[([^=\]]+)=?([^\]]+)?]/) {
--
KeiraChen - 11 Dec 2008
I have also did a modification that can let users to define the color of code block
Use [code=color:white;bgcolor:black] to define the style
-
color:...
to set the color of text
-
bgcolor:...
to set the background color in the code block
Modified file:
/var/www/htdocs/lib/TWiki/Plugins/BBCodePlugin/BBCode.pm
(detail as attachment file: BBCode.pm.20081209.diff)
--
KeiraChen - 11 Dec 2008
Thank you Keira for providing the patches. The author of this plugin set the
ModificationPolicy to
PleaseFeelFreeToModify, so please go ahead and update plugin code and doc, and attach it to the plugin topic.
ReadmeFirst gets you started.
--
PeterThoeny - 11 Dec 2008