From 8aef4c91d494b1578be29a776bdbb81d8400f805 Mon Sep 17 00:00:00 2001 From: yarusome <97945148+yarusome@users.noreply.github.com> Date: Mon, 15 May 2023 00:01:14 +0800 Subject: [PATCH] Strip extra content from displayed link name --- kumascript/macros/cssxref.ejs | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/kumascript/macros/cssxref.ejs b/kumascript/macros/cssxref.ejs index 2538de5410fc..5812cef7642c 100644 --- a/kumascript/macros/cssxref.ejs +++ b/kumascript/macros/cssxref.ejs @@ -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) @@ -18,9 +22,8 @@ {{cssxref("length")}} => <length> - {{cssxref("linear-gradient()")}} => - linear-gradient() + {{cssxref("gradient/linear-gradient")}} => + linear-gradient() {{cssxref("margin-top", "top margin")}} => top margin @@ -31,7 +34,7 @@ var lang = env.locale; var url = ""; var urlWithoutAnchor = ""; -var displayName = ($1 || $0); +let displayName = ($1 || $0.slice($0.lastIndexOf("/") + 1)); // Deal with CSS data types by removing <> var slug = $0.replace(/<(.*)>/g, '$1');