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
Merged
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
8 changes: 7 additions & 1 deletion kumascript/macros/cssxref.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@
This template handles CSS data types and CSS functions gracefully by
automatically adding arrow brackets or round brackets, respectively.

For the ease of linking to CSS descriptors and functions, if only one
parameter is specified and it contains a slash, the displayed link name
will strip the last slash and any content before it.

Parameters:
$0 - API name to refer to
$1 - name of the link to display (optional)
Expand All @@ -16,6 +20,8 @@
<a href="/en-US/docs/Web/CSS/background"><code>background</code></a>
{{cssxref("length")}} =>
<a href="/en-US/docs/Web/CSS/length"><code>&lt;length&gt;</code></a>
{{cssxref("gradient/linear-gradient")}} =>
<a href="/en-US/docs/Web/CSS/gradient/linear-gradient"><code>linear-gradient()</code></a>
{{cssxref("calc()")}} =>
<a href="/en-US/docs/Web/CSS/calc"><code>calc()</code></a>
{{cssxref("margin-top", "top margin")}} =>
Expand All @@ -27,7 +33,7 @@
const lang = env.locale;
let url = "";
let urlWithoutAnchor = "";
let displayName = ($1 || $0);
let displayName = ($1 || $0.slice($0.lastIndexOf("/") + 1));

// Deal with CSS data types and functions by removing <> and ()
let slug = $0.replace(/&lt;(.*)&gt;/g, "$1")
Expand Down
Loading