djcev.com

//

Git Repos / blogofile_gitview / commit 993ba07

Commit: 993ba075ea57234d16b309bb9e612f682da435d1
Parent: 23af687919307630d8f7b540d2b259e71c0b7c60
Author: Cameron Vanderzanden, 2021-08-03 20:40
Committer: Cameron Vanderzanden, 2021-08-03 20:40

Commit Message

Pygments wasn't detecting mako files; add override

This is probably a bad idea.

Change List

?File Add Del
M _controllers/gitview.py +6 -1

Diff _controllers/gitview.py

diff --git a/_controllers/gitview.py b/_controllers/gitview.py
index 6dc9a42..90fc67f 100644
--- a/_controllers/gitview.py
+++ b/_controllers/gitview.py
@@ -187,7 +187,12 @@ def format_obj_text(repoinfo, obj, path):
# run obj.data thru pygments
data = str(obj.data, sys.stdout.encoding)
try:
- lexer = pygments.lexers.guess_lexer_for_filename(obj.name, data)
+ # TODO: for some reason guess_lexer_for_filename doesn't detect
+ # my mako templates. So let's test file extension...
+ if obj.name.endswith(".mako"):
+ lexer = pygments.lexers.get_lexer_by_name("mako")
+ else:
+ lexer = pygments.lexers.guess_lexer_for_filename(obj.name, data)
except pygments.util.ClassNotFound:
lexer = pygments.lexers.get_lexer_by_name("text")
lexer.tabsize = 8

Return to the top of this page or return to the overview of this repo.