now = datetime.now()
title = os.path.basename(filename)[:-4]
content = fp.read()
- parts = generate_documentation(content, (lambda x: './%s.html' % x))
+ suffix = not preproc and '.html' or ''
+ parts = generate_documentation(content, (lambda x: './%s%s' % (x, suffix)))
result = file(os.path.join(dst, title + '.html'), 'w')
c = dict(parts)
c['style'] = PYGMENTS_FORMATTER.get_style_defs('.syntax')
from sets import Set as set
from jinja.exceptions import TemplateSyntaxError, TemplateRuntimeError
-from cgi import escape
-
-_known_safe_types = set([int, long, float])
def contextcallable(f):
class Markup(unicode):
"""
Compatibility for Pylons and probably some other frameworks.
+
+ It's only used in Jinja environments with `auto_escape` set
+ to true.
"""
def __html__(self):
from jinja.parser import Parser
from jinja.loaders import LoaderWrapper
from jinja.datastructure import Undefined, Markup, Context, FakeTranslator
-from jinja.utils import escape, collect_translations, get_attribute
+from jinja.utils import collect_translations, get_attribute
from jinja.exceptions import FilterNotFound, TestNotFound, \
SecurityException, TemplateSyntaxError, TemplateRuntimeError
from jinja.defaults import DEFAULT_FILTERS, DEFAULT_TESTS, DEFAULT_NAMESPACE
This method will have no effect it the value is already escaped.
"""
+ #: because filters are cached we can make a local alias to
+ #: speed things up a bit
+ e = escape
def wrapped(env, context, s):
if isinstance(s, TemplateData):
return s
elif hasattr(s, '__html__'):
return s.__html__()
- return escape(env.to_unicode(s), attribute)
+ return e(env.to_unicode(s), attribute)
return wrapped
'[', ']', '(', ')', '{', '}',
# attribute access and comparison / logical operators
'.', ':', ',', '|', '==', '<', '>', '<=', '>=', '!=', '=',
- ur'or\b', ur'and\b', ur'not\b', ur'in\b', ur'is'
+ ur'or\b', ur'and\b', ur'not\b', ur'in\b', ur'is\b'
]]))
# set of used keywords