Re: Checking equal number of <div> and </div> [message #171303 is a reply to message #171297] |
Thu, 30 December 2010 05:15 ![Go to previous message Go to previous message](/forum/theme/default/images/up.png) ![Go to next message Go to previous message](/forum/theme/default/images/down.png) |
![](//www.gravatar.com/avatar/5a04b58209c8dd80f5e593ab3edca044?s=64&d=mm&r=g) |
richard
![](/forum/images/flags/us.png) Messages: 213 Registered: June 2013
Karma:
|
Senior Member |
|
|
On Wed, 29 Dec 2010 20:42:41 -0800 (PST), jwcarlton wrote:
> On Dec 29, 8:28 pm, Thomas 'PointedEars' Lahn <PointedE...@web.de>
> wrote:
>> jwcarlton wrote:
>>> Can you guys think of a good way for me to check a string to make sure
>>> there are an equal number of <div (.*)> and </div>? Then, either add
>>> or remove </div> tags as needed to make them match?
>>
>> A recursive RegEx to parse HTML has been posted (by me) and can be easily
>> found in the manual; whatever is not matched by it can be analyzed further.
>>
>> However, you should (also) describe the problem you want to solve, not
>> (only) the problem with your approach for a solution, for the approach might
>> be completely wrong.
>>
>> PointedEars
>> --
>> var bugRiddenCrashPronePieceOfJunk = (
>> navigator.userAgent.indexOf('MSIE 5') != -1
>> && navigator.userAgent.indexOf('Mac') != -1
>> ) // Plone, register_function.js:16
>
>
> It's for a message board, where I've implemented Rich HTML posting
> (contentEditable). It works fine except for when someone copy-and-
> pastes from a site that uses DIV tags for layout. In those cases, if
> the poster doesn't grab the entire page, then it's not uncommon for
> the opening or closing DIV tags to be missing.
>
> I've been rebuilding this section using DIV instead of tables, but
> those missing tags in the posts cause major layout errors. I can
> correct it by surrounding posts with a table, but I figure that a
> better long-term solution would be to correct the missing tags as soon
> as they're posted.
In that case, I'd say to have a statement about this in your "new thread"
item. But do you want to see the code for that page or the output?
Most boards only post the code, not the output.
|
|
|