Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(core/inlines): support generic nullable type in inline var #4709

Merged
merged 2 commits into from
May 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/core/inlines.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 =]
Expand Down
15 changes: 9 additions & 6 deletions tests/spec/core/inlines-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ describe("Core - Inlines", () => {
<p id="h"> TEXT |var: Generic&lt;int&gt;| TEXT |var2: Generic&lt;unsigned short int&gt;| </p>
</section>
<section>
<p id="nulls"> |var 1: null type spaces?| and |var 2 : NullableType?| </p>
<p id="nulls"> |var 1: null type spaces?| and |var 2 : NullableType?| and |var 3: Generic&lt;NullableType?&gt;|</p>
</section>
`;
const doc = await makeRSDoc(makeStandardOps(null, body));
Expand Down Expand Up @@ -223,11 +223,14 @@ describe("Core - Inlines", () => {
expect(h[1].textContent).toBe("var2");
expect(h[1].dataset.type).toBe("Generic<unsigned short int>");

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?");
const nulls = doc.querySelectorAll("#nulls > var");
expect(nulls).toHaveSize(3);
expect(nulls[0].textContent).toBe("var 1");
expect(nulls[0].dataset.type).toBe("null type spaces?");
expect(nulls[1].textContent).toBe("var 2");
expect(nulls[1].dataset.type).toBe("NullableType?");
expect(nulls[2].textContent).toBe("var 3");
expect(nulls[2].dataset.type).toBe("Generic<NullableType?>");
});

it("expands inline references and they get classified as normative/informative correctly", async () => {
Expand Down
Loading