Merge lp:~martinmassera/beautifulsoup/modifying-string-docs into lp:beautifulsoup

Proposed by martin massera on 2019-08-22
Status: Needs review
Proposed branch: lp:~martinmassera/beautifulsoup/modifying-string-docs
Merge into: lp:beautifulsoup
Diff against target: 27 lines (+16/-1)
1 file modified
doc/source/index.rst (+16/-1)
To merge this branch: bzr merge lp:~martinmassera/beautifulsoup/modifying-string-docs
Reviewer Review Type Date Requested Status
Leonard Richardson 2019-08-22 Pending
Review via email:

Description of the change

Extending documentation for the "Modifying .string" section for the case of using a string with HTML content. Describes two ways: escaping the content and parsing the content.

To post a comment you must log in.

Unmerged revisions

523. By martin massera on 2019-08-22

Adding documentation for parsing HTML content in the "Modifying .string" section

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'doc/source/index.rst'
--- doc/source/index.rst 2019-07-21 19:50:49 +0000
+++ doc/source/index.rst 2019-08-22 17:41:47 +0000
@@ -1873,7 +1873,22 @@
1873 # <a href="">New link text.</a>1873 # <a href="">New link text.</a>
1875Be careful: if the tag contained other tags, they and all their1875Be careful: if the tag contained other tags, they and all their
1876contents will be destroyed.1876contents will be destroyed. If the new string contains HTML content,
1877it will be escaped and added as the tag's text::
1879 html_string = "A <strong>BOLD</strong> statement"
1881 tag.string = html_string
1882 tag
1883 # <a href="">A &lt;strong&gt;BOLD&lt;/strong&gt; statement</a>
1885You can parse the HTML string by creting a
1886``BeautifulSoap`` object and appending it as tags::
1888 tag.clear()
1889 tag.append(BeautifulSoup(html_string, 'html.parser'))
1890 tag
1891 # <a href="">A <strong>BOLD</strong> statement</a>


People subscribed via source and target branches

to status/vote changes: