##// END OF EJS Templates
highlight: only pygmentize for HTML mimetypes...
Rocco Rutte -
r6987:d09e813b default
parent child Browse files
Show More
@@ -25,14 +25,25 b' web_filerevision = webcommands._filerevi'
25 25 web_annotate = webcommands.annotate
26 26
27 27 def filerevision_highlight(web, tmpl, fctx):
28 style = web.config('web', 'pygments_style', 'colorful')
29 highlight.pygmentize('fileline', fctx, style, tmpl)
28 mt = ''.join(tmpl('mimetype', encoding=web.encoding))
29 # only pygmentize for mimetype containing 'html' so we both match
30 # 'text/html' and possibly 'application/xhtml+xml' in the future
31 # so that we don't have to touch the extension when the mimetype
32 # for a template changes; also hgweb optimizes the case that a
33 # raw file is sent using rawfile() and doesn't call us, so we
34 # can't clash with the file's content-type here in case we
35 # pygmentize a html file
36 if 'html' in mt:
37 style = web.config('web', 'pygments_style', 'colorful')
38 highlight.pygmentize('fileline', fctx, style, tmpl)
30 39 return web_filerevision(web, tmpl, fctx)
31 40
32 41 def annotate_highlight(web, req, tmpl):
33 fctx = webutil.filectx(web.repo, req)
34 style = web.config('web', 'pygments_style', 'colorful')
35 highlight.pygmentize('annotateline', fctx, style, tmpl)
42 mt = ''.join(tmpl('mimetype', encoding=web.encoding))
43 if 'html' in mt:
44 fctx = webutil.filectx(web.repo, req)
45 style = web.config('web', 'pygments_style', 'colorful')
46 highlight.pygmentize('annotateline', fctx, style, tmpl)
36 47 return web_annotate(web, req, tmpl)
37 48
38 49 def generate_css(web, req, tmpl):
@@ -18,14 +18,41 b' echo % hg serve'
18 18 hg serve -p $HGPORT -d -n test --pid-file=hg.pid -A access.log -E errors.log
19 19 cat hg.pid >> $DAEMON_PIDS
20 20
21 echo % hgweb filerevision
21 echo % hgweb filerevision, html
22 22 ("$TESTDIR/get-with-headers.py" localhost:$HGPORT '/file/tip/get-with-headers.py') \
23 23 | sed "s/[0-9]* years ago/long ago/g"
24 24
25 echo % hgweb fileannotate
25 echo % hgweb fileannotate, html
26 26 ("$TESTDIR/get-with-headers.py" localhost:$HGPORT '/annotate/tip/get-with-headers.py') \
27 27 | sed "s/[0-9]* years ago/long ago/g"
28 28
29 echo % hgweb fileannotate, raw
30 ("$TESTDIR/get-with-headers.py" localhost:$HGPORT '/annotate/tip/get-with-headers.py?style=raw') \
31 | sed "s/test@//" > a
32
33 echo "200 Script output follows" > b
34 echo "" >> b
35 echo "" >> b
36 hg annotate "get-with-headers.py" >> b
37 echo "" >> b
38 echo "" >> b
39 echo "" >> b
40 echo "" >> b
41
42 diff -u b a
43
44 echo
45 echo % hgweb filerevision, raw
46 ("$TESTDIR/get-with-headers.py" localhost:$HGPORT '/file/tip/get-with-headers.py?style=raw') \
47 > a
48
49 echo "200 Script output follows" > b
50 echo "" >> b
51 hg cat get-with-headers.py >> b
52
53 diff -u b a
54
55 echo
29 56 echo % hgweb highlightcss friendly
30 57 "$TESTDIR/get-with-headers.py" localhost:$HGPORT '/highlightcss' > out
31 58 head -n 4 out
@@ -1,6 +1,6 b''
1 1 adding get-with-headers.py
2 2 % hg serve
3 % hgweb filerevision
3 % hgweb filerevision, html
4 4 200 Script output follows
5 5
6 6 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
@@ -63,7 +63,7 b' 200 Script output follows'
63 63 </body>
64 64 </html>
65 65
66 % hgweb fileannotate
66 % hgweb fileannotate, html
67 67 200 Script output follows
68 68
69 69 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
@@ -130,6 +130,10 b' 200 Script output follows'
130 130 </body>
131 131 </html>
132 132
133 % hgweb fileannotate, raw
134
135 % hgweb filerevision, raw
136
133 137 % hgweb highlightcss friendly
134 138 200 Script output follows
135 139
General Comments 0
You need to be logged in to leave comments. Login now