Skip to content

Commit ed096bb

Browse files
committed
Leave explictly created ref divs alone
We will no incorporate an explicitly created refs target into the appendix.
1 parent ddb48d5 commit ed096bb

File tree

4 files changed

+14
-3
lines changed

4 files changed

+14
-3
lines changed

src/command/render/types.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import { Metadata } from "../../config/types.ts";
1717
import { ProjectContext } from "../../project/types.ts";
1818
import { TempContext } from "../../core/temp-types.ts";
1919
import { ExtensionContext } from "../../extension/extension-shared.ts";
20+
import { kPositionedRefs } from "../../config/constants.ts";
2021

2122
// options for render
2223
export interface RenderOptions {
@@ -57,7 +58,7 @@ export interface RunPandocResult {
5758
}
5859

5960
export interface PandocInputTraits {
60-
bibliographyTarget?: boolean;
61+
[kPositionedRefs]?: boolean;
6162
}
6263

6364
export type HtmlPostProcessor = (

src/config/constants.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -443,6 +443,9 @@ export const kTblCapLoc = "tbl-cap-location";
443443
export const kCapTop = "top";
444444
export const kCapBottom = "bottom";
445445

446+
// Pandoc Input Traits
447+
export const kPositionedRefs = "positioned-refs";
448+
446449
// https://pandoc.org/MANUAL.html#default-files
447450
// note: we are keeping some things out of 'defaults' b/ca
448451
// they are known to be valid in metadata. this includes:

src/format/html/format-html-appendix.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,12 @@
55
*
66
*/
77

8+
import { PandocInputTraits } from "../../command/render/types.ts";
89
import {
910
kAppendixAttributionBibTex,
1011
kAppendixAttributionCiteAs,
1112
kLang,
13+
kPositionedRefs,
1214
kSectionTitleCitation,
1315
kSectionTitleReuse,
1416
} from "../../config/constants.ts";
@@ -51,6 +53,7 @@ const kAppendixId = "quarto-appendix";
5153

5254
export async function processDocumentAppendix(
5355
input: string,
56+
inputTraits: PandocInputTraits,
5457
format: Format,
5558
flags: PandocFlags,
5659
doc: Document,
@@ -102,7 +105,7 @@ export async function processDocumentAppendix(
102105
};
103106

104107
// Move the refs into the appendix
105-
if (!hasMarginCites(format)) {
108+
if (!hasMarginCites(format) && !inputTraits[kPositionedRefs]) {
106109
const refsEl = doc.getElementById("refs");
107110
if (refsEl) {
108111
const findRefTitle = (refsEl: Element) => {

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ import {
2828
kHtmlFinalizers,
2929
kHtmlPostprocessors,
3030
kSassBundles,
31+
Metadata,
3132
SassLayer,
3233
} from "../../config/types.ts";
3334
import { PandocFlags } from "../../config/types.ts";
@@ -49,6 +50,7 @@ import {
4950
import {
5051
HtmlPostProcessor,
5152
HtmlPostProcessResult,
53+
PandocInputTraits,
5254
} from "../../command/render/types.ts";
5355
import { processDocumentAppendix } from "./format-html-appendix.ts";
5456
import {
@@ -211,6 +213,8 @@ function bootstrapHtmlPostprocessor(
211213
): HtmlPostProcessor {
212214
return async (
213215
doc: Document,
216+
_inputMedata: Metadata,
217+
inputTraits: PandocInputTraits,
214218
): Promise<HtmlPostProcessResult> => {
215219
// use display-7 style for title
216220
const title = doc.querySelector("header > .title");
@@ -356,7 +360,7 @@ function bootstrapHtmlPostprocessor(
356360
format.metadata[kAppendixStyle] !== false &&
357361
format.metadata[kAppendixStyle] !== "none"
358362
) {
359-
await processDocumentAppendix(input, format, flags, doc, offset);
363+
await processDocumentAppendix(input, inputTraits, format, flags, doc, offset);
360364
}
361365

362366
// no resource refs

0 commit comments

Comments
 (0)