import html5lib
from html5lib import treebuilders
from cStringIO import StringIO

def get_soup(obj):
    if isinstance(obj, basestring):
        obj = StringIO(obj)
    parser = html5lib.HTMLParser(tree=treebuilders.getTreeBuilder('beautifulsoup'))
    return parser.parse(obj)

import html5lib
from html5lib import treebuilders
from cStringIO import StringIO

# Hack, hide DataLossWarnings
# Based on html5lib code namespaceHTMLElements=False should do it, but nope ...
import warnings
from html5lib.constants import DataLossWarning
warnings.simplefilter('ignore', DataLossWarning)


def get_soup(obj):
    if isinstance(obj, basestring):
        obj = StringIO(obj)
    parser = html5lib.HTMLParser(namespaceHTMLElements=False, tree=treebuilders.getTreeBuilder('beautifulsoup'))
    return parser.parse(obj)

Hide DataLossWarnings that appeared with html5lib 0.90 or so.
Hide DataLossWarnings that appeared with html5lib 0.90 or so.

git-svn-id: ad91b9aa7ba7638d69f912c9f5d012e3326e9f74@1124 3942dd89-8c5d-46d7-aeed-044bccf3e60c

  import html5lib
  from html5lib import treebuilders
  from cStringIO import StringIO
  
+ # Hack, hide DataLossWarnings
+ # Based on html5lib code namespaceHTMLElements=False should do it, but nope ...
+ import warnings
+ from html5lib.constants import DataLossWarning
+ warnings.simplefilter('ignore', DataLossWarning)
+ 
+ 
  def get_soup(obj):
      if isinstance(obj, basestring):
          obj = StringIO(obj)
-     parser = html5lib.HTMLParser(tree=treebuilders.getTreeBuilder('beautifulsoup'))
+     parser = html5lib.HTMLParser(namespaceHTMLElements=False, tree=treebuilders.getTreeBuilder('beautifulsoup'))
      return parser.parse(obj)
  
Hide DataLossWarnings that appeared with html5lib 0.90 or so.
## Code Before:
import html5lib
from html5lib import treebuilders
from cStringIO import StringIO

def get_soup(obj):
    if isinstance(obj, basestring):
        obj = StringIO(obj)
    parser = html5lib.HTMLParser(tree=treebuilders.getTreeBuilder('beautifulsoup'))
    return parser.parse(obj)

## Instruction:
Hide DataLossWarnings that appeared with html5lib 0.90 or so.
## Code After:
import html5lib
from html5lib import treebuilders
from cStringIO import StringIO

# Hack, hide DataLossWarnings
# Based on html5lib code namespaceHTMLElements=False should do it, but nope ...
import warnings
from html5lib.constants import DataLossWarning
warnings.simplefilter('ignore', DataLossWarning)


def get_soup(obj):
    if isinstance(obj, basestring):
        obj = StringIO(obj)
    parser = html5lib.HTMLParser(namespaceHTMLElements=False, tree=treebuilders.getTreeBuilder('beautifulsoup'))
    return parser.parse(obj)
