diff options
author | Leonard Richardson <leonard.richardson@canonical.com> | 2011-02-26 22:54:04 -0500 |
---|---|---|
committer | Leonard Richardson <leonard.richardson@canonical.com> | 2011-02-26 22:54:04 -0500 |
commit | 247785aa53358fa64e9bd5f799c4c9a1609489f0 (patch) | |
tree | ac3f92a60f5b9293c1971869fb90857bbfab94af | |
parent | d7056f49c8bb3a448cec2f1a6f2de55e93c8e8d6 (diff) |
Renamed replace_with_html_entities to substitute_html_entities.
-rw-r--r-- | beautifulsoup/__init__.py | 4 | ||||
-rw-r--r-- | beautifulsoup/element.py | 16 | ||||
-rw-r--r-- | tests/test_tree.py | 6 |
3 files changed, 13 insertions, 13 deletions
diff --git a/beautifulsoup/__init__.py b/beautifulsoup/__init__.py index f4c2a95..5aa1406 100644 --- a/beautifulsoup/__init__.py +++ b/beautifulsoup/__init__.py @@ -264,7 +264,7 @@ class BeautifulSoup(Tag): def decode(self, pretty_print=False, indent_level=0, eventual_encoding=DEFAULT_OUTPUT_ENCODING, - replace_with_html_entities=False): + substitute_html_entities=False): """Returns a string or Unicode representation of this document. To get Unicode, pass None for encoding.""" if self.is_xml: @@ -277,7 +277,7 @@ class BeautifulSoup(Tag): prefix = u'' return prefix + super(BeautifulSoup, self).decode( pretty_print, indent_level, eventual_encoding, - replace_with_html_entities) + substitute_html_entities) class StopParsing(Exception): diff --git a/beautifulsoup/element.py b/beautifulsoup/element.py index f3a59d4..bbecdbd 100644 --- a/beautifulsoup/element.py +++ b/beautifulsoup/element.py @@ -562,13 +562,13 @@ class Tag(PageElement, EntitySubstitution): def encode(self, encoding=DEFAULT_OUTPUT_ENCODING, pretty_print=False, indent_level=0, - replace_with_html_entities=False): + substitute_html_entities=False): return self.decode(pretty_print, indent_level, encoding, - replace_with_html_entities).encode(encoding) + substitute_html_entities).encode(encoding) def decode(self, pretty_print=False, indent_level=0, eventual_encoding=DEFAULT_OUTPUT_ENCODING, - replace_with_html_entities=False): + substitute_html_entities=False): """Returns a string or Unicode representation of this tag and its contents. To get Unicode, pass None for encoding.""" @@ -601,7 +601,7 @@ class Tag(PageElement, EntitySubstitution): indentContents = indentTag + 1 contents = self.decodeContents(pretty_print, indentContents, eventual_encoding, - replace_with_html_entities) + substitute_html_entities) if self.hidden: s = contents else: @@ -642,12 +642,12 @@ class Tag(PageElement, EntitySubstitution): pretty_print=False, indent_level=0, replace_With_html_entities=False): return self.decodeContents( - pretty_print, indent_level, replace_with_html_entities).encode( + pretty_print, indent_level, substitute_html_entities).encode( encoding) def decodeContents(self, pretty_print=False, indent_level=0, eventual_encoding=DEFAULT_OUTPUT_ENCODING, - replace_with_html_entities=False): + substitute_html_entities=False): """Renders the contents of this tag as a string in the given encoding. If encoding is None, returns a Unicode string..""" s=[] @@ -657,11 +657,11 @@ class Tag(PageElement, EntitySubstitution): text = c.decodeGivenEventualEncoding(eventual_encoding) elif isinstance(c, Tag): s.append(c.decode(pretty_print, indent_level, eventual_encoding, - replace_with_html_entities)) + substitute_html_entities)) if text and pretty_print: text = text.strip() if text: - if replace_with_html_entities: + if substitute_html_entities: text = self.substitute_html(text) if pretty_print: s.append(" " * (indent_level-1)) diff --git a/tests/test_tree.py b/tests/test_tree.py index 249e7ae..f9163f1 100644 --- a/tests/test_tree.py +++ b/tests/test_tree.py @@ -830,14 +830,14 @@ class TestPersistence(SoupTest): class TestSubstitutions(SoupTest): - def test_entity_substitution(self): + def test_html_entity_substitution(self): soup = self.soup( u"<b>Sacr\N{LATIN SMALL LETTER E WITH ACUTE} bleu!</b>") - encoded = soup.encode("utf-8", replace_with_html_entities=True) + encoded = soup.encode("utf-8", substitute_html_entities=True) self.assertEquals(encoded, self.document_for("<b>Sacré bleu!</b>")) - def test_entity_substitution_off_by_default(self): + def test_html_entity_substitution_off_by_default(self): markup = u"<b>Sacr\N{LATIN SMALL LETTER E WITH ACUTE} bleu!</b>" soup = self.soup(markup) encoded = soup.b.encode("utf-8") |