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.
Extension: AutoP
Stash
✭
I have just released AutoP.
If you've ever been annoyed by the way you carefully crafted HTML gets <br />d to death in Vanilla, this extension is for you! It is an implementation of AutoP by Matthew Mullenweg of WordPress fame. It "fixes" new lines in comments, displaying them as you would expect and using semantic, valid XHTML instead of multiple <br />s all over the place.
As of 2007-01-02, it has been tested and works with the default Vanilla text formatter, BBCodeParser, BetterBBCode, ExtendedTextFormatter, ForcedBBCode, HtmlFormatter, ksesXHTML, Markdown and Textile.
Known bugs:
! None. Please shout if you think you've found something that's broken!
To do:
+ Add a blacklist to disable this extension only on comments with incompatible text formatters used.
Also, a big THANK YOU goes out to Chuyskywalker for letting me know AutoP existed in the first place!
If you've ever been annoyed by the way you carefully crafted HTML gets <br />d to death in Vanilla, this extension is for you! It is an implementation of AutoP by Matthew Mullenweg of WordPress fame. It "fixes" new lines in comments, displaying them as you would expect and using semantic, valid XHTML instead of multiple <br />s all over the place.
As of 2007-01-02, it has been tested and works with the default Vanilla text formatter, BBCodeParser, BetterBBCode, ExtendedTextFormatter, ForcedBBCode, HtmlFormatter, ksesXHTML, Markdown and Textile.
Known bugs:
! None. Please shout if you think you've found something that's broken!
To do:
+ Add a blacklist to disable this extension only on comments with incompatible text formatters used.
Also, a big THANK YOU goes out to Chuyskywalker for letting me know AutoP existed in the first place!
0
This discussion has been closed.
Comments
OK, try this code in an HTML comment at this forum here:
A line of text. <ul> <li>one</li> <li>two</li> <li>three</li> </ul> Another line of text.
This gives me
- one
- two
- three
Another line of text.And the actual HTML output looks like this:
A line of text.<br /><br /><ul><br /><li>one</li><br /><li>two</li><br /><li>three</li><br /></ul><br /><br />Another line of text.
When really, I was expecting
- one
- two
- three
Another line of text.But in order to get this I have to type the following code:
A line of text. <ul><li>one</li><li>two</li><li>three</li></ul> Another line of text.
Essentially, the HTML being output is incorrect. HTML doesn't usually care about white space or carriage returns, yet these are being converted to <br />s. The AutoP Extension does a better job of deciding when a paragraph <p> tag should be used instead of two <br />s and when newlines should be left as is (after an </li> in the examples above) and not converted into HTML.
Hope this clears things up a bit?
Not sure that it happens enough that I want to add another extension though, and I've never had a user complain or use lists for that matter, but thanks anyway. All clear now.
Posted: Wednesday, 3 January 2007 at 1:03PM (AEDT)
And yes, I too vote for a core fix.
Posted: Wednesday, 3 January 2007 at 1:14PM (AEDT)
<ul> <li>Test Line 1</li> <li>Test Line 2</li> <li>Test Line 3</li> </ul>
By the way, should it work with preview as well?
Posted: Thursday, 4 January 2007 at 8:03AM (AEDT)
<div class="CommentBody" id="CommentBody_134"><ul>Multiple lines, expecting AutoP to fix things... <ul> <li>Test Line 1</li> <!-- SNIP --> </ul> </ul>
Notice specifically, that after id="CommentBody_134"><ul> there is no <li>. I can only imagine that this invalid HTML is breaking AutoP somehow. I would say that this isn't AutoP's fault, but I will show it to the author and see if there's anything he can do to make AutoP more robust with invalid HTML.
Of course I may be completely wrong here and it is AutoP's fault, so if anyone wants to show me the error of my ways you're more than welcome.
But there's still definitely something strange happening here...
[-Stash-]
define('HTML_CONVERT_NEWLINES', 1);
to:define('HTML_CONVERT_NEWLINES',0);
I don't suppose there's any way of the AutoP extension overriding HtmlFormatter's setting here is there?
Oh yes, and preview should work, it does for me using SirNot's Preview Post 2.1, however, given the HTML issues mentioned above, I would imagine that isn't helping matters. Your forum's HTML seems to be broken compared to every other Vanilla forum's HTML code.
Edit: I have added this to the readme file and updated the package on the add-ons site.
I don't see how you can say this mate, the <li> and </li> tags are definitely there.
In any case, your suggested modification to HTML Formatter worked, for lists but now HTML Formatter takes out ALL of the <p> tags.
Posted: Friday, 5 January 2007 at 6:03AM (AEDT)
<p>
after</param>
with HtmlFormatter 1.7.2 (on the youtube html), really strange.Does anyone have the same problem?
I notice you are using the BBInsertBar and I guess you're using it to embed the YouTube videos? I'm also going to guess that you are using BetterBBCode with the YouTube modifications mentioned elsewhere in this community. Taking these assumptions, I can say that I found the same problem on a site of mine as well. I would say that it's possibly a shortcoming in the AutoP regex, but I haven't really looked into it all that deeply. I will bring this to the attention of AutoP and see if he has the time to create a fix for it.
What I did to solve it was change the YouTube embedding code from:
return preg_replace('/<youtube>([\d\w-_]+)<\/youtube>/i', '<object width="425" height="350"><param name="movie" value="http://www.youtube.com/v/$1"></param> <embed src="http://www.youtube.com/v/$1" type="application/x-shockwave-flash" width="425" height="350" wmode="transparent"></embed> </object>', $String);
to:
return preg_replace('/<youtube>([\d\w-_]+)<\/youtube>/i', '<object width="425" height="350"><param name="movie" value="http://www.youtube.com/v/$1" /><param name="wmode" value="transparent" /><embed src="http://www.youtube.com/v/$1" type="application/x-shockwave-flash" wmode="transparent" width="425" height="350"></embed></object>', $String);
This solved the problem for me...
Edit: The BBCodeParser extension already contains this fix among others...
<embed blah blah...></embed>
in your forum, you'll want to add "embed" in the line 27 of AutoP's default page.eg:
$allblocks = '(?:table|thead|tfoot|caption|colgroup|tbody|tr|td|th|div|dl|dd|dt|ul|ol|li|pre|select|form|blockquote|address|math|style|script|object|input|embed|param|p|h[1-6])';
or you may get some dirty "p" on it.
I am using BBCodeParser (nice Extension, thanks.) and I add youtube video with HtmlFormatter.
Whatever, it works great now.
case 'youtube' : return ('<object width="425" height="350"><param name="movie" value="http://www.youtube.com/v/'.$ID.'"></param>'. '<embed src="http://www.youtube.com/v/'.$ID.'" type="application/x-shockwave-flash" width="425" height="350"></embed>'. '</object>');
Source will be:<object width="425" height="350"><param name="movie" value="http://www.youtube.com/v/XXXXX"></param><embed src="http://www.youtube.com/v/XXXXXX" type="application/x-shockwave-flash" wmode="transparent" width="425" height="350"></embed></object>
It'll not have new line in the code.
But since the line 28 & 29 of AutoP:
$pee = preg_replace('!(<' . $allblocks . '[^>]*>)!', "\n$1", $pee); $pee = preg_replace('!(</' . $allblocks . '>)!', "$1\n\n", $pee);
AutoP will add some new line on it.Source after AutoP:
<object width="425" height="350"> <param name="movie" value="http://www.youtube.com/v/XXX"></param> <embed src="http://www.youtube.com/v/XXXX" type="application/x-shockwave-flash" wmode="transparent" width="425" height="350"></embed> </object>
PS: AutoP also changes the html source code of BBCodePaser.
I saw there was a need for this functionality in BBCodeParser as I was building it, but I also realised that just about every string formatter in Vanilla, includingn the defaul, needed it as well, so I separated it out so people who don't want to use the BBCodeParser can benefit from it as well.