Merge ~chrispitude/beautifulsoup:new-tag-allow-text into beautifulsoup:master
Status: | Merged |
---|---|
Merge reported by: | Leonard Richardson |
Merged at revision: | b3e3474bdf663cb7bb0bdbfce0a73f2d0a9c6f8d |
Proposed branch: | ~chrispitude/beautifulsoup:new-tag-allow-text |
Merge into: | beautifulsoup:master |
Diff against target: |
68 lines (+9/-8) 3 files modified
bs4/__init__.py (+6/-2) bs4/tests/test_soup.py (+2/-1) doc/source/index.rst (+1/-5) |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Leonard Richardson | Pending | ||
Review via email: mp+457198@code.launchpad.net |
Commit message
allow string text specification in new_tag()
Description of the change
This change allows new text to be specified in the new_tag() method:
>>> title = soup.new_
or, alternatively as a named argument:
>>> title = soup.new_
This, together with the `return-
>>> from bs4 import BeautifulSoup
>>> soup = BeautifulSoup(
>>> html = soup.find('html')
>>> #
>>> head = html.insert(0, soup.new_
>>> title = head.append(
>>> meta = head.append(
>>> #
>>> print(html) # manually prettified
<html>
<head>
<title>My Title Text</title>
<meta charset="UTF-8"/>
</head>
</html>
This looks good for the next feature release. The only change I plan to make is to move 'string' to the end of the argument list to maintain backwards compatibility. Otherwise existing code that uses positional arguments (like the tree builder code you had to change) will break.