Basit Anwer commited on
Commit
6e3243e
1 Parent(s): aa00404

Fixed highlighting issue

Browse files
Files changed (1) hide show
  1. actions/actions.py +5 -6
actions/actions.py CHANGED
@@ -109,7 +109,7 @@ def highlight(fulltext, snippet):
109
  start = fulltext.index(snippet)
110
  end = start + len(snippet)
111
 
112
- lines = textwrap.wrap(fulltext)
113
  start_line = 0
114
  end_line = len(lines)
115
  pos = 0
@@ -124,17 +124,17 @@ def highlight(fulltext, snippet):
124
 
125
  if color_start and color_end:
126
  start_line = end_line = x
127
- ips = start - pos - x # insertion point
128
- ipe = end - pos - x # insertion point
129
  lines[x] = line[:ips] + "**" + line[ips:ipe] + \
130
  "**" + line[ipe:]
131
  elif color_start:
132
  start_line = x
133
- ip = start - pos - x # insertion point
134
  lines[x] = line[:ip] + "**" + line[ip:]
135
  elif color_end:
136
  end_line = x
137
- ip = end - pos - x # insertion point
138
  lines[x] = line[:ip] + "**" + line[ip:]
139
 
140
  pos = next_pos
@@ -146,7 +146,6 @@ def highlight(fulltext, snippet):
146
  return prettify('\n'.join(lines[start_line:end_line]))
147
  return prettify(snippet)
148
 
149
-
150
  def head(fulltext):
151
  """Returns the first three lines of the review."""
152
  lines = textwrap.wrap(fulltext)
 
109
  start = fulltext.index(snippet)
110
  end = start + len(snippet)
111
 
112
+ lines = textwrap.wrap(fulltext, drop_whitespace=False)
113
  start_line = 0
114
  end_line = len(lines)
115
  pos = 0
 
124
 
125
  if color_start and color_end:
126
  start_line = end_line = x
127
+ ips = start - pos # insertion point
128
+ ipe = end - pos # insertion point
129
  lines[x] = line[:ips] + "**" + line[ips:ipe] + \
130
  "**" + line[ipe:]
131
  elif color_start:
132
  start_line = x
133
+ ip = start - pos # insertion point
134
  lines[x] = line[:ip] + "**" + line[ip:]
135
  elif color_end:
136
  end_line = x
137
+ ip = end - pos # insertion point
138
  lines[x] = line[:ip] + "**" + line[ip:]
139
 
140
  pos = next_pos
 
146
  return prettify('\n'.join(lines[start_line:end_line]))
147
  return prettify(snippet)
148
 
 
149
  def head(fulltext):
150
  """Returns the first three lines of the review."""
151
  lines = textwrap.wrap(fulltext)