From 54026b7585badf3736ad97f6f6e1d656d9f469e2 Mon Sep 17 00:00:00 2001 From: Alberto Bertogli Date: Sat, 2 Nov 2013 21:12:50 +0000 Subject: Make embedding markdown and images configurable per-repo This patch introduces the embed_markdown and embed_images configuration options, so users can enable and disable those features on a per-repository basis. Signed-off-by: Alberto Bertogli --- utils.py | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'utils.py') diff --git a/utils.py b/utils.py index b40624b..51141e4 100644 --- a/utils.py +++ b/utils.py @@ -48,20 +48,23 @@ def can_colorize(s): return True -def can_markdown(fname): +def can_markdown(repo, fname): """True if we can process file through markdown, False otherwise.""" if markdown is None: return False + if not repo.info.embed_markdown: + return False + return fname.endswith(".md") -def can_embed_image(fname): +def can_embed_image(repo, fname): """True if we can embed image file in HTML, False otherwise.""" - exts = [ 'jpg', 'jpeg', 'png', 'gif' ] - if '.' in fname and fname.split('.')[-1].lower() in exts: - return True + if not repo.info.embed_images: + return False - return False + return (('.' in fname) and + (fname.split('.')[-1].lower() in [ 'jpg', 'jpeg', 'png', 'gif' ])) def colorize_diff(s): lexer = lexers.DiffLexer(encoding = 'utf-8') -- cgit v1.2.3