summaryrefslogtreecommitdiffstats
path: root/src/g2h/file_page.py
diff options
context:
space:
mode:
Diffstat (limited to 'src/g2h/file_page.py')
-rw-r--r--src/g2h/file_page.py6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/g2h/file_page.py b/src/g2h/file_page.py
index a558254..d64cb84 100644
--- a/src/g2h/file_page.py
+++ b/src/g2h/file_page.py
@@ -1,6 +1,7 @@
import base64
import filetype
import os
+import re
from .file import generate_breadcrumbs, sanitize_file_name, tree_join
from .page import Page
@@ -35,8 +36,13 @@ class FilePage(Page):
def context(self):
file_bytes = self.read_file()
content, file_type = bytes_to_content(file_bytes)
+ backtick_max = 2
+ if file_type == 'text':
+ matches = re.findall('`+', content)
+ backtick_max = max(max(len(match) for match in matches) if matches else 0, backtick_max)
return {
+ 'backtick_max': backtick_max + 1,
'breadcrumbs': generate_breadcrumbs(self.content_subdir, self.commit, os.path.join(self.file_path, self.file_name), self.tree.blobs),
'content': content,
'content_subdir': self.content_subdir,