-
Notifications
You must be signed in to change notification settings - Fork 11.7k
feat: line numbers in code blocks #34844
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: develop
Are you sure you want to change the base?
feat: line numbers in code blocks #34844
Conversation
Looks like this PR is not ready to merge, because of the following issues:
Please fix the issues and try again If you have any trouble, please check the PR guidelines |
|
This commit adds line numbers in the code when sent. Since hightlight.js doesn't natively support line numbers, this commit implements a custom solution to prepend the line numbers to each line of code manually.
03f62d1
to
4395fbb
Compare
Can you note that there probably should be an option of other indicators on this. Perhaps a different way of marking up - different character sequence? Eg markup if it sees code enclosed with say We frequently copy pasted sections of code and don't want to be trying to strip line numbers from it. It break established behaviour for all users. It would also be a massive retrograde step for me and my users. The line numbers are largely irrelevant to us. Case 1. We normally just paste sections of code, so line numbers may be 250-269 so numbering from say 1 would be useless/irrelevant/misleading Case 2. If we really want line numbers we can just |
I reviewed your comments and noted the concern regarding how it's handled in Slack. I couldn't find a similar feature in Slack either.
In this case, it shouldn't cause any issues, as line numbers are currently not even present. Introducing line numbers would allow users to refer to specific lines, which could be beneficial.
Would it be feasible to add an option to toggle the line numbers instead?
I'm not sure how this would disrupt the established behavior for users. Line numbers are merely displayed and do not interfere with copying, which aligns with the current behavior.
If line numbers are not needed, then maybe we could resolve the linked issue by adding an option to toggle them on or off? |
I never mentioned Slack. No idea how it works there.
It could, but as I pointed out the line numbers could cause confusion if they do not align with the line numbers in the file. If I paste line numbers 511-520 but your code numbers them 1-10 you can see it may be an issue.
Remember that current behaviour is no line numbers at all....
I don't know. You are the one coding, not me. I suggested it should be an option. |
Yeah, it was mentioned in the issue itself. |
So if you read that you will see that Slack has a key sequence to insert code with numbers. How are you implementing that? |
This commit adds line numbers in the code when sent. Since hightlight.js doesn't natively support line numbers, this commit implements a custom solution to prepend the line numbers to each line of code manually.
Proposed changes (including videos or screenshots)
Since highligh.js doesn't support line numbers, this PR implements it by adding line numbers manually to each line of code. It also ensures that line numbers are not selected when someone is trying to select and copy the code.
This is the updated screenshot of new code block:


Issue(s)
Closes: #914