Skip to content

Commit cfb7d4c

Browse files
authored
Merge pull request #1380 from quarto-dev/bugfix/ext-path3
Extension Path Improvements + Tests
2 parents c732697 + 3a0802c commit cfb7d4c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+10970
-8
lines changed

src/extension/extension.ts

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import { coerce } from "semver/mod.ts";
1212
import { kProjectType, ProjectContext } from "../project/types.ts";
1313
import { isSubdir } from "fs/_util.ts";
1414

15-
import { dirname, join, normalize, relative } from "path/mod.ts";
15+
import { dirname, isAbsolute, join, normalize, relative } from "path/mod.ts";
1616
import { Metadata, QuartoFilter } from "../config/types.ts";
1717
import { resolvePathGlobs } from "../core/path.ts";
1818
import { toInputRelativePaths } from "../project/project-shared.ts";
@@ -316,7 +316,7 @@ export function discoverExtensionPath(
316316
}`,
317317
);
318318
}
319-
return paths.include[0];
319+
return relative(Deno.cwd(), paths.include[0]);
320320
} else {
321321
return undefined;
322322
}
@@ -386,7 +386,10 @@ function readExtension(
386386

387387
// The directory containing this extension
388388
// Paths used should be considered relative to this dir
389-
const extensionDir = dirname(extensionFile);
389+
const extensionDirRaw = dirname(extensionFile);
390+
const extensionDir = isAbsolute(extensionDirRaw)
391+
? extensionDirRaw
392+
: join(Deno.cwd(), extensionDirRaw);
390393

391394
// The formats that are being contributed
392395
const formats = contributes?.formats as Metadata ||
@@ -436,7 +439,7 @@ function readExtension(
436439
id: extensionId,
437440
path: extensionDir,
438441
contributes: {
439-
shortcodes: shortcodes.map((code) => join(extensionDir, code)),
442+
shortcodes,
440443
filters,
441444
formats,
442445
},
@@ -464,7 +467,7 @@ function resolveShortcode(
464467
const shortcodes: string[] = [];
465468
for (const shortcode of extensions[0].contributes.shortcodes || []) {
466469
// Shortcodes are expected to be extension relative paths
467-
shortcodes.push(relative(dir, shortcode));
470+
shortcodes.push(relative(dir, join(extensions[0].path, shortcode)));
468471
}
469472
return shortcodes;
470473
} else {
@@ -493,7 +496,15 @@ function resolveFilter(
493496
if (extensions.length > 0) {
494497
const filters: QuartoFilter[] = [];
495498
for (const filter of extensions[0].contributes.filters || []) {
496-
filters.push(filter);
499+
// Filters are expected to be extension relative paths
500+
if (typeof (filter) === "string") {
501+
filters.push(relative(dir, join(extensions[0].path, filter)));
502+
} else {
503+
filters.push({
504+
type: filter.type,
505+
path: relative(dir, join(extensions[0].path, filter.path)),
506+
});
507+
}
497508
}
498509
return filters;
499510
} else {
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
title: Font Awesome support
2+
author: Carlos Scheidegger
3+
version: 0.0.1
4+
contributes:
5+
shortcodes:
6+
- fontawesome.lua

0 commit comments

Comments
 (0)