styx31
  •  styx31
  • 69.2% (Friendly)
  • YAF Lover Topic Starter
2010-10-26T16:06:27Z
I'm trying to use nested bbcode modules and the result is quite strange.

Here is my test code, in CustomBBCodes.cs in App_Code folder :


namespace YAF.Modules {
  using System.Web.UI;
  public class FirstBBCodeModule : YafBBCodeControl {
    protected override void Render(HtmlTextWriter writer) {
      writer.Write("<div style=\"border: 1px solid red\">");
      writer.Write(this.Parameters["inner"]);
      writer.Write("</div>");
    }
  }

  public class SecondBBCodeModule : YafBBCodeControl {
    protected override void Render(HtmlTextWriter writer) {
      writer.Write("<div style=\"border: 1px solid red\">");
      writer.Write(this.Parameters["inner"]);
      writer.Write("</div>");
    }
  }
}


And the Exported XML :

<YafBBCodeList>
  <YafBBCode>
    <Name>FIRST</Name>
    <Description>[first]text[/first]</Description>
    <OnClickJS />
    <DisplayJS />
    <EditJS />
    <DisplayCSS />
    <SearchRegex>\[first\](?&lt;inner&gt;.*?)\[/first\]</SearchRegex>
    <ReplaceRegex />
    <Variables />
    <UseModule>true</UseModule>
    <ModuleClass>YAF.Modules.FirstBBCodeModule</ModuleClass>
    <ExecOrder>1</ExecOrder>
  </YafBBCode>
  <YafBBCode>
    <Name>SECOND</Name>
    <Description>[second]text[/second]</Description>
    <OnClickJS />
    <DisplayJS />
    <EditJS />
    <DisplayCSS />
    <SearchRegex>\[second\](?&lt;inner&gt;.*?)\[/second\]</SearchRegex>
    <ReplaceRegex />
    <Variables />
    <UseModule>true</UseModule>
    <ModuleClass>YAF.Modules.SecondBBCodeModule</ModuleClass>
    <ExecOrder>1</ExecOrder>
  </YafBBCode>
</YafBBCodeList>


And the bbcode I've used :

[first]begin first[second]second[/second]end first[/first]


or

[second]begin first[first]second[/first]end first[/second]


In each case, I've got incorrect html :

<div style="border: 1px solid green">begin first
<YafModuleFactoryInvocation ClassName="YAF.Modules.SecondBBCodeModule"><Parameters><Param Name="inner">second</div>end first</Param></Parameters></YafModuleFactoryInvocation>
Sponsor
styx31
  •  styx31
  • 69.2% (Friendly)
  • YAF Lover Topic Starter
2010-10-26T16:14:02Z
I've tried to replace writer.Write(inner) by writer.Write(this.ProcessBBCodeString(inner)) without success : because the input is already translated into <YafModuleFactoryInvocation ...>, it's rendered as encoded html.
styx31
  •  styx31
  • 69.2% (Friendly)
  • YAF Lover Topic Starter
2010-10-26T16:28:06Z
Ok, Got it.

For now, it CAN'T work, because of MessageBase.cs code : the regulax expression _rgxModule will match the first closing </YafModuleFactoryInvocation>, resulting in broken rendering.
bbobb
  •  bbobb
  • 100% (Exalted)
  • YAF Developer
2010-10-27T00:26:49Z
It's a strange problem, because I can see it in Safari as guest.


Updated: created an issue on YAF tracker.
styx31
  •  styx31
  • 69.2% (Friendly)
  • YAF Lover Topic Starter
2010-10-30T07:02:13Z
styx31
  •  styx31
  • 69.2% (Friendly)
  • YAF Lover Topic Starter
2010-10-30T07:06:21Z
I've seen the issue  in the tracker, but I wan't to precise that there is certainly also a specific problem when you use nested modules bbcodes.

See example before : I've written 2 nested spoilers (which use SpoilerBBCodeModule). If you read the source (not with a html inspector like firebug !), you will find this html code (localized in french here) :


<!-- BEGIN spoiler -->

<div class="spoilertitle">

<input type="button" value="Afficher spoiler" class="spoilerbutton" name="spoilerBtn39708" onclick='toggleSpoiler(this,"spoil_bb4ab");' title="Cliquez ici pour afficher ou masquer le texte cach&#233; (aussi appell&#233; spoiler)" /></div><div class="spoilerbox" id="spoil_bb4ab" style="display:none">First Spoiler<br /><br />
<YafModuleFactoryInvocation ClassName="YAF.Modules.SpoilerBBCodeModule">
<Parameters><Param Name="inner">Nested Spoiler

</div>

<!-- END spoiler -->

<br /><br />End First Spoiler</Param>
</Parameters>
</YafModuleFactoryInvocation>

About Us

The YAF.NET is an open source .NET forum project. YAF.NET is supported by an team of international developers who are build community by building community software.

Powered by Resharper Donate with PayPal button

Project Twitter Updates

Copyright © YetAnotherForum.NET & Ingo Herbote. All rights reserved