mirror of
https://github.com/facebook/docusaurus.git
synced 2025-06-23 13:07:57 +02:00
fix(utils): handle CRLF when parsing MDX imports (#8606)
This commit is contained in:
parent
ece720b1a7
commit
2f02beebe2
2 changed files with 25 additions and 3 deletions
|
@ -55,16 +55,18 @@ export function createExcerpt(fileString: string): string | undefined {
|
|||
const fileLines = fileString
|
||||
.trimStart()
|
||||
// Remove Markdown alternate title
|
||||
.replace(/^[^\n]*\n[=]+/g, '')
|
||||
.split('\n');
|
||||
.replace(/^[^\r\n]*\r?\n[=]+/g, '')
|
||||
.split(/\r?\n/);
|
||||
let inCode = false;
|
||||
let inImport = false;
|
||||
let lastCodeFence = '';
|
||||
|
||||
for (const fileLine of fileLines) {
|
||||
if (fileLine === '' && inImport) {
|
||||
// An empty line marks the end of imports
|
||||
if (!fileLine.trim() && inImport) {
|
||||
inImport = false;
|
||||
}
|
||||
|
||||
// Skip empty line.
|
||||
if (!fileLine.trim()) {
|
||||
continue;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue