Skip to content

First line is not parsed as markdown #2139

Closed
@Nefcanto

Description

@Nefcanto

Marked version: 2.1.3

Describe the bug
I'm using marked in my next.js app. I have this code:

const fs = require('fs');
const marked = require("marked");

var content = fs.readFileSync('/sample/markdown/file.md', 'utf8');
content = marked(content);

And this is my file.md:

# Formal sciences

***

## Tools

- [GeoGebra](https://www.geogebra.org/)

And this is my output:

imageedit_1_3630574482

But if I only add one line to the beginning of my file.md, then I get this result:

imageedit_3_9689168460

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 your marked method passing my file's content. Nothing more.

  • Create a next.js app
  • Add marked
  • Create an html file and serve it.
  • Now change the extension of that HTML file to .md.
  • First line is not respected as markdown.

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions