Skip to content

Commit 7e62b54

Browse files
committed
If no displayable other formats are present, omit any of the html
1 parent 7b3f97e commit 7e62b54

File tree

1 file changed

+43
-38
lines changed

1 file changed

+43
-38
lines changed

src/format/html/format-html-bootstrap.ts

Lines changed: 43 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -526,49 +526,54 @@ function processAlternateFormatLinks(
526526
})
527527
: options.renderedFormats;
528528

529-
for (const renderedFormat of displayFormats) {
530-
if (!isHtmlOutput(renderedFormat.format.pandoc, true)) {
531-
const li = doc.createElement("li");
532-
533-
const relPath = isAbsolute(renderedFormat.path)
534-
? relative(dirname(input), renderedFormat.path)
535-
: renderedFormat.path;
536-
537-
const link = doc.createElement("a");
538-
link.setAttribute("href", relPath);
539-
const dlAttrValue = fileDownloadAttr(
540-
renderedFormat.format,
541-
renderedFormat.path,
542-
);
543-
if (dlAttrValue) {
544-
link.setAttribute("download", dlAttrValue);
545-
}
529+
const finalDisplayFormats = displayFormats.filter((renderedFormat) => {
530+
return !isHtmlOutput(renderedFormat.format.pandoc, true);
531+
});
546532

547-
const icon = doc.createElement("i");
548-
icon.classList.add("bi");
549-
icon.classList.add(`bi-${fileBsIconName(renderedFormat.format)}`);
550-
link.appendChild(icon);
551-
link.appendChild(
552-
doc.createTextNode(
553-
`${
554-
renderedFormat.format.identifier[kDisplayName] ||
555-
renderedFormat.format.pandoc.to
556-
}${
557-
renderedFormat.format.identifier[kExtensionName]
558-
? ` (${renderedFormat.format.identifier[kExtensionName]})`
559-
: ""
560-
}`,
561-
),
562-
);
533+
for (const renderedFormat of finalDisplayFormats) {
534+
const li = doc.createElement("li");
563535

564-
li.appendChild(link);
565-
formatList.appendChild(li);
536+
const relPath = isAbsolute(renderedFormat.path)
537+
? relative(dirname(input), renderedFormat.path)
538+
: renderedFormat.path;
566539

567-
resources.push(renderedFormat.path);
540+
const link = doc.createElement("a");
541+
link.setAttribute("href", relPath);
542+
const dlAttrValue = fileDownloadAttr(
543+
renderedFormat.format,
544+
renderedFormat.path,
545+
);
546+
if (dlAttrValue) {
547+
link.setAttribute("download", dlAttrValue);
568548
}
549+
550+
const icon = doc.createElement("i");
551+
icon.classList.add("bi");
552+
icon.classList.add(`bi-${fileBsIconName(renderedFormat.format)}`);
553+
link.appendChild(icon);
554+
link.appendChild(
555+
doc.createTextNode(
556+
`${
557+
renderedFormat.format.identifier[kDisplayName] ||
558+
renderedFormat.format.pandoc.to
559+
}${
560+
renderedFormat.format.identifier[kExtensionName]
561+
? ` (${renderedFormat.format.identifier[kExtensionName]})`
562+
: ""
563+
}`,
564+
),
565+
);
566+
567+
li.appendChild(link);
568+
formatList.appendChild(li);
569+
570+
resources.push(renderedFormat.path);
571+
}
572+
573+
if (finalDisplayFormats.length > 0) {
574+
containerEl.appendChild(formatList);
575+
dlLinkTarget.appendChild(containerEl);
569576
}
570-
containerEl.appendChild(formatList);
571-
dlLinkTarget.appendChild(containerEl);
572577
}
573578
}
574579
}

0 commit comments

Comments
 (0)