Working with invalid HTML tags -


i have set of html codes , wondering how can wrap code such interpreted correct browser , independent of others.

i think should give example:

x = <a href="stackoverflow.com">something

y = <b>else</b>

i print x, y , browser consider y part of link defined in x. how can force browser interpret x independent of y; that's is, how can wrap x , y?

i don't know if relevant, work in python.

thanks!

you must find tags in html snippets , make sure closed properly.

a simple solution use regexp: r<[^>]+> , pseudocode:

find next match:     if match ends `/>`:         continue     if match starts '</':         pop element stack , make sure name matches element match     else:         push element name on stack  each element on stack:     print '</%s>' % element.name 

Comments

Popular posts from this blog

ASP.NET/SQL find the element ID and update database -

jquery - appear modal windows bottom -

c++ - Compiling static TagLib 1.6.3 libraries for Windows -