mirror of
https://github.com/jackyzha0/quartz
synced 2026-11-30 22:44:41 +01:00
Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
28fcb64720 |
No files matched your search
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"@jackyzha0/quartz": patch
|
||||
---
|
||||
|
||||
When a build stops on an error, Quartz stops esbuild before exiting. esbuild runs as a child process that writes to the same terminal; left running, it could print "fatal error: all goroutines are asleep - deadlock!" and a long goroutine dump after Quartz's error message.
|
||||
@@ -1,5 +0,0 @@
|
||||
---
|
||||
"@jackyzha0/quartz": patch
|
||||
---
|
||||
|
||||
Embedding a section by the anchor Obsidian writes for its heading works when that anchor differs from the heading's id: `![[note#Colon unspaced]]` now embeds `## Colon:unspaced`. It needs GitHubFlavoredMarkdown 2.1.0 or later, which marks those anchors on the heading.
|
||||
@@ -428,6 +428,8 @@ export async function handleBuild(argv) {
|
||||
`${styleText("red", "Failed to build Quartz.")} Check for syntax errors in your configuration or plugins.`,
|
||||
)
|
||||
console.log(`Reason: ${styleText("gray", err.message ?? String(err))}`)
|
||||
// stop esbuild's child process first: it shares our stderr and outlives us otherwise
|
||||
void esbuild.stop()
|
||||
process.exit(1)
|
||||
})
|
||||
release()
|
||||
|
||||
@@ -183,46 +183,6 @@ describe("renderTranscludes", () => {
|
||||
assert.ok(!secondText.includes("Circular transclusion"), "should not show circular warning")
|
||||
})
|
||||
|
||||
test("a header transclusion matches a heading's Obsidian-anchor alias", () => {
|
||||
const root: Root = {
|
||||
type: "root",
|
||||
children: [makeTranscludeBlockquote("target", "#colon-unspaced")],
|
||||
}
|
||||
const targetHtml: Root = {
|
||||
type: "root",
|
||||
children: [
|
||||
{
|
||||
type: "element",
|
||||
tagName: "h2",
|
||||
properties: { id: "colonunspaced" },
|
||||
children: [
|
||||
{
|
||||
type: "element",
|
||||
tagName: "span",
|
||||
properties: { id: "colon-unspaced", className: ["heading-alias"] },
|
||||
children: [],
|
||||
},
|
||||
{ type: "text", value: "Colon:unspaced" },
|
||||
],
|
||||
},
|
||||
{
|
||||
type: "element",
|
||||
tagName: "p",
|
||||
properties: {},
|
||||
children: [{ type: "text", value: "Section text" }],
|
||||
},
|
||||
],
|
||||
}
|
||||
renderTranscludes(
|
||||
root,
|
||||
cfg,
|
||||
"current" as FullSlug,
|
||||
makeComponentData([makePageData("target", targetHtml)]) as QuartzComponentProps,
|
||||
new Set<FullSlug>(["current" as FullSlug]),
|
||||
)
|
||||
assert.ok(JSON.stringify((root.children[0] as Element).children).includes("Section text"))
|
||||
})
|
||||
|
||||
test("detects actual circular transclusion (A -> B -> A)", () => {
|
||||
// Page A embeds B, and B's htmlAst contains a transclusion of A
|
||||
const bTranscludesA = makeTranscludeBlockquote("pageA")
|
||||
|
||||
@@ -31,25 +31,6 @@ interface RenderComponents {
|
||||
}
|
||||
|
||||
const headerRegex = new RegExp(/h[1-6]/)
|
||||
|
||||
/**
|
||||
* Whether a heading answers to `id`: its own id, or the id of a `span.heading-alias` inside it.
|
||||
* GitHubFlavoredMarkdown adds that alias when the anchor Obsidian writes for a heading (`:`, `|`,
|
||||
* `^`, `#` and `\` become spaces) slugs differently, e.g. `![[note#Colon unspaced]]` for
|
||||
* `## Colon:unspaced`.
|
||||
*/
|
||||
function headingHasId(heading: Element, id: string): boolean {
|
||||
if (heading.properties?.id === id) return true
|
||||
const hasAlias = (el: Element): boolean =>
|
||||
el.children.some(
|
||||
(child) =>
|
||||
child.type === "element" &&
|
||||
((child.properties?.id === id &&
|
||||
([] as unknown[]).concat(child.properties?.className ?? []).includes("heading-alias")) ||
|
||||
hasAlias(child)),
|
||||
)
|
||||
return hasAlias(heading)
|
||||
}
|
||||
export function pageResources(
|
||||
baseDir: FullSlug | RelativeURL,
|
||||
staticResources: StaticResources,
|
||||
@@ -250,7 +231,7 @@ export function renderTranscludes(
|
||||
const depth = Number(htmlEl.tagName.substring(1))
|
||||
|
||||
if (startIdx === undefined || startDepth === undefined) {
|
||||
if (headingHasId(htmlEl, blockRef)) {
|
||||
if (htmlEl.properties?.id === blockRef) {
|
||||
startIdx = i
|
||||
startDepth = depth
|
||||
}
|
||||
|
||||
+13
-1
@@ -1,5 +1,6 @@
|
||||
import { styleText } from "util"
|
||||
import process from "process"
|
||||
import esbuild from "esbuild"
|
||||
import { isMainThread } from "workerpool"
|
||||
import { isContentError, pluginErrorInfo, PluginErrorInfo } from "./pluginErrors"
|
||||
import { knownProblemsFor } from "./diagnostics"
|
||||
@@ -130,6 +131,17 @@ export function trace(msg: string, err: Error) {
|
||||
} else {
|
||||
// print and exit
|
||||
console.error(traceMsg)
|
||||
process.exit(1)
|
||||
exitBuild(1)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Exit the build process. esbuild's service is a child process that shares our stderr; exiting
|
||||
* while it has requests in flight (bundling component scripts, the CLI's build context) left it
|
||||
* running without its parent, and it printed "fatal error: all goroutines are asleep - deadlock!"
|
||||
* and a goroutine dump after Quartz's error. Stop it first.
|
||||
*/
|
||||
export function exitBuild(code: number): never {
|
||||
void esbuild.stop()
|
||||
process.exit(code)
|
||||
}
|
||||
Reference in new issue
Block a user