From ba1f9cd610416c8593d436492f7622def29c5c5e Mon Sep 17 00:00:00 2001 From: Sid Vishnoi <8426945+sidvishnoi@users.noreply.github.com> Date: Fri, 12 Apr 2024 12:38:44 +0530 Subject: [PATCH] fix(core/inlines): allow quotes in inline var's types (for enums) (#4685) --- src/core/inlines.js | 2 +- tests/spec/core/inlines-spec.js | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/core/inlines.js b/src/core/inlines.js index 5b09882411..2b627582c1 100644 --- a/src/core/inlines.js +++ b/src/core/inlines.js @@ -65,7 +65,7 @@ const l10n = getIntlData(localizationStrings); // add support. const inlineCodeRegExp = /(?:`[^`]+`)(?!`)/; // `code` const inlineIdlReference = /(?:{{[^}]+\?*}})/; // {{ WebIDLThing }}, {{ WebIDLThing? }} -const inlineVariable = /\B\|\w[\w\s]*(?:\s*:[\w\s&;<>]+\??)?\|\B/; // |var : Type?| +const inlineVariable = /\B\|\w[\w\s]*(?:\s*:[\w\s&;"<>]+\??)?\|\B/; // |var : Type?| const inlineCitation = /(?:\[\[(?:!|\\|\?)?[\w.-]+(?:|[^\]]+)?\]\])/; // [[citation]] const inlineExpansion = /(?:\[\[\[(?:!|\\|\?)?#?[\w-.]+\]\]\])/; // [[[expand]]] const inlineAnchor = /(?:\[=[^=]+=\])/; // Inline [= For/link =] diff --git a/tests/spec/core/inlines-spec.js b/tests/spec/core/inlines-spec.js index 34a25cd43c..96e5654e0f 100644 --- a/tests/spec/core/inlines-spec.js +++ b/tests/spec/core/inlines-spec.js @@ -160,6 +160,7 @@ describe("Core - Inlines", () => {

TEXT |with spaces : Type with spaces| TEXT

+

TEXT |typeWithQuotes: "valid" or "invalid"| TEXT

TEXT |variable| TEXT

TEXT | ignored | TEXT

TEXT|ignore: Ignore|TEXT

@@ -190,6 +191,10 @@ describe("Core - Inlines", () => { expect(a4.textContent).toBe("with spaces"); expect(a4.dataset.type).toBe("Type with spaces"); + const a5 = doc.querySelector("#a5 var"); + expect(a5.textContent).toBe("typeWithQuotes"); + expect(a5.dataset.type).toBe(`"valid" or "invalid"`); + const b = doc.querySelector("#b var"); expect(b.textContent).toBe("variable"); expect(b.dataset.type).toBeUndefined();