~loggerhead-team/loggerhead/trunk-rich

« back to all changes in this revision

Viewing changes to loggerhead/util.py

Merge with mhudson's branch

* Should be more efficient since we don't translate whitespace

Show diffs side-by-side

added added

removed removed

Lines of Context:
241
241
    return s.expandtabs().replace(' ', NONBREAKING_SPACE)
242
242
 
243
243
 
244
 
def fix_whitespace(s):
245
 
    """
246
 
    Replace spaces outside of HTML tags with nonbreaking spaces 
247
 
    """
248
 
 
249
 
    ns = ''
250
 
    outside_tag = True  # Whether or not we are outside of a HTML tag
251
 
 
252
 
    for c in s.expandtabs():
253
 
        if outside_tag:
254
 
            if c == '<':
255
 
                outside_tag = False
256
 
            elif c == ' ':
257
 
                c = NONBREAKING_SPACE
258
 
        else: # Inside tag
259
 
            if c == '>':
260
 
                outside_tag = True
261
 
        ns += c
262
 
 
263
 
    return ns
264
 
 
265
 
 
266
244
def fake_permissions(kind, executable):
267
245
    # fake up unix-style permissions given only a "kind" and executable bit
268
246
    if kind == 'directory':