summaryrefslogtreecommitdiff
path: root/beautifulsoup/element.py
diff options
context:
space:
mode:
authorLeonard Richardson <leonard.richardson@canonical.com>2011-02-13 20:00:33 -0500
committerLeonard Richardson <leonard.richardson@canonical.com>2011-02-13 20:00:33 -0500
commit5aa0e5ba8ec6a590c673db54c60ff2a76544f14f (patch)
treebf0637e79bc667a1b5ae08ca4794df414f169992 /beautifulsoup/element.py
parent87a55b145f0a73e6fc9ede9a762d81d2527161b6 (diff)
parentbc97bb3a83ee9fb4c8e31d11069ccf1cda61d4ff (diff)
Fixed handling of doctypes and added tests for nonsensical declarations.
Diffstat (limited to 'beautifulsoup/element.py')
-rw-r--r--beautifulsoup/element.py10
1 files changed, 10 insertions, 0 deletions
diff --git a/beautifulsoup/element.py b/beautifulsoup/element.py
index b2e0e12..8749114 100644
--- a/beautifulsoup/element.py
+++ b/beautifulsoup/element.py
@@ -372,6 +372,16 @@ class Declaration(NavigableString):
class Doctype(NavigableString):
+ @classmethod
+ def for_name_and_ids(cls, name, pub_id, system_id):
+ value = name
+ if pub_id is not None:
+ value += ' PUBLIC "%s"' % pub_id
+ if system_id is not None:
+ value += ' SYSTEM "%s"' % system_id
+
+ return Doctype(value)
+
def decodeGivenEventualEncoding(self, eventualEncoding):
return u'<!DOCTYPE ' + self + u'>'