mirror of
https://github.com/facebook/docusaurus.git
synced 2025-05-25 23:17:06 +02:00
fix(utils): parse Markdown headings with CRLF line break (#7043)
This commit is contained in:
parent
5fb09a2946
commit
4f4f503633
2 changed files with 19 additions and 3 deletions
|
@ -198,13 +198,13 @@ export function parseMarkdownContentTitle(
|
|||
// `import` nodes, as broken syntax can't render anyways. That means any block
|
||||
// that has `import` at the very beginning and surrounded by empty lines.
|
||||
const contentWithoutImport = content
|
||||
.replace(/^(?:import\s(?:.|\n(?!\n))*\n{2,})*/, '')
|
||||
.replace(/^(?:import\s(?:.|\r?\n(?!\r?\n))*(?:\r?\n){2,})*/, '')
|
||||
.trim();
|
||||
|
||||
const regularTitleMatch = /^#[ \t]+(?<title>[^ \t].*)(?:\n|$)/.exec(
|
||||
const regularTitleMatch = /^#[ \t]+(?<title>[^ \t].*)(?:\r?\n|$)/.exec(
|
||||
contentWithoutImport,
|
||||
);
|
||||
const alternateTitleMatch = /^(?<title>.*)\n=+(?:\n|$)/.exec(
|
||||
const alternateTitleMatch = /^(?<title>.*)\r?\n=+(?:\r?\n|$)/.exec(
|
||||
contentWithoutImport,
|
||||
);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue