Commit 72a2bed0 authored by Jacek Sowiński's avatar Jacek Sowiński Committed by Bram Schoenmakers

Update comments and regexps for LINK and METADATA

- do not match something like: '://example.org'
- match URLs at beginning of the line
parent 008ee60e
......@@ -39,8 +39,8 @@ PRIORITY_COLORS = {
PROJECT_COLOR = '\033[1;31m' # color for + keyword : red
CONTEXT_COLOR = '\033[1;35m' # color for @ keyword : magenta
METADATA_COLOR = '\033[1;32m' # color for @ metadata : green
LINK_COLOR = '\033[4;36m' # color for @ links : cyan/underline
METADATA_COLOR = '\033[1;32m' # color for foo:bar metadata : green
LINK_COLOR = '\033[4;36m' # color for foo://bar.baz links : cyan/underline
NEUTRAL_COLOR = '\033[0m'
class PrettyPrinterColorFilter(PrettyPrinterFilter):
......@@ -60,18 +60,17 @@ class PrettyPrinterColorFilter(PrettyPrinterFilter):
except KeyError:
pass
p_todo_str = '%s%s%s' % (color, p_todo_str, NEUTRAL_COLOR)
p_todo_str = color + p_todo_str + NEUTRAL_COLOR
if config().highlight_projects_contexts():
p_todo_str = re.sub(
r'\B(\+|@)(\S*\w)',
#PROJECT_COLOR + r'\g<0>' + color,
lambda m: (
CONTEXT_COLOR if m.group(0)[0] == "+"
else PROJECT_COLOR)+m.group(0)+color,
p_todo_str)
p_todo_str = re.sub(r'\w(\S*:[^/\s]\S*)\w',METADATA_COLOR+r'\g<0>'+color,p_todo_str)
# add LINK_COLOR to anything like : (one group od charater and a :)(// and non whitespace chars)
p_todo_str = re.sub(r'\s(\w*:){1}(//\S*\w)',' '+LINK_COLOR+r'\1\2'+color,p_todo_str)
p_todo_str = re.sub(r'\b\S+:[^/\s]\S+\b',METADATA_COLOR+r'\g<0>'+color,p_todo_str)
# add LINK_COLOR to any valid URL specified outside of the tag.
p_todo_str = re.sub(r'(^|\s)(\w+:){1}(//\S+)',' '+LINK_COLOR+r'\2\3'+color,p_todo_str)
p_todo_str += NEUTRAL_COLOR
# chnge any group of reduntant multiple NEUTRAL_GROUP occurrence to only one
p_todo_str = re.sub(r'('+re.escape(NEUTRAL_COLOR)+')+',NEUTRAL_COLOR,p_todo_str)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment