| 1 |
##~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~## |
|---|
| 2 |
##~ Copyright (C) 2002-2005 TechGame Networks, LLC. ## |
|---|
| 3 |
##~ ## |
|---|
| 4 |
##~ This library is free software; you can redistribute it ## |
|---|
| 5 |
##~ and/or modify it under the terms of the BSD style License as ## |
|---|
| 6 |
##~ found in the LICENSE file included with this distribution. ## |
|---|
| 7 |
##~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~## |
|---|
| 8 |
|
|---|
| 9 |
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|---|
| 10 |
#~ Imports |
|---|
| 11 |
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|---|
| 12 |
|
|---|
| 13 |
from css import * |
|---|
| 14 |
|
|---|
| 15 |
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|---|
| 16 |
#~ Definitions |
|---|
| 17 |
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|---|
| 18 |
|
|---|
| 19 |
class CSSCascadeStrategyForHTML(CSSCascadeStrategy): |
|---|
| 20 |
def _normalizeAttrNames(self, attrNames): |
|---|
| 21 |
if isinstance(attrNames, (str, unicode)): |
|---|
| 22 |
return attrNames.lower() |
|---|
| 23 |
else: |
|---|
| 24 |
return [n.lower() for n in attrNames] |
|---|
| 25 |
|
|---|
| 26 |
class CSSBuilderForHTML(CSSBuilder): |
|---|
| 27 |
def property(self, name, value, important=False): |
|---|
| 28 |
name = name.lower() |
|---|
| 29 |
return CSSBuilder.property(self, name, value, important) |
|---|
| 30 |
|
|---|
| 31 |
def selector(self, name): |
|---|
| 32 |
name = name.lower() |
|---|
| 33 |
return CSSBuilder.selector(self, name) |
|---|
| 34 |
|
|---|
| 35 |
|
|---|
| 36 |
class CSSParserForHTML(cssParser.CSSParser): |
|---|
| 37 |
CSSBuilderFactory = CSSBuilderForHTML |
|---|
| 38 |
|
|---|
| 39 |
|
|---|
| 40 |
# Override the imports from the css namespace |
|---|
| 41 |
CSSCascade = CSSCascadeStrategyForHTML |
|---|
| 42 |
CSSBuilder = CSSBuilderForHTML |
|---|
| 43 |
CSSParser = CSSParserForHTML |
|---|
| 44 |
|
|---|
| 45 |
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|---|
| 46 |
#~ Convience functions |
|---|
| 47 |
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|---|
| 48 |
|
|---|
| 49 |
class _CSSNamespaceForHtml(_CSSNamespace): |
|---|
| 50 |
CSSParserFactory = CSSParserForHTML |
|---|
| 51 |
|
|---|
| 52 |
_CSSNamespaceForHtml.updateNamespace(locals()) |
|---|
| 53 |
|
|---|