-
Notifications
You must be signed in to change notification settings - Fork 244
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
DRIVERS-2789 Add script to check for malformed links
- Loading branch information
Showing
2 changed files
with
30 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import sys | ||
fname = sys.argv[-1] | ||
|
||
# Check for markdown links that got improperly line wrapped. | ||
with open(fname) as fid: | ||
for line in fid: | ||
id0 = line.index('[') if '[' in line else -1 | ||
id1 = line.index(']') if ']' in line else -1 | ||
id2 = line.index('(') if '(' in line else -1 | ||
id3 = line.index(')') if ')' in line else -1 | ||
if id1 == -1 or id2 == -1 or id3 == -1: | ||
continue | ||
if id2 < id1 or id3 < id2: | ||
continue | ||
if id0 == -1: | ||
print('*** Malformed link in line:', line, fname) | ||
sys.exit(1) |