mirror of
https://github.com/jackyzha0/quartz
synced 2026-11-30 22:44:41 +01:00
Compare commits
14
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7453f7f0d0 | ||
|
|
9c46b01c57 | ||
|
|
842a293ab1 | ||
|
|
6f872d4302 | ||
|
|
8578f2fdb2 | ||
|
|
5b863b0752 | ||
|
|
d092a3179b | ||
|
|
dacfeba928 | ||
|
|
5fafbf37b7 | ||
|
|
2e4ef40bc0 | ||
|
|
99685cf741 | ||
|
|
b58a7f20fe | ||
|
|
f690faad9e | ||
|
|
546703340e |
No files matched your search
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"@jackyzha0/quartz": patch
|
||||
---
|
||||
|
||||
Bases inside a transcluded note render that note's own base, and links in bases follow `configuration.links` (external-link icon, new tab, lazy images, popovers) (bases-page 1.5.1).
|
||||
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"@jackyzha0/quartz": patch
|
||||
---
|
||||
|
||||
Updates `@quartz-community/obsidian-flavored-markdown` to 2.3.1, which renders callout titles in `.callout-title-inner` without a `<p>`, as in Obsidian (themes put the title below its icon otherwise). Callout titles are styled on `.callout-title-inner` itself (colour, margin, line height); the `> p` rule stays for sites on an older obsidian-flavored-markdown.
|
||||
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"@jackyzha0/quartz": patch
|
||||
---
|
||||
|
||||
Permalinks work on large sites: sites of 192 or more files are parsed in worker threads, which didn't receive the permalinks, so a note with a `permalink` was published at its file path (#2644). A permalink with `.` or `..` segments is ignored with a warning instead of writing pages outside the output folder (#2641). With `prettyLinks`, a wikilink to a note whose name has a space or a non-ASCII letter reads as the note's name without its folder, as other links do (#2643).
|
||||
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"@jackyzha0/quartz": patch
|
||||
---
|
||||
|
||||
Updates `@quartz-community/alias-redirects` to 1.0.4 (aliases that point outside the site are skipped, #2641) and `@quartz-community/note-properties` to 1.1.5 (links in properties to missing pages get the `broken` class with `disableBrokenWikilinks`, #2635).
|
||||
Generated
+12
-12
@@ -2359,9 +2359,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/@quartz-community/alias-redirects": {
|
||||
"version": "1.0.3",
|
||||
"resolved": "https://registry.npmjs.org/@quartz-community/alias-redirects/-/alias-redirects-1.0.3.tgz",
|
||||
"integrity": "sha512-kA3MiAneoHlC09uQJxF1ex1GktkUf9Rm53b0ybeJrtNEcteRoqBCELHB+pf6hUj9i/k2Epx0J8RyTSe/zwTg2A==",
|
||||
"version": "1.0.4",
|
||||
"resolved": "https://registry.npmjs.org/@quartz-community/alias-redirects/-/alias-redirects-1.0.4.tgz",
|
||||
"integrity": "sha512-DGlkfTtpG8TBI8zyibUq5XCK00gqEyG+nK8YfhNgnvIgUUKtO5Cdx5HSpI+K2a8bb0uT0zpeAUy/uwUp30EmLQ==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@quartz-community/types": "^1.0.0",
|
||||
@@ -2425,9 +2425,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/@quartz-community/bases-page": {
|
||||
"version": "1.5.0",
|
||||
"resolved": "https://registry.npmjs.org/@quartz-community/bases-page/-/bases-page-1.5.0.tgz",
|
||||
"integrity": "sha512-fesgMUzNk0/IVrBPBrqW5pzLvvfhXwL2Gxu/5Q7S/pGHqJTsDH5VXUU0f0oFsbZI3FKlOefz+RYm/Knvo1Yrbg==",
|
||||
"version": "1.5.1",
|
||||
"resolved": "https://registry.npmjs.org/@quartz-community/bases-page/-/bases-page-1.5.1.tgz",
|
||||
"integrity": "sha512-rdZZlrUM8Lj15mQf0EB8oYfFmwVH4N4Br68bI3tZLyfwwErfpJbRtc7sGHxxH+e9H+15dS8N0g+INcyNWRp9ag==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@lucide/icons": "^1.70.0",
|
||||
@@ -2897,9 +2897,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/@quartz-community/note-properties": {
|
||||
"version": "1.1.4",
|
||||
"resolved": "https://registry.npmjs.org/@quartz-community/note-properties/-/note-properties-1.1.4.tgz",
|
||||
"integrity": "sha512-MTj7D4+CzmuYzZ8UwF8T5uzFf+JHoA2NzRCniuhug4h6KVxf3IRePqn5uVupjm/0Uzz2oeB7UX8Nr0hH0SNAdg==",
|
||||
"version": "1.1.5",
|
||||
"resolved": "https://registry.npmjs.org/@quartz-community/note-properties/-/note-properties-1.1.5.tgz",
|
||||
"integrity": "sha512-C8sKIhjaD479SozfzmU/r6IMG7Jc279qPTTxpCuJthrTBW7oYcSn/iEieplhojIXbUo7GTWY23g0iL/jUfuL/g==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@quartz-community/types": "^1.0.0",
|
||||
@@ -2923,9 +2923,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/@quartz-community/obsidian-flavored-markdown": {
|
||||
"version": "2.3.0",
|
||||
"resolved": "https://registry.npmjs.org/@quartz-community/obsidian-flavored-markdown/-/obsidian-flavored-markdown-2.3.0.tgz",
|
||||
"integrity": "sha512-R4QAnmir6wZO6M8608xAE7Z+O9c8uExhSGXPY0a3W71KnmBzOblU4kzsXjU4T3KaifBAyeYjHAVC39qjBcP6iw==",
|
||||
"version": "2.3.1",
|
||||
"resolved": "https://registry.npmjs.org/@quartz-community/obsidian-flavored-markdown/-/obsidian-flavored-markdown-2.3.1.tgz",
|
||||
"integrity": "sha512-lQucQG1Cm0KrjRQJfaSf0Ud5ugpnLC8ZG5e5cTFrysu2DVkLeS6ks0c0gXXtc6iK1OyZ49Bzug4HkNKZb6AwHQ==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@quartz-community/rehype-obsidian": "^1.4.0",
|
||||
|
||||
@@ -408,6 +408,27 @@ describe("links built-in", () => {
|
||||
)
|
||||
})
|
||||
|
||||
test("pretty links shorten a link whose text is its percent-decoded href (#2643)", () => {
|
||||
const { els } = run(
|
||||
[
|
||||
a("Folder/Name%20With%20Space", "Folder/Name With Space"),
|
||||
a("Ordner/%C3%9Cbersicht", "Ordner/Übersicht"),
|
||||
a("Folder/Name%20With%20Space", "own text"),
|
||||
],
|
||||
"page",
|
||||
{ prettyLinks: true },
|
||||
)
|
||||
const links = els.filter((e) => e.tagName === "a")
|
||||
assert.deepStrictEqual(
|
||||
links.map((e) => (e.children[0] as Text).value),
|
||||
["Name With Space", "Übersicht", "own text"],
|
||||
)
|
||||
assert.deepStrictEqual(
|
||||
links.map((e) => (e.properties.className as string[]).includes("alias")),
|
||||
[false, false, true],
|
||||
)
|
||||
})
|
||||
|
||||
test("disableBrokenWikilinks adds a broken class to missing targets", () => {
|
||||
const { els } = run([a("missing")], "page", { disableBrokenWikilinks: true }, ["page"])
|
||||
assert.ok((els[0].properties.className as string[]).includes("broken"))
|
||||
|
||||
@@ -50,6 +50,14 @@ const isAbsolute = isAbsoluteUrl as (url: string, options?: { httpOnly?: boolean
|
||||
// As in Obsidian: a URL with a scheme (`x:y`, but not `../x:y`), or a link whose path is not valid
|
||||
// percent-encoding (`%zz`, `a%E2.md`), which names no file
|
||||
const isExternalUrl = (url: string) => isAbsolute(url, { httpOnly: false }) || !linkPathDecodes(url)
|
||||
// An href percent-decoded, to compare with link text; left as it is when it does not decode
|
||||
const decodedHref = (href: string) => {
|
||||
try {
|
||||
return decodeURI(href)
|
||||
} catch {
|
||||
return href
|
||||
}
|
||||
}
|
||||
|
||||
const EXTERNAL_ICON_PATH =
|
||||
"M320 0H288V64h32 82.7L201.4 265.4 178.7 288 224 333.3l22.6-22.6L448 109.3V192v32h64V192 32 0H480 320zM32 32H0V64 480v32H32 456h32V480 352 320H424v32 96H64V96h96 32V32H160 32z"
|
||||
@@ -131,12 +139,14 @@ export const Links: QuartzTransformerPlugin<LinksConfig> = (userOpts) => {
|
||||
})
|
||||
}
|
||||
|
||||
// link text differs from the href → it's an alias ("[[note|text]]")
|
||||
// link text differs from the href → it's an alias ("[[note|text]]"). The href is
|
||||
// percent-encoded by now ("a%20b" for "a b"), so it is compared decoded too (#2643)
|
||||
const firstChild = node.children[0]
|
||||
if (
|
||||
node.children.length === 1 &&
|
||||
firstChild?.type === "text" &&
|
||||
firstChild.value !== dest
|
||||
firstChild.value !== dest &&
|
||||
firstChild.value !== decodedHref(dest)
|
||||
) {
|
||||
classes.push("alias")
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@ import path from "path"
|
||||
import workerpool, { Promise as WorkerPromise } from "workerpool"
|
||||
import { QuartzLogger } from "../util/log"
|
||||
import { trace } from "../util/trace"
|
||||
import { BuildCtx, WorkerSerializableBuildCtx } from "../util/ctx"
|
||||
import { BuildCtx, workerCtx } from "../util/ctx"
|
||||
import { styleText } from "util"
|
||||
import {
|
||||
attributeError,
|
||||
@@ -206,14 +206,7 @@ export async function parseMarkdown(ctx: BuildCtx, fps: FilePath[]): Promise<Pro
|
||||
maxWorkers: concurrency,
|
||||
workerType: "thread",
|
||||
})
|
||||
const serializableCtx: WorkerSerializableBuildCtx = {
|
||||
buildId: ctx.buildId,
|
||||
argv: ctx.argv,
|
||||
allSlugs: ctx.allSlugs,
|
||||
allFiles: ctx.allFiles,
|
||||
incremental: ctx.incremental,
|
||||
virtualPages: [],
|
||||
}
|
||||
const serializableCtx = workerCtx(ctx)
|
||||
|
||||
try {
|
||||
const textToMarkdownPromises: WorkerPromise<MarkdownContent[]>[] = []
|
||||
|
||||
@@ -161,6 +161,9 @@
|
||||
--callout-icon: var(--callout-icon-fold);
|
||||
}
|
||||
|
||||
// The title's text sits in .callout-title-inner, as in Obsidian; obsidian-flavored-markdown
|
||||
// before 2.3.1 wrapped it in a <p>
|
||||
& > .callout-title-inner,
|
||||
& > .callout-title-inner > p {
|
||||
color: var(--color);
|
||||
margin: 0;
|
||||
@@ -185,5 +188,7 @@
|
||||
|
||||
.callout-title-inner {
|
||||
font-weight: $semiBoldWeight;
|
||||
// the line height the title had as a <p>
|
||||
line-height: 1.6rem;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
import { describe, test } from "node:test"
|
||||
import assert from "node:assert"
|
||||
import { BuildCtx, workerCtx } from "./ctx"
|
||||
import { FullSlug, FilePath } from "./path"
|
||||
|
||||
describe("workerCtx", () => {
|
||||
const ctx = {
|
||||
buildId: "b",
|
||||
argv: { directory: "content" },
|
||||
cfg: { configuration: {} },
|
||||
allSlugs: ["index", "elsewhere/moved"] as FullSlug[],
|
||||
allFiles: ["index.md", "Moved.md"] as FilePath[],
|
||||
permalinks: { "Moved.md": "elsewhere/moved" as FullSlug },
|
||||
incremental: false,
|
||||
virtualPages: [],
|
||||
trie: {},
|
||||
} as unknown as BuildCtx
|
||||
|
||||
test("carries permalinks to worker threads (#2644)", () => {
|
||||
assert.deepStrictEqual(workerCtx(ctx).permalinks, { "Moved.md": "elsewhere/moved" })
|
||||
})
|
||||
|
||||
test("holds plain data only, and survives structured cloning", () => {
|
||||
const worker = workerCtx(ctx)
|
||||
assert.ok(!("cfg" in worker) && !("trie" in worker))
|
||||
assert.deepStrictEqual(structuredClone(worker), worker)
|
||||
assert.deepStrictEqual(worker.virtualPages, [])
|
||||
})
|
||||
})
|
||||
@@ -86,3 +86,26 @@ export function trieFromAllFiles(allFiles: QuartzPluginData[]): FileTrieNode<Bui
|
||||
}
|
||||
|
||||
export type WorkerSerializableBuildCtx = Omit<BuildCtx, "cfg" | "trie">
|
||||
|
||||
/** The plain-data fields of {@link BuildCtx} that worker threads need, each one required. */
|
||||
type WorkerCtxFields = {
|
||||
[K in "buildId" | "argv" | "allSlugs" | "allFiles" | "permalinks" | "incremental"]-?: BuildCtx[K]
|
||||
}
|
||||
|
||||
/**
|
||||
* The build context passed to worker threads (structured-cloned): every plain-data field the
|
||||
* parse needs. Listing each field as required means a new one can't be forgotten here: worker
|
||||
* threads run for sites of 192 or more files, so a missing field (permalinks, #2644) only broke
|
||||
* large sites.
|
||||
*/
|
||||
export function workerCtx(ctx: BuildCtx): WorkerSerializableBuildCtx {
|
||||
const fields: WorkerCtxFields = {
|
||||
buildId: ctx.buildId,
|
||||
argv: ctx.argv,
|
||||
allSlugs: ctx.allSlugs,
|
||||
allFiles: ctx.allFiles,
|
||||
permalinks: ctx.permalinks ?? {},
|
||||
incremental: ctx.incremental,
|
||||
}
|
||||
return { ...fields, virtualPages: [] }
|
||||
}
|
||||
@@ -19,6 +19,25 @@ describe("permalinks (Obsidian Publish semantics)", () => {
|
||||
assert.strictEqual(normalizePermalink(2024), "2024")
|
||||
})
|
||||
|
||||
test("collectPermalinks ignores permalinks with a . or .. segment", () => {
|
||||
const fm: Record<string, unknown> = {
|
||||
"a.md": "../escaped",
|
||||
"b.md": "x/../../escaped",
|
||||
"c.md": "./c",
|
||||
"d.md": "/../../d/",
|
||||
"e.md": "..\\..\\e",
|
||||
"f.md": "fine..name/ok",
|
||||
}
|
||||
const warnings: string[] = []
|
||||
const permalinks = collectPermalinks({
|
||||
files: Object.keys(fm),
|
||||
permalinkOf: (f) => fm[f],
|
||||
warn: (m) => warnings.push(m),
|
||||
})
|
||||
assert.deepStrictEqual(permalinks, { "f.md": "fine..name/ok" })
|
||||
assert.strictEqual(warnings.length, 5)
|
||||
})
|
||||
|
||||
test("collectPermalinks maps files to their permalink; the address can't be taken twice", () => {
|
||||
const fm: Record<string, unknown> = {
|
||||
"folder/note.md": "page",
|
||||
|
||||
@@ -46,6 +46,11 @@ export function collectPermalinks({
|
||||
for (const file of files) {
|
||||
const slug = normalizePermalink(permalinkOf(file))
|
||||
if (!slug) continue
|
||||
if (slug.split("/").some((segment) => segment === "." || segment === "..")) {
|
||||
// a "." or ".." segment would be written outside the output directory (../x.html)
|
||||
warn(`${file}: permalink "${slug}" contains a "." or ".." segment and is ignored.`)
|
||||
continue
|
||||
}
|
||||
const own = slugifyFilePath(file as FilePath)
|
||||
if (slug === own) continue // the note's own path: nothing to do
|
||||
const owner = pathSlugs.get(slug) ?? taken.get(slug)
|
||||
|
||||
Reference in new issue
Block a user