Skip to content

Commit a2a020e

Browse files
committed
Control other formats with format-links
1 parent 02737f5 commit a2a020e

File tree

4 files changed

+17
-3
lines changed

4 files changed

+17
-3
lines changed

src/config/constants.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ export const kInclude = "include";
3636
export const kResources = "resources";
3737
export const kFormatResources = "format-resources";
3838

39+
export const kFormatLinks = "format-links";
40+
3941
export const kKeepHidden = "keep-hidden";
4042

4143
export const kExecuteEnabled = "enabled";
@@ -155,6 +157,7 @@ export const kRenderDefaultsKeys = [
155157
kLinkExternalNewwindow,
156158
kLinkExternalFilter,
157159
kFormatResources,
160+
kFormatLinks,
158161
];
159162

160163
// language fields

src/config/types.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ import {
7373
kFigWidth,
7474
kFilterParams,
7575
kFilters,
76+
kFormatLinks,
7677
kFormatResources,
7778
kFreeze,
7879
kGladtex,
@@ -387,6 +388,7 @@ export interface FormatRender {
387388
[kLinkExternalFilter]?: string;
388389
[kSelfContainedMath]?: boolean;
389390
[kFormatResources]?: string[];
391+
[kFormatLinks]?: boolean;
390392
}
391393

392394
export interface FormatExecute {

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

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import { findParent } from "../../core/html.ts";
1515
import {
1616
kDisplayName,
1717
kExtensionName,
18+
kFormatLinks,
1819
kHtmlMathMethod,
1920
kIncludeInHeader,
2021
kLinkCitations,
@@ -319,7 +320,9 @@ function bootstrapHtmlPostprocessor(
319320

320321
// Inject links to other formats if there is another
321322
// format that of this file that has been rendered
322-
processAlternateFormatLinks(options, doc, format, resources);
323+
if (format.render[kFormatLinks] !== false) {
324+
processAlternateFormatLinks(options, doc, format, resources);
325+
}
323326

324327
// Look for included / embedded notebooks and include those
325328
processNotebookEmbeds(doc, format, resources);
@@ -451,9 +454,8 @@ function processAlternateFormatLinks(
451454
if (options.renderedFormats.length > 1) {
452455
let dlLinkTarget = doc.querySelector(`nav[role="doc-toc"]`);
453456
if (dlLinkTarget === null) {
454-
dlLinkTarget = doc.querySelector("#quarto-margin-sidebar");
457+
dlLinkTarget = doc.querySelector(kMarginSidebarId);
455458
}
456-
457459
if (dlLinkTarget) {
458460
const containerEl = doc.createElement("div");
459461
containerEl.classList.add("quarto-alternate-formats");

src/resources/schema/document-links.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,10 @@
2424
```
2525
^(?:http:|https:)\/\/www\.quarto\.org\/custom
2626
```
27+
28+
- name: format-links
29+
tags:
30+
formats: [$html-doc]
31+
schema: boolean
32+
description:
33+
short: "Controls whether links to other rendered formats are displayed in HTML output"

0 commit comments

Comments
 (0)