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

enhance(macros/cssxref): strip extra content from displayed link name #8854

Merged
merged 4 commits into from
Mar 28, 2024

Conversation

yarusome
Copy link
Contributor

Summary

Fixes #8853.
Depends on #8766.

Problem

To refer to CSS functions and descriptors that are subpages using {{CSSXref}}, currently it's necessary to use a rather repetitive invocation like {{CSSXref("color_value/rgb", "rgb()")}}.

Solution

This PR removes the last slash (if any) and any content before it from the displayed link name when {{CSSXref}} is specified with only one parameter.


How did you test this change?

Run the following code in the console:

function getDisplayName(arg0, arg1, arg2, pageType) {
  let displayName = (arg1 || arg0.slice(arg0.lastIndexOf("/") + 1));

  if (!arg1) {
    // Append parameter brackets to CSS functions
    if ((pageType === "css-function") && !displayName.endsWith("()")) {
      displayName += "()";
    }
  }
  
  return displayName;
}

const TEST_CASE = [
  ["color_value/lab", "", "", "css-function"],
  ["@page/size", "", "", "css-at-rule-descriptor"],
  ["abs()", "", "", "css-function"],
]

for (const caseInput of TEST_CASE) {
  console.log(getDisplayName(...caseInput));
}

/* Expected output:
 * lab()
 * size
 * abs()
 */

@github-actions github-actions bot added the macros tracking issues related to kumascript macros label May 15, 2023
@yarusome yarusome marked this pull request as ready for review May 15, 2023 02:29
@caugner caugner requested a review from a team as a code owner November 7, 2023 19:15
@github-actions github-actions bot added the idle label Jan 24, 2024
@github-actions github-actions bot added the merge conflicts 🚧 Please rebase onto or merge the latest main. label Mar 28, 2024
Copy link
Contributor

This pull request has merge conflicts that must be resolved before it can be merged.

@github-actions github-actions bot removed the merge conflicts 🚧 Please rebase onto or merge the latest main. label Mar 28, 2024
@caugner caugner changed the title feat(macros/cssxref): strip extra content from displayed link name enhance(macros/cssxref): strip extra content from displayed link name Mar 28, 2024
Copy link
Contributor

@caugner caugner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTU (@argl @fiji-flo @caugner), thanks!

@caugner caugner merged commit 3b7ab64 into mdn:main Mar 28, 2024
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
idle macros tracking issues related to kumascript macros
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Redundent use of {{CSSXref}}'s parameter for CSS descriptors and (some) functions
2 participants