Skip to content

Commit cfee8ea

Browse files
committed
fix: Improve handling of css classes in docdash publish.js
1 parent e15f0b5 commit cfee8ea

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

internal/documentation/jsdoc/docdash/publish.js

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -512,7 +512,7 @@ exports.publish = function(taffyData, opts, tutorials) {
512512
// Taken from templateHelper.js in jsdoc/util
513513

514514
function linkTo(longname, linkText, cssClass, fragmentId) {
515-
const classString = cssClass ? util.format(' class="%s"', cssClass) : '';
515+
const classString = getCssClassString(cssClass);
516516
let fileUrl;
517517
let fragmentString = fragmentId ? `#${fragmentId}` : '';
518518
let stripped;
@@ -612,7 +612,7 @@ function isComplexTypeExpression(expr) {
612612
}
613613

614614
function linkComplexType(longname, linkText, cssClass) {
615-
const classString = cssClass ? util.format(' class="%s"', cssClass) : '';
615+
const classString = getCssClassString(cssClass);
616616

617617
// Handle type unions (e.g., "string | number")
618618
if (/^.+\|.+$/.test(longname) && !/<.+>/.test(longname)) {
@@ -630,7 +630,7 @@ function linkComplexType(longname, linkText, cssClass) {
630630

631631
// Handle generic types (e.g., "Array.<string>", "Promise.<@ui5/fs/Resource>")
632632
if (/<.+>/.test(longname)) {
633-
return linkGenericType(longname, classString);
633+
return linkGenericType(longname, cssClass);
634634
}
635635

636636
// Handle record types (e.g., "{a: string, b: number}")
@@ -642,7 +642,8 @@ function linkComplexType(longname, linkText, cssClass) {
642642
return linkText || htmlsafe(longname);
643643
}
644644

645-
function linkGenericType(type, classString) {
645+
function linkGenericType(type, cssClass) {
646+
const classString = getCssClassString(cssClass);
646647
// Match patterns like "Promise.<Type>" or "Array.<Type>" or "Promise.<Array.<Type>>"
647648
const match = type.match(/^([^<]+)<(.+)>$/);
648649

@@ -672,7 +673,7 @@ function linkGenericType(type, classString) {
672673

673674
// Recursively handle the inner type
674675
if (isComplexTypeExpression(innerType)) {
675-
result += linkComplexType(innerType, null, classString.replace(' class="', '').replace('"', ''));
676+
result += linkComplexType(innerType, null, cssClass);
676677
} else {
677678
let innerUrl = helper.longnameToUrl[innerType];
678679
if (innerUrl) {
@@ -688,3 +689,7 @@ function linkGenericType(type, classString) {
688689

689690
return result;
690691
}
692+
693+
function getCssClassString(cssClass) {
694+
return cssClass ? util.format(' class="%s"', cssClass) : '';
695+
}

0 commit comments

Comments
 (0)