검증 문제, 그것은하지 않습니다 이러한 문자를 (제거 할 수 유용 어쨌든 신뢰성있게 표시하십시오) 없이는이 반드시 이스케이프됩니다.
이
config['pylons.app_globals'].mako_lookup = TemplateLookup(
...
imports=[....,'from appname.lib.helpers import sgmlsafe',...]
그런 다음에 사용할 수 있어야합니다 : 당신이 environment.py
을 편집하여 필터로이 가능한을 할 수
__sgml_invalid = re.compile(r'[\x82-\x8c\x91-\x9c\x9f]', re.UNICODE)
def sgmlsafe(text):
lookup = {
130:"‚", #Single Low-9 Quotation Mark
131: "ƒ", #Latin Small Letter F With Hook
132:"„", #Double Low-9 Quotation Mark
133:"…", #Horizontal Ellipsis
134:"†", #Dagger
135:"‡", #Double Dagger
136: "ˆ", #Modifier Letter Circumflex Accent
137:"‰", #Per Mille Sign
138: "Š", #Latin Capital Letter S With Caron
139:"‹", #Single Left-Pointing Angle Quotation Mark
140: "Œ", #Latin Capital Ligature OE
145:"‘", #Left Single Quotation Mark
146:"’", #Right Single Quotation Mark
147:"“", #Left Double Quotation Mark
148:"”", #Right Double Quotation Mark
149:"•", #Bullet
150:"–", #En Dash
151:"—", #Em Dash
152: "˜", #Small Tilde
153:"™", #Trade Mark Sign
154: "š", #Latin Small Letter S With Caron
155:"›", #Single Right-Pointing Angle Quotation Mark
156: "œ", #Latin Small Ligature OE
159: "Ÿ" #Latin Capital Letter Y With Diaeresis
}
return __sgml_invalid.sub(lambda x: lookup[ord(x.group())], text)
그리고이 목적을 위해 나는`lib 디렉토리/helpers.py '에 다음과 같은 기능을 추가 귀하의 템플릿 :
${c.content|n,sgmlsafe}
나는 그게 간단했지만 좋았어. * * UTF-8을 사용하고 있으므로 유효성이 검사되지 않습니다. – Draemon
XHTML Strict로 유효합니다. HTML 4에는 문제가 있습니다. X가 아닌 HTML이 필요합니까? –
XHTML Strict, UTF-8이며 온라인 및 오프라인 w3c 검사기에서 올바르게 감지됩니다. 그러나 온라인 유효성 검사기는 "텍스트에 불법 문자를 사용했습니다. HTML은 표준 UNICODE 컨소시엄 캐릭터 레퍼토리를 사용합니다" – Draemon