mirror of
https://github.com/DavidAnson/markdownlint.git
synced 2026-04-25 17:26:22 +03:00
[GH-ISSUE #187] MD047/single-trailing-newline bug? #162
Labels
No labels
bug
enhancement
enhancement
enhancement
fixed in next
fixed in next
fixed in next
new rule
new rule
new rule
pull-request
question
refactoring
refactoring
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/markdownlint#162
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @mathiasbynens on GitHub (May 17, 2019).
Original GitHub issue: https://github.com/DavidAnson/markdownlint/issues/187
Reproduction steps:
git clone git@github.com:v8/v8.dev.git && cd v8.devnpm install(note: this includesmarkdownlint-cli@0.15.0)npm install markdownlint-cli@0.16.0markdownlint src/**/*.mdfails with the following error message:But, the last character in the file is definitely a U+000A LF character, as evidenced by
hexdump:Ref.
https://github.com/DavidAnson/markdownlint/pull/176
https://github.com/igorshubovych/markdownlint-cli/issues/56
@DavidAnson commented on GitHub (May 17, 2019):
On a bus with a phone right now, but I’m suddenly afraid this is a CR/LF platform/encoding issue. I will have a look tonight and release a fix shortly if the rule is in error.
@DavidAnson commented on GitHub (May 17, 2019):
For the record, I am not a total buffoon - this rule behaves as expected on Windows, Mac, and Linux with default Git line ending settings: https://travis-ci.org/DavidAnson/markdownlint
@nschonni commented on GitHub (May 17, 2019):
I opened up the repo and it looks like the file is encoded with CRLF, except for link 94, which is CR. I
Edit: nvm, missed in the block
@mathiasbynens commented on GitHub (May 17, 2019):
Ok, let’s focus on the
scanner.mdfile for now, since the above discussion already indicates there’s something weird going on.The file is here: https://github.com/v8/v8.dev/blob/master/src/blog/scanner.md Its raw URL is https://raw.githubusercontent.com/v8/v8.dev/master/src/blog/scanner.md.
Just to make sure we’re all talking about the same exact thing, with no special Git config that normalizes line endings or anything like that, here’s the SHA256 checksum of the file:
I can confirm just downloading the raw version gets you the exact same file:
@nschonni Are you getting the same checksum? When you say “it looks like the file is encoded with CRLF, except for line 94, which is CR” that’s highly surprising, as I cannot confirm that at all.
@mathiasbynens commented on GitHub (May 17, 2019):
Here are simplified repro instructions:
Expected results
The output should not include any warnings related to
MD047/single-trailing-newline.Actual results
The output includes:
@nschonni commented on GitHub (May 17, 2019):
Sorry, I threw in a VS Code extension to show line endings, but it looks like it was bad. Opening in Notepad++ does show it as CRLF (unless I do that test curl, then it as LF, but still failed)
@mathiasbynens commented on GitHub (May 17, 2019):
This is still surprising! The file is not supposed to contain any CRLF (i.e. U+000D U+000A) and doesn’t seem to, assuming
hexdumpis correct. 🤔 I wonder why you’re seeing something else than I am. Did you check if the checksum matches?@nschonni commented on GitHub (May 17, 2019):
I'll check that next. It did find what was tripping it up. This line if removed makes it happy
Since the rule does a quick check of line lengths, I think for whatever reason it's not counting this line and is throwing off the calculation
github.com/DavidAnson/markdownlint@0b9b74ccfd/lib/md047.js (L11-L17)@nschonni commented on GitHub (May 17, 2019):
@DavidAnson commented on GitHub (May 17, 2019):
That line may be tripping up the HTML comment detection code. If so, MD047 may be correct itself, but seeing the second-to-last line instead.
@DavidAnson commented on GitHub (May 17, 2019):
Yep, here’s a repro: https://dlaa.me/markdownlint/#%25m%23%20Heading%0A%0A%5B%5E1%5D%3A%20%60%3C!--%60%20is%2C%20whereas%20%60%3C!-%60%20scans%0A%0AText%0A
Sorry about that!
@DavidAnson commented on GitHub (May 17, 2019):
Slightly simpler: https://dlaa.me/markdownlint/#%25m%23%20Heading%0A%0A%60%3C!--%60%0A
I will debug later from a real computer. :)
Thanks for helping track this down, both of you!!
@DavidAnson commented on GitHub (May 17, 2019):
I've fixed this scenario, but realized there's a bigger issue with the handling of HTML comment bodies such that
<!--inside a code fence/span/block isn't correctly ignored. I'll address that in a future release. I'll release a patch with this commit in the next few days.@DavidAnson commented on GitHub (May 18, 2019):
@mathiasbynens: Version
0.14.2ofmarkdownlintis now available. If you reinstall the CLI, it should pick up the new reference.@mathiasbynens commented on GitHub (May 19, 2019):
Thanks for the quick fix!