~facelessuser/beautifulsoup/lxml-fix

« back to all changes in this revision

Viewing changes to bs4/__init__.py

  • Committer: Leonard Richardson
  • Date: 2019-07-21 19:50:49 UTC
  • Revision ID: leonardr@segfault.org-20190721195049-vzupkzxai3bx3r8t
Implemented line number tracking for html5lib.

Show diffs side-by-side

added added

removed removed

Lines of Context:
377
377
        self.preserve_whitespace_tag_stack = []
378
378
        self.pushTag(self)
379
379
 
380
 
    def new_tag(self, name, namespace=None, nsprefix=None, attrs={}, **kwattrs):
 
380
    def new_tag(self, name, namespace=None, nsprefix=None, attrs={},
 
381
                sourceline=None, sourcepos=None, **kwattrs):
381
382
        """Create a new tag associated with this soup."""
382
383
        kwattrs.update(attrs)
383
 
        return Tag(None, self.builder, name, namespace, nsprefix, kwattrs)
 
384
        return Tag(None, self.builder, name, namespace, nsprefix, kwattrs,
 
385
                   sourceline=sourceline, sourcepos=sourcepos)
384
386
 
385
387
    def new_string(self, s, subclass=NavigableString):
386
388
        """Create a new NavigableString associated with this soup."""
531
533
 
532
534
        return most_recently_popped
533
535
 
534
 
    def handle_starttag(self, name, namespace, nsprefix, attrs, lineno=None,
535
 
                        offset=None):
 
536
    def handle_starttag(self, name, namespace, nsprefix, attrs, sourceline=None,
 
537
                        sourcepos=None):
536
538
        """Push a start tag on to the stack.
537
539
 
538
540
        If this method returns None, the tag was rejected by the
550
552
            return None
551
553
 
552
554
        tag = Tag(self, self.builder, name, namespace, nsprefix, attrs,
553
 
                  self.currentTag, self._most_recent_element, lineno=lineno,
554
 
                  offset=offset)
 
555
                  self.currentTag, self._most_recent_element,
 
556
                  sourceline=sourceline, sourcepos=sourcepos)
555
557
        if tag is None:
556
558
            return tag
557
559
        if self._most_recent_element is not None: