diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml
index 4830a1f7a59e..245eb90d92d2 100644
--- a/.github/workflows/codeql-analysis.yml
+++ b/.github/workflows/codeql-analysis.yml
@@ -31,10 +31,10 @@ jobs:
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
- name: Initialize CodeQL
- uses: github/codeql-action/init@4e94bd11f71e507f7f87df81788dff88d1dacbfb # 4.31.0
+ uses: github/codeql-action/init@8aad20d150bbac5944a9f9d289da16a4b0d87c1e # 4.36.2
with:
languages: javascript-typescript
config-file: ./.github/codeql/codeql-config.yml
- name: Perform CodeQL Analysis
- uses: github/codeql-action/analyze@4e94bd11f71e507f7f87df81788dff88d1dacbfb # 4.31.0
+ uses: github/codeql-action/analyze@8aad20d150bbac5944a9f9d289da16a4b0d87c1e # 4.36.2
diff --git a/packages/docusaurus-utils/src/__tests__/markdownUtils.test.ts b/packages/docusaurus-utils/src/__tests__/markdownUtils.test.ts
index 7e1668cd415f..a81e8cfff103 100644
--- a/packages/docusaurus-utils/src/__tests__/markdownUtils.test.ts
+++ b/packages/docusaurus-utils/src/__tests__/markdownUtils.test.ts
@@ -174,6 +174,18 @@ describe('createExcerpt', () => {
).toBe('Lorem ipsum dolor sit amet, consectetur adipiscing elit.');
});
+ it('creates excerpt after a multi-line JSX element', () => {
+ expect(
+ createExcerpt(dedent`
+
+
+ Lorem ipsum dolor sit amet.
+ `),
+ ).toBe('Lorem ipsum dolor sit amet.');
+ });
+
it('creates excerpt after multi-line imports', () => {
expect(
createExcerpt(dedent`
diff --git a/packages/docusaurus-utils/src/markdownUtils.ts b/packages/docusaurus-utils/src/markdownUtils.ts
index d411f1ca28cd..216d0122e7ad 100644
--- a/packages/docusaurus-utils/src/markdownUtils.ts
+++ b/packages/docusaurus-utils/src/markdownUtils.ts
@@ -92,6 +92,7 @@ export function createExcerpt(fileString: string): string | undefined {
.split(/\r?\n/);
let inCode = false;
let inImport = false;
+ let inHTML = false;
let lastCodeFence = '';
for (const fileLine of fileLines) {
@@ -127,6 +128,20 @@ export function createExcerpt(fileString: string): string | undefined {
continue;
}
+ // Skip lines inside a multi-line JSX/HTML element. An opening "" on the same line would otherwise leak into the excerpt
+ // (e.g. "')) {
+ inHTML = false;
+ }
+ continue;
+ }
+ if (/^\s*<[a-z][^>]*$/i.test(fileLine)) {
+ inHTML = true;
+ continue;
+ }
+
const cleanedLine = fileLine
// Remove HTML tags.
.replace(/<[^>]*>/g, '')