Changeset - 7c094db329b3
[Not reviewed]
default
0 3 0
Mads Kiilerich - 11 years ago 2014-07-18 18:44:54
madski@unity3d.com
diff: show whitespace

It could be considered to use the VisibleWhitespaceFilter instead ...
3 files changed with 50 insertions and 7 deletions:
0 comments (0 inline, 0 general)
kallithea/lib/diffs.py
Show inline comments
 
@@ -192,7 +192,10 @@ class DiffProcessor(object):
 
    """, re.VERBOSE | re.MULTILINE)
 

	
 
    #used for inline highlighter word split
 
    _token_re = re.compile(r'()(>|<|&|\W+?)')
 
    _token_re = re.compile(r'()(&gt;|&lt;|&amp;|<u>\t</u>| <i></i>|\W+?)')
 

	
 
    _escape_re = re.compile(r'(&)|(<)|(>)|(\t)|( \n| $)')
 

	
 

	
 
    def __init__(self, diff, vcs='hg', format='gitdiff', diff_limit=None):
 
        """
 
@@ -248,9 +251,20 @@ class DiffProcessor(object):
 
        if self.diff_limit is not None and self.cur_diff_size > self.diff_limit:
 
            raise DiffLimitExceeded('Diff Limit Exceeded')
 

	
 
        return safe_unicode(string).replace('&', '&amp;')\
 
                .replace('<', '&lt;')\
 
                .replace('>', '&gt;')
 
        def substitute(m):
 
            groups = m.groups()
 
            if groups[0]:
 
                return '&amp;'
 
            if groups[1]:
 
                return '&lt;'
 
            if groups[2]:
 
                return '&gt;'
 
            if groups[3]:
 
                return '<u>\t</u>'
 
            if groups[4] and m.start(): # skip 1st column with +/-
 
                return ' <i></i>'
 

	
 
        return self._escape_re.sub(substitute, safe_unicode(string))
 

	
 
    def _line_counter(self, l):
 
        """
kallithea/lib/helpers.py
Show inline comments
 
@@ -266,6 +266,18 @@ class CodeHtmlFormatter(HtmlFormatter):
 
        yield 0, '</td></tr></table>'
 

	
 

	
 
_whitespace_re = re.compile(r'(\t)|( )(?=\n|</div>)')
 

	
 
def _markup_whitespace(m):
 
    groups = m.groups()
 
    if groups[0]:
 
        return '<u>\t</u>'
 
    if groups[1]:
 
        return ' <i></i>'
 

	
 
def markup_whitespace(s):
 
    return _whitespace_re.sub(_markup_whitespace, s)
 

	
 
def pygmentize(filenode, **kwargs):
 
    """
 
    pygmentize function using pygments
 
@@ -273,8 +285,8 @@ def pygmentize(filenode, **kwargs):
 
    :param filenode:
 
    """
 
    lexer = get_custom_lexer(filenode.extension) or filenode.lexer
 
    return literal(code_highlight(filenode.content, lexer,
 
                                  CodeHtmlFormatter(**kwargs)))
 
    return literal(markup_whitespace(
 
        code_highlight(filenode.content, lexer, CodeHtmlFormatter(**kwargs))))
 

	
 

	
 
def pygmentize_annotation(repo_name, filenode, **kwargs):
 
@@ -361,7 +373,7 @@ def pygmentize_annotation(repo_name, fil
 
            return uri
 
        return _url_func
 

	
 
    return literal(annotate_highlight(filenode, url_func(repo_name), **kwargs))
 
    return literal(markup_whitespace(annotate_highlight(filenode, url_func(repo_name), **kwargs)))
 

	
 

	
 
def is_following_repo(repo_name, user_id):
kallithea/public/css/style.css
Show inline comments
 
@@ -4974,6 +4974,23 @@ table.code-difftable .del del {
 
    text-decoration: none;
 
}
 

	
 
table.code-highlighttable div.code-highlight pre u:before,
 
table.code-difftable td.code pre u:before {
 
    content: "\21a6";
 
    display: inline-block;
 
    width: 0;
 
}
 
table.code-highlighttable div.code-highlight pre u,
 
table.code-difftable td.code pre u {
 
    color: rgba(0,0,0,0.15);
 
}
 
table.code-highlighttable div.code-highlight pre i,
 
table.code-difftable td.code pre i {
 
    border-style: solid;
 
    border-left-width: 1px;
 
    color: rgba(0,0,0,0.15);
 
}
 

	
 
/** LINE NUMBERS **/
 
table.code-difftable .lineno {
 
    padding-left: 2px;
0 comments (0 inline, 0 general)