Skip to content

Commit 7c24e88

Browse files
committed
fix issue w/ chapter prefixes
1 parent 4d601a5 commit 7c24e88

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

src/project/types/book/book-crossrefs.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ function resolveCrossrefs(
8989
for (let i = 0; i < refs.length; i++) {
9090
const ref = refs[i] as Element;
9191
const id = ref.textContent;
92+
const noPrefix = ref.classList.contains("ref-noprefix");
9293
const type = refType(id);
9394
if (!type) {
9495
continue;
@@ -113,6 +114,7 @@ function resolveCrossrefs(
113114
type,
114115
index.files[entry.file],
115116
entry,
117+
noPrefix,
116118
format.language,
117119
entry.parent ? index.entries[entry.parent] : undefined,
118120
);
@@ -271,6 +273,7 @@ function formatCrossref(
271273
type: string,
272274
options: BookCrossrefOptions,
273275
entry: BookCrossrefEntry,
276+
noPrefix: boolean,
274277
language: FormatLanguage,
275278
parent?: BookCrossrefEntry,
276279
) {
@@ -285,7 +288,7 @@ function formatCrossref(
285288
} else {
286289
// if this is a section we need a prefix
287290
const refNumber = numberOption(entry.order, options, type);
288-
if (type === "sec") {
291+
if (type === "sec" && !noPrefix) {
289292
const prefix = (options[kCrossrefChapters] && isChapterRef(entry))
290293
? language[kCrossrefChPrefix]
291294
: language[kCrossrefSecPrefix];

src/resources/filters/crossref/refs.lua

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,13 @@ function resolveRefs()
6161
ref:extend({pandoc.RawInline('latex', '\\ref{' .. label .. '}')})
6262
else
6363
if not resolve then
64+
local refClasses = pandoc.List({"quarto-unresolved-ref"})
65+
if #cite.prefix > 0 or cite.mode == pandoc.SuppressAuthor then
66+
refClasses:insert("ref-noprefix")
67+
end
6468
local refSpan = pandoc.Span(
6569
stringToInlines(label),
66-
pandoc.Attr("", {"quarto-unresolved-ref"})
70+
pandoc.Attr("", refClasses)
6771
)
6872
ref:insert(refSpan)
6973
else

0 commit comments

Comments
 (0)