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

chore(macros/cssxref): use page-type to detect CSS Functions/Data Types #7729

Merged
merged 4 commits into from Dec 2, 2022
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions kumascript/macros/cssxref.ejs
Expand Up @@ -60,11 +60,11 @@ const thisPage = (!$1 || !$2) ? wiki.getPage(urlWithoutAnchor) : null;

if (!$1) {
// Append parameter brackets to CSS functions
if (page.hasTag(thisPage, "CSS Function") && !str.endsWith("()")) {
if ((thisPage.pageType === "css-function") && !str.endsWith("()")) {
str += "()";
}
// Enclose CSS data types in arrow brackets
if (page.hasTag(thisPage, "CSS Data Type") && !/^<.+>$/.test(str)) {
if ((thisPage.pageType === "css-type") && !/^<.+>$/.test(str)) {
str = "<" + str + ">";
}
}
Expand Down
2 changes: 1 addition & 1 deletion kumascript/tests/index.test.ts
Expand Up @@ -83,7 +83,7 @@ describe("testing the main render() function", () => {
title: "<number>",
locale: "en-US",
slug: "Web/Number",
tags: ["Web", "CSS", "CSS Data Type", "Layout", "Reference"],
"page-type": "css-type",
},
rawBody: "<p>This is the number test page.</p>",
isMarkdown: false,
Expand Down
12 changes: 6 additions & 6 deletions kumascript/tests/macros/cssxref.test.ts
Expand Up @@ -30,7 +30,7 @@ const MOCK_PAGES = {
url: [CSS_BASE_URL, "display"].join("/"),
summary:
'The <strong><code>display</code></strong> <a href="/en-US/docs/Web/CSS">CSS</a> property specifies the type of rendering box used for an element.',
tags: ["CSS", "CSS Property", "CSS Display"],
pageType: "css-property",
},
},
attr: {
Expand All @@ -39,7 +39,7 @@ const MOCK_PAGES = {
url: [CSS_BASE_URL, "attr()"].join("/"),
summary:
'The <strong><code>attr()</code></strong> <a href="/en-US/docs/Web/CSS">CSS</a> function is used to retrieve the value of an attribute of the selected element and use it in the style sheet.',
tags: ["CSS", "Reference", "Web", "CSS Function", "Layout"],
pageType: "css-function",
},
},
length: {
Expand All @@ -48,7 +48,7 @@ const MOCK_PAGES = {
url: [CSS_BASE_URL, "length"].join("/"),
summary:
'The <strong><code>&lt;length&gt;</code></strong> <a href="/en-US/docs/Web/CSS">CSS</a> <a href="/en-US/docs/Web/CSS/CSS_Types">data type</a> represents a distance value.',
tags: ["CSS", "Reference", "Web", "Layout", "CSS Data Type", "length"],
pageType: "css-type",
},
},
color_value: {
Expand All @@ -57,7 +57,7 @@ const MOCK_PAGES = {
url: [CSS_BASE_URL, "color_value"].join("/"),
summary:
'The <strong><code>&lt;color&gt;</code></strong> <a href="/en-US/docs/Web/CSS">CSS</a> <a href="/en-US/docs/Web/CSS/CSS_Types">data type</a> represents a color in the <a href="https://en.wikipedia.org/wiki/SRGB" class="external">sRGB color space</a>.',
tags: ["CSS", "Reference", "Web", "CSS Data Type", "Layout"],
pageType: "css-type",
},
},
flex_value: {
Expand All @@ -66,7 +66,7 @@ const MOCK_PAGES = {
url: [CSS_BASE_URL, "flex_value"].join("/"),
summary:
'The <strong><code>&lt;flex&gt;</code></strong> <a href="/en-US/docs/Web/CSS">CSS</a> <a href="/en-US/docs/Web/CSS/CSS_Types">data type</a> denotes a flexible length within a grid container.',
tags: ["CSS", "Reference", "Web", "CSS Data Type", "Layout"],
pageType: "css-type",
},
},
position_value: {
Expand All @@ -75,7 +75,7 @@ const MOCK_PAGES = {
url: [CSS_BASE_URL, "position_value"].join("/"),
summary:
'The <strong><code>&lt;position&gt;</code></strong> <a href="/en-US/docs/Web/CSS">CSS</a> <a href="/en-US/docs/Web/CSS/CSS_Types">data type</a> denotes a two-dimensional coordinate used to set a location relative to an element box.',
tags: ["CSS", "Reference", "Web", "CSS Data Type", "Layout"],
pageType: "css-type",
},
},
};
Expand Down
8 changes: 2 additions & 6 deletions testing/content/files/en-us/web/css/number/index.html
@@ -1,11 +1,7 @@
---
title: <number>
slug: Web/CSS/number
tags:
- CSS
- CSS Data Type
- Layout
- Reference
- Web
page-type: css-type
---

<p>You've reached the number test page.</p>