Tags:
create new tag
view all tags

BBCodePluginDev Discussion: Page for developer collaboration, enhancement requests, patches and improved versions on BBCodePlugin contributed by the TWikiCommunity.
• Please let us know what you think of this extension.
• For support, check the existing questions, or ask a new support question in the Support web!
• Please report bugs below

Feedback on BBCodePlugin

-- 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

Topic attachments
I Attachment History Action Size Date Who Comment
Unknown file formatdiff BBCode.pm.20081209.diff r1 manage 2.6 K 2008-12-11 - 12:01 UnknownUser Let users define the color of code block
Edit | Attach | Watch | Print version | History: r5 < r4 < r3 < r2 < r1 | Backlinks | Raw View | Raw edit | More topic actions
Topic revision: r5 - 2008-12-11 - PeterThoeny
 
  • Learn about TWiki  
  • Download TWiki
This site is powered by the TWiki collaboration platform Powered by Perl Hosted by OICcam.com Ideas, requests, problems regarding TWiki? Send feedback. Ask community in the support forum.
Copyright © 1999-2024 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.