Vanilla 1 is no longer supported or maintained. If you need a copy, you can get it here.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.
Options

Extension: BBCodeParser

StashStash
edited March 2007 in Vanilla 1.0 Help
Tired of waiting for BetterBBCode to get better? Then give the new BBCodeParser a go. It works well with the BBInsertBar and has great formatting flexibility supporting even more BBCode. It will happily sit along side other text formatters as well.

*** Nested Lists!
*** Hacked in support for YouTube video via the [youtube][/youtube] tag
*** Easy to update to newer versions of the PEAR HTML_BBCodeParser
*** Requires PEAR in your PHP installation

To do:
+ Create Video.php filter to include other video sites such as Google, MSN SoapBox, Metacafe et al and move the ugly hack for YouTube to there to make it nice and smart.
+ Add options screen to make the tags configurable, ie. arbitarily disable any BBCode tags you dislike. Initially, this could work broadly by disabling whole filters.

This extension uses Seth Price's version of the PHP PEAR HTML_BBCodeParser which fixes many of the official bugs listed on the official site.
«1

Comments

  • Options
    hey stash. i got a white/blank screen when i activated this. (trying to view post.php).
  • Options
    StashStash
    edited January 2007
    No error messages of any kind?

    How blank? Just where the content area, or even the header and navs?

    Also, which other extensions do you have installed and activated?
  • Options
    Anyone else having this trouble?
  • Options
    Works fine for me, no error, no blank pages. But when I change from BetterBBCode to BBCodeParser, I loose many line breaks in comments, rendering them very hard to read!
  • Options
    But when used together with AutoP, it works exactly as expected! Very nice! Thank you!
  • Options
    Ahhhhhhhhhhhhh. Ah yes. I'm not sure where, how or why, but the later HTML_BBCodeParser that I'm using does things slightly differently to the older version used in BetterBBCode. But like you say, AutoP fixes all ;) And regarding it working well with AutoP... well I did them at the same time image Thanks for letting me know that it works.

    Circuit, if you give us some more information we might be able to track the problem down.
  • Options
    edited January 2007
    I'll test this extension... only a (php newbie) question: I'm pretty sure my host provider has not installed PEAR... what can I do?
    Can I include it in my Vanilla dir? (I can't install php packages on the server)
  • Options
    I'm a PHP noob myself, so I wouldn't know the answer to that. Anyone have the answer?
  • Options
    emilime, I'd ask your host if they would be willing to install PEAR. Did you try it an see if it worked anyway? If it did, PEAR's installed.
  • Options
    Hi! Im using BBCodeParser together with AutoP, and get into trouble with nested quotes. it doesn't open a second level of quotation, but it closes the first, when the second is ended. [quote]Some Text [quote]Second Quotetation...[/quote] more text [/quote] is rendered as: <blockquote>Some Text [quote]Second Quotetation...</blockquote> more text [/quote] Bye Tiggr
  • Options
    I don't really know anything about the context, but here's how you could go about changing nested quotes into their html equivelent:
    $out = $text;
    do
    {
    	$text = $out;
    	$out = preg_replace(
    		'/\[quote(=([^\]]*?))?\]((.*?)|(?R))\[\/quote\]/is', 
    		'<blockquote cite="\\2">\\3</blockquote>', 
    		$text
    	);
    }
    while($out != $text);
    (where $text holds the comment text)
  • Options
    Tiggr, that's a juicy one, thanks. I don't have a solution to that right now, but I'll get onto it pronto.

    SirNot, you're too clever for me :P
  • Options
    StashStash
    edited January 2007
    Hehe, check this out...
    Here's some random code <code>and this lot's in a nested code

    The above is actually this:
    Hehe, check this out...
    <code>
    Here's some random code
    <code>and this lot's in a nested code</code>
    </code>

    There's a basic problem with this. How do the machine know to not close the first one? It doesn't know there will be a second one. That's why the HTML version screws up as well. For the BBCode version, I reckon something like a new [bbcode][/bbcode] tag would solve this problem. What this tag would need to do is prevent the parser from parsing any more BBCode until the [/bbcode] tag comes in. Of course, that means you can't have nested [bbcode] tags, but... are there other solutions to this that I can't see?
  • Options
    I don't quite follow all of that, but assuming you're asking how to manage nested tags, just use a regular expression with the recursive directive ((?R)).

    ...and the html formatter screws up your code example because a) it dosn't allow code tags to be nested (although in this case they did manage to come out like that as a consequence of the 'tag police') and b) it automatically converts all html within code tags to their entity equivelents.
  • Options
    Thanks SirNot. There's just one problem - all that you just said about regex went way over my head. I'm really very *very* new to PHP, JS and all the stuff that goes with them like RegEx - I have a LOT to learn.

    Regarding your a) comment, what's this about the "tag police" (I feel like I've missed part of a discussion here somewhere) and how are they causing the strangeness with Html Formatter?

    As to b), how does converting to entity equivalents make that example display like that?

    I really appreciate your input on this as you obviously have a far greater understanding of these things than I do. So if you would be so kind as to continue, I would really appreciate it :)
  • Options
    Hi and thank you! The strange thing is: I'm shure, it worked fine with BetterBBCode! :-( Would be nice to have nested quotings...
  • Options
    The 'tag police' is a sort of half-arsed html tidier in the html formatter, which tries to make sure there aren't any stray opening or closing tags. What happened there was that the second opening code tag was escaped because it was between an opening code tag and the nearest ending one. Subsequently, the second closing code tag was left orphaned, so the html formatter attempted to fix that by adding an opening code tag to the beginning of the comment. As for regular expressions, I've found this page to be quite useful: http://php.net/manual/en/reference.pcre.pattern.syntax.php ; I already showed you how you could apply a recursive regular expression to nested bbcode in my earlier comment.
  • Options
    StashStash
    edited January 2007
    Tiggr, I will get this fixed. Please just be patient :)

    SirNot, thanks again. Just attempting to wrap my head around it all!
  • Options
    No problem, I can wait... ;-) I had a look into it by my self, but I had no idea how to fix! I'm very thankful for the many good extensions you do for vanilla. So no hurry! Keep on your great work.
  • Options
    When it comes to tags inside a code block, that's even more problematic, isn't it? Since the tags inside the code block shouldn't get parsed (or perhaps that makes it easier?). The behaviour I'd expect from code tags (with the example above) would be:
    Here's some random code
    <code>and this lot's in a nested code</code>
This discussion has been closed.