Skip to content
This repository has been archived by the owner on Jun 7, 2024. It is now read-only.

Commit

Permalink
fix(core/inlines): support nullable type in variable declarations (sp…
Browse files Browse the repository at this point in the history
  • Loading branch information
marcoscaceres authored Jun 15, 2021
1 parent 7babccc commit 8bdb284
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/core/inlines.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 =]
Expand Down
9 changes: 9 additions & 0 deletions tests/spec/core/inlines-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,9 @@ describe("Core - Inlines", () => {
<section>
<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>
</section>
`;
const doc = await makeRSDoc(makeStandardOps(null, body));

Expand Down Expand Up @@ -188,6 +191,12 @@ describe("Core - Inlines", () => {
expect(h[0].dataset.type).toBe("Generic<int>");
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?");
});

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

0 comments on commit 8bdb284

Please sign in to comment.