From 8bdb284a6d1d25e2928b89722d252b993ff9182f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcos=20C=C3=A1ceres?= Date: Tue, 15 Jun 2021 11:48:34 +1000 Subject: [PATCH] fix(core/inlines): support nullable type in variable declarations (#3627) --- src/core/inlines.js | 2 +- tests/spec/core/inlines-spec.js | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/core/inlines.js b/src/core/inlines.js index c6cc434a87..72fd63d45b 100644 --- a/src/core/inlines.js +++ b/src/core/inlines.js @@ -62,7 +62,7 @@ const l10n = getIntlData(localizationStrings); // add support. const inlineCodeRegExp = /(?:`[^`]+`)(?!`)/; // `code` const inlineIdlReference = /(?:{{[^}]+}})/; // {{ 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 5483994345..1680405959 100644 --- a/tests/spec/core/inlines-spec.js +++ b/tests/spec/core/inlines-spec.js @@ -143,6 +143,9 @@ describe("Core - Inlines", () => {

TEXT |var: Generic<int>| TEXT |var2: Generic<unsigned short int>|

+
+

|var 1: null type spaces?| and |var 2 : NullableType?|

+
`; const doc = await makeRSDoc(makeStandardOps(null, body)); @@ -188,6 +191,12 @@ describe("Core - Inlines", () => { expect(h[0].dataset.type).toBe("Generic"); expect(h[1].textContent).toBe("var2"); expect(h[1].dataset.type).toBe("Generic"); + + const [nullVar1, nullVar2] = doc.querySelectorAll("#nulls > var"); + expect(nullVar1.textContent).toBe("var 1"); + expect(nullVar1.dataset.type).toBe("null type spaces?"); + expect(nullVar2.textContent).toBe("var 2"); + expect(nullVar2.dataset.type).toBe("NullableType?"); }); it("expands inline references and they get classified as normative/informative correctly", async () => {