Show More
@@ -82,14 +82,17 b' def pygments_format(filename, rawtext, f' | |||
|
82 | 82 | return highlight(rawtext, lexer, formatter) |
|
83 | 83 | |
|
84 | 84 | |
|
85 | def filerevision_pygments(self, fctx): | |
|
85 | def filerevision_pygments(self, tmpl, fctx): | |
|
86 | 86 | """Reimplement hgweb.filerevision to use syntax highlighting""" |
|
87 |
f |
|
|
87 | f = fctx.path() | |
|
88 | 88 | |
|
89 | 89 | rawtext = fctx.data() |
|
90 | 90 | text = rawtext |
|
91 | 91 | |
|
92 | mt = mimetypes.guess_type(filename)[0] | |
|
92 | fl = fctx.filelog() | |
|
93 | n = fctx.filenode() | |
|
94 | ||
|
95 | mt = mimetypes.guess_type(f)[0] | |
|
93 | 96 | |
|
94 | 97 | if util.binary(text): |
|
95 | 98 | mt = mt or 'application/octet-stream' |
@@ -107,36 +110,35 b' def filerevision_pygments(self, fctx):' | |||
|
107 | 110 | |
|
108 | 111 | style = self.config("web", "pygments_style", "colorful") |
|
109 | 112 | |
|
110 |
text_formatted = lines(pygments_format(f |
|
|
113 | text_formatted = lines(pygments_format(f, text, | |
|
111 | 114 | forcetext=forcetext, |
|
112 | 115 | stripecount=self.stripecount, |
|
113 | 116 | style=style)) |
|
114 | 117 | |
|
115 | 118 | # override per-line template |
|
116 |
|
|
|
119 | tmpl.cache['fileline'] = '#line#' | |
|
117 | 120 | |
|
118 | 121 | # append a <link ...> to the syntax highlighting css |
|
119 |
old_header = ''.join( |
|
|
122 | old_header = ''.join(tmpl('header')) | |
|
120 | 123 | if SYNTAX_CSS not in old_header: |
|
121 | 124 | new_header = old_header + SYNTAX_CSS |
|
122 |
|
|
|
125 | tmpl.cache['header'] = new_header | |
|
123 | 126 | |
|
124 |
yield |
|
|
125 |
|
|
|
126 |
|
|
|
127 |
|
|
|
128 |
|
|
|
129 |
|
|
|
130 |
|
|
|
131 |
|
|
|
132 |
|
|
|
133 |
|
|
|
134 |
|
|
|
135 |
|
|
|
136 |
|
|
|
137 |
|
|
|
138 | fctx.filenode()), | |
|
139 | permissions=fctx.manifest().flags(filename)) | |
|
127 | yield tmpl("filerevision", | |
|
128 | file=f, | |
|
129 | path=hgweb_mod._up(f), # fixme: make public | |
|
130 | text=text_formatted, | |
|
131 | raw=rawtext, | |
|
132 | mimetype=mt, | |
|
133 | rev=fctx.rev(), | |
|
134 | node=hex(fctx.node()), | |
|
135 | author=fctx.user(), | |
|
136 | date=fctx.date(), | |
|
137 | desc=fctx.description(), | |
|
138 | parent=self.siblings(fctx.parents()), | |
|
139 | child=self.siblings(fctx.children()), | |
|
140 | rename=self.renamelink(fl, n), | |
|
141 | permissions=fctx.manifest().flags(f)) | |
|
140 | 142 | |
|
141 | 143 | |
|
142 | 144 | # monkeypatch in the new version |
General Comments 0
You need to be logged in to leave comments.
Login now