-
-
Notifications
You must be signed in to change notification settings - Fork 363
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
Do not add multiple line feeds at end of file #440
Conversation
This shouldn’t happen 🤔 What code are you using that keeps on adding an extra line feed? |
I use VIM modelines at the end of my markdown files, and maybe the problem is that the comments are unclosed |
If I run `remark-cli` several times on a file, each run will insert a final newline to the end of the checked target file. This commit adds a verification to check if the file already ends with a linefeed and doesn't include additional ones when not needed.
Hmm, it is expected that the initial file, without an EOF EOL, has an EOL. It is also expected that after adding the comment, another EOF EOL is added. But the other EOLs are superfluous 🤔 |
there are EOF EOL, they just doesn't show up. If they were missing, git diffs would report for the initial version... diff --git a/README.md b/README.md
new file mode 100644
index 0000000..b45ef6f
--- /dev/null
+++ b/README.md
@@ -0,0 +1 @@
+Hello, World!
\ No newline at end of file ...and for the comment version diff --git a/README.md b/README.md
index 8ab686e..706a8d7 100644
--- a/README.md
+++ b/README.md
@@ -1 +1,3 @@
Hello, World!
+
+<!-- vim: set ai si sta et sw=4 sts=4 fenc=utf-8 nobomb eol ff=unix ft=markdown:
\ No newline at end of file Also, after the very first run of |
I don't know typescript and can't make the build pass. Can you give me directions? |
Ah, TS checking recently started failing: unifiedjs/unified@9786410. I’ll work on a fix |
The problem is the final unclosed HTML: var remark = require('./packages/remark')
var doc = `Hello, World!`
var index = 3
while (index--) {
doc = remark()
.processSync(doc)
.toString()
console.log([doc])
} Yields:
var remark = require('./packages/remark')
var doc = `Hello, World!
<!-- asd -->`
var index = 3
while (index--) {
doc = remark()
.processSync(doc)
.toString()
console.log([doc])
} Yields:
var remark = require('./packages/remark')
var doc = `Hello, World!
<!-- asd`
var index = 3
while (index--) {
doc = remark()
.processSync(doc)
.toString()
console.log([doc])
} Yields:
|
Note btw, that VIM modelines, from the examples the doc you linked show, should be valid comments. |
I refactor the code a bit; thanks for working on this! |
If I run
remark-cli
several times on a file, each run will insert a final newline to the end of the checked target file.This commit adds a verification to check if the file already ends with a linefeed and doesn't include additional ones when not needed.