-
Notifications
You must be signed in to change notification settings - Fork 3.4k
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
First line is not parsed as markdown #2139
Comments
Is this only for |
@calculuschild, that's weird, it's working for all other markdowns, but it's not working for |
It sounds like something is happening in this conversion. Can you see what var content = fs.readFileSync('/sample/markdown/file.md', 'utf8');
console.log(content);
content = marked(content); |
Well, I did that. And I don't see any difference. At least in the console. And since I'm running this inside But I used |
I managed to solve the problem by this line of code:
But I think it's better that you should also consider handling this thing. Thank you so much for this amazing tool. |
Aha. Yep, that looks like the Byte Order Marker that some text editors will insert into a document as a note that the document is UTF-8 encoded. Also known as a zero width no-break space. We can probably filter it out in the start of the Lexer like we do with some other Unicode characters and replace it with a blank or a simple whitespace. |
I would rather not automatically remove or replace anything more unless there is a reason to believe no one would ever want it (or it complies with the CommonMark spec). It is easier to document that users need to replace it before running it through marked. Otherwise we get people who want to keep it in there and no way for them to do so (example). |
I tried to make a code PR addressing this, but after going through the code and CommonMark spec, I see @UziTech is right: Straight out removing this characters might in some cases cause problems for someone using this library and changing the regex to ignore them would not be up to CommonMark spec. |
Marked version: 2.1.3
Describe the bug
I'm using
marked
in mynext.js
app. I have this code:And this is my
file.md
:And this is my output:
But if I only add one line to the beginning of my
file.md
, then I get this result:To Reproduce
Steps to reproduce the behavior:
It works on your demo playground. But it doesn't work in my
next.js
app. And I only call yourmarked
method passing my file's content. Nothing more.next.js
appmarked
html
file and serve it.HTML
file to.md
.If we create
.md
file in the first place, things work as expected. But when we change the extension of an existing HTML file to .md, first line breaks.Expected behavior
The first line should be respected as markdown too. I can't add an empty line to all of my files.
The text was updated successfully, but these errors were encountered: