Skip to content
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

(GitHub Collapse In Comment) numberOfLines appears to be +1 (it takes </code> as line) #149

Open
darkred opened this issue Jun 17, 2021 · 0 comments

Comments

@darkred
Copy link
Collaborator

darkred commented Jun 17, 2021

I've noticed in 'GitHub Collapse In Comment' that the lines count value appears to be +1 the expected one.

The relevant line in the script:

numberOfLines = el.innerHTML.split("\n").length;

For the following block:

line 1
line 2
line 3
line 4
line 5
line 6
line 7
line 8
line 9
line 10
line 11

I get:

The markdown I used for the code fenching is just backticks: screenshot

For the above block, the numberOfLines is 12 instead of 11,
and that's because it takes in the produced innerHTML the closing </code> as a separate line:

screenshot
document.querySelector('.markdown-body pre, .email-signature-reply').innerHTML.split("\n")

2021-06-17_221313

@Mottie, maybe we should add something like .replace('</code>', '') right after .split("\n") ?

PS. Using latest Tampermonkey/Violentmonkey in fresh profile of Chrome 91.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant