shon/sphc — Issue #1: [PATCH] reenable self-close tag and fix double % bug.
Author: cardmaster
Created: 2011-11-28 09:07:36+00:00
State: open

When I generate HTML using sphc, every '%' chracter will outputed as '%%', no matter escaped is enabled or not.
So I simply modify a few lines, I don't know further impact, but it works for me.

Author: Leaf Johnson
Date: Mon Nov 28 16:58:34 2011 +0800

diff --git a/sphc/__init__.py b/sphc/__init__.py
index 4c87c67..2216107 100644
--- a/sphc/__init__.py
+++ b/sphc/__init__.py
@@ -19,7 +19,7 @@ class Tag(object):
_content = content
else:
_content = ''
- self._content = _content.replace('%', '%%')
+ self._content = _content
self.attributes = attrs
self.nv_attributes = list(nv_attrs)
return self
@@ -69,9 +69,10 @@ class Tag(object):
if nv_attributes_s: nv_attributes_s = ' ' + nv_attributes_s
if children_s: children_s = ' ' + children_s

- #if self.name.upper() in TAGS_UNFRIENDLY_WITH_SELF_CLOSING or self._content or children_s:
- return pats.regular % dict(content=self._content, children=children_s, tagname=self._name, attributes=attributes_s, nv_attributes=nv_attributes_s)
- return pats.no_content % dict(tagname=self._name, attributes=attributes_s, nv_attributes=nv_attributes_s)
+ if self._name.upper() in TAGS_UNFRIENDLY_WITH_SELF_CLOSING or self._content or children_s:
+ return pats.regular % dict(content=self._content, children=children_s, tagname=self._name, attributes=attributes_s, nv_attributes=nv_attributes_s)
+ else:
+ return pats.no_content % dict(tagname=self._name, attributes=attributes_s, nv_attributes=nv_attributes_s)

def pretty(self): # deprecated
from tidylib import tidy_document