-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Optimize Markdown ToC checker script #886
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
All contributors have signed the CLA ✍️ ✅ |
I have read the CLA Document and I hereby sign the CLA |
recheck |
@maintainers Could you please review and approve this PR? The CLA has been signed, and all checks have passed. Thank you! |
return 0 | ||
|
||
|
||
def main(): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please reorganize main()
as I had it before:
- Top of file so reader does not have to dig to the end of the file to figure out what arguments this script accepts.
- As good practice,
main()
should not callsys.exit()
itself. That behavior should be restricted toif __name__ == "__main__"
slug = text.lower() | ||
# normalize spaces and dashes | ||
slug = slug.replace("\u00a0", " ") | ||
level, title = len(m.group(1)), m.group(2).strip() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please keep these as separate lines as before
print(line) | ||
# Show diff | ||
print("ERROR: ToC out of date. Diff:") | ||
for ln in unified_diff(current, expected, fromfile="existing ToC", tofile="generated ToC", lineterm=""): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
prefer line
to ln
Optimize Markdown ToC checker script