Skip to content

Commit

Permalink
Ignore initial spaces in locating a line for anchor
Browse files Browse the repository at this point in the history
  • Loading branch information
kwankyu committed Aug 4, 2024
1 parent 0f34773 commit 4520ef0
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions .ci/create-changes-html.sh
Original file line number Diff line number Diff line change
Expand Up @@ -83,12 +83,18 @@ for block in diff_blocks:
hunk_lines = []
search_result = re.search(r'@@ -(\d+),(\d+) \+(\d+),(\d+)', line)
if search_result:
line_number = int(search_result.group(3))
line_number = int(search_result.group(3)) - 1
span = int(search_result.group(4))
for i in chain(range(line_number, line_number + span), range(line_number - 1, -1, -1)):
if content[i].startswith('<') and not content[i].startswith('</'):
for i in chain(range(line_number, line_number + span), range(line_number, -1, -1)):
ln = content[i]
for idx, char in enumerate(ln):
if not char.isspace():
break
else:
idx = len(ln)
if ln.startswith('<', idx) and not ln.startswith('</', idx):
count += 1
content[i] = f'<span id="hunk{count}" style="visibility: hidden;"></span>' + content[i]
content[i] = ln[:idx] + f'<span id="hunk{count}" style="visibility: hidden;"></span>' + ln[idx:]
hunks.append(f'<p class="hunk"><a href="{path}#hunk{count}" class="hunk" target="_blank">hunk #{count}</a></p>')
break
hunk_lines.append(line)
Expand Down

0 comments on commit 4520ef0

Please sign in to comment.