summaryrefslogtreecommitdiffstats
path: root/src/g2h
diff options
context:
space:
mode:
Diffstat (limited to 'src/g2h')
-rw-r--r--src/g2h/cli.py1
-rw-r--r--src/g2h/file_page.py6
2 files changed, 7 insertions, 0 deletions
diff --git a/src/g2h/cli.py b/src/g2h/cli.py
index d61b71b..fe3850c 100644
--- a/src/g2h/cli.py
+++ b/src/g2h/cli.py
@@ -10,6 +10,7 @@ def parse_args():
description='Convert a git repository into markdown files Hugo can understand.')
parser.add_argument('--repo', help='Path to the root of git repository', default=os.getcwd())
parser.add_argument('--out', help='Path to where the generated files should be stored', default=os.getcwd())
+ # TODO: Add an actual default value.
parser.add_argument('--name', help='Name of the project. Default: directory name of repo')
parser.add_argument('--content-subdir', help='Subdir(s) where the page will be served from. Default: None', default='')
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,