feat: quartz.deprecated plugin marker (warned at build, add, doctor); drop deprecated hard-line-breaks from default config and templates

This commit is contained in:
saberzero1 committed 2026-11-07 20:57:30 +01:00
1 parent 67ae68e9a4
commit 3c18be8c71
15 files changed
+54 -17

No files matched your search

+5
View File
@@ -0,0 +1,5 @@
---
"@jackyzha0/quartz": minor
---
Plugins can be marked deprecated with `quartz.deprecated` (a message naming the replacement) in their `package.json`. Quartz warns while a deprecated plugin is enabled — when the build loads the config (repeated in the end-of-build summary), in `plugin add` and in `plugin doctor` — and suggests removing it. The deprecated `hard-line-breaks` plugin is no longer listed in the default config and templates: ObsidianFlavoredMarkdown 2.0+ handles line breaks (`strictLineBreaks`).
+1
View File
@@ -46,6 +46,7 @@ and says whether to update Quartz (`npx quartz upgrade`) or the plugin. If an in
- Prefer a lower bound (`>=5.1.0`) over a caret range: minor Quartz releases don't break plugins, so `^5` would only add an upper bound you'd have to bump at every major release. Add an upper bound when you know a major version breaks you.
- Raising `quartzVersion` is a breaking change for users on older Quartz versions: release it as a new major (or at least minor) version of your plugin and say so in its changelog.
- Pre-releases count: Quartz `5.2.0-beta.1` satisfies `>=5.1.0`.
- To retire a plugin, set `quartz.deprecated` in its `package.json` to a message saying what replaces it (for example `"Line breaks are handled by ObsidianFlavoredMarkdown 2.0+ …"`). Quartz 5.1+ warns when the plugin is enabled (in the build summary, `plugin add` and `plugin doctor`) and suggests removing it; the plugin keeps working.
## Contributing: changesets
+4 -1
View File
@@ -9,7 +9,10 @@ enabled: false
required: false
---
This plugin automatically converts single line breaks in Markdown text into hard line breaks in the HTML output. This plugin is not enabled by default as this doesn't follow the semantics of actual Markdown but you may enable it if you'd like parity with [[Obsidian compatibility|Obsidian]].
> [!warning] Deprecated
> Line breaks are handled by [[ObsidianFlavoredMarkdown]] 2.0+: a single line break renders as a `<br>` by default (`preset: "legacy"`), as in Obsidian. Set its `strictLineBreaks` option to `true` to render it as a space instead. Remove this plugin (`npx quartz plugin remove hard-line-breaks`) unless your site doesn't use ObsidianFlavoredMarkdown; Quartz warns while it is enabled.
This plugin converts single line breaks in Markdown text into hard line breaks in the HTML output.
> [!note]
> For information on how to add, remove or configure plugins, see the [[configuration#Plugins|Configuration]] page.
+2 -1
View File
@@ -19,6 +19,7 @@ This plugin accepts the following configuration options:
- `preset`: How Markdown is parsed (via [remark-obsidian](https://github.com/quartz-community/remark-obsidian)).
- `"legacy"` (default) parses exactly as Obsidian does, so pages render as they do in the app. It replaces Quartz's Markdown parser, so syntax extensions added by other plugins are not consulted, and only YAML (`---`) [[Frontmatter|frontmatter]] is recognized.
- `"strict"` parses CommonMark and GFM as specified, plus Obsidian's syntax, and keeps other plugins' syntax extensions working. Use it for TOML (`+++`) or custom frontmatter delimiters, or plugins that add Markdown syntax.
- `strictLineBreaks`: Obsidian's "Strict line breaks" setting. `false` (the default under `preset: "legacy"`) renders a single line break inside a paragraph as a `<br>`, as in Obsidian's default reading view. `true` (the default under `preset: "strict"`) renders it as a space, as CommonMark does. This replaces the deprecated [[HardLineBreaks]] plugin.
- `comments`: If `true` (default), enables parsing of `%%` style Obsidian comment blocks.
- `highlight`: If `true` (default), enables parsing of `==` style highlights within content.
- `wikilinks`:If `true` (default), turns [[wikilinks]] into regular links.
@@ -34,7 +35,7 @@ This plugin accepts the following configuration options:
- `enableCheckbox`: If `true`, adds support for interactive checkboxes in content, including custom task characters (e.g. `- [?]`, `- [!]`, `- [/]`). Defaults to `false`.
- `enableObsidianUri`: If `true` (default), marks `obsidian://` protocol links with a CSS class and data attribute for custom styling.
Line breaks follow your settings: a single line break inside a paragraph becomes a `<br>` only when [[HardLineBreaks]] is enabled (Obsidian's default reading view shows them; "Strict line breaks" in Obsidian corresponds to leaving HardLineBreaks off). Inline footnotes (`text^[note]`) are numbered together with regular footnotes.
Inline footnotes (`text^[note]`) are numbered together with regular footnotes.
> [!note]
> The `disableBrokenWikilinks` option previously lived on this plugin. It has moved to the built-in [[CrawlLinks|link processing]] (`configuration.links.disableBrokenWikilinks`), which owns link resolution and can honor the configured `markdownLinkResolution` strategy when deciding whether a link is broken. Users upgrading from earlier Quartz v5 betas should move the option from `ObsidianFlavoredMarkdown` to `CrawlLinks`.
-3
View File
@@ -89,9 +89,6 @@ plugins:
- source: "@quartz-community/citations"
enabled: false
order: 85
- source: "@quartz-community/hard-line-breaks"
enabled: false
order: 90
- source: "@quartz-community/ox-hugo"
enabled: false
order: 91
+4
View File
@@ -25,6 +25,10 @@ export function describeRequirementProblem(
result: RequirementResult,
pluginVersion?: string,
): { message: string; hint: string } | undefined
export function describeDeprecation(
pluginName: string,
deprecated: unknown,
): { message: string; hint: string } | undefined
export function describeQuartzCheckout(root?: string): QuartzCheckout
export function formatQuartzVersion(version: string | undefined, checkout?: QuartzCheckout): string
export function incompatiblePluginsFailBuild(env?: Record<string, string | undefined>): boolean
+12
View File
@@ -88,6 +88,18 @@ export function isCI(env = process.env) {
return ci !== undefined && ci !== "" && ci !== "0" && ci.toLowerCase() !== "false"
}
/**
* A plugin's `quartz.deprecated` message (a string, ideally naming its replacement) as a warning
* with a fix; undefined when the plugin isn't deprecated.
*/
export function describeDeprecation(pluginName, deprecated) {
if (typeof deprecated !== "string" || deprecated.trim() === "") return undefined
return {
message: `${pluginName} is deprecated: ${deprecated.trim()}`,
hint: `Remove it when you have switched: npx quartz plugin remove ${pluginName}`,
}
}
function git(root, args) {
try {
return execFileSync("git", args, {
+12
View File
@@ -2,6 +2,7 @@ import test, { describe } from "node:test"
import assert from "node:assert"
import {
checkQuartzRequirement,
describeDeprecation,
describeRequirementProblem,
formatQuartzVersion,
brokenPluginsFailBuild,
@@ -80,6 +81,17 @@ describe("incompatiblePluginsFailBuild", () => {
})
})
describe("describeDeprecation", () => {
test("turns quartz.deprecated into a warning with a fix", () => {
const d = describeDeprecation("hard-line-breaks", " Use OFM's strictLineBreaks. ")
assert.strictEqual(d.message, "hard-line-breaks is deprecated: Use OFM's strictLineBreaks.")
assert.match(d.hint, /npx quartz plugin remove hard-line-breaks/)
assert.strictEqual(describeDeprecation("x", undefined), undefined)
assert.strictEqual(describeDeprecation("x", ""), undefined)
assert.strictEqual(describeDeprecation("x", true), undefined)
})
})
describe("version display", () => {
test("readQuartzVersion reads this checkout's package.json", () => {
assert.match(readQuartzVersion() ?? "", /^\d+\.\d+\.\d+/)
+8
View File
@@ -37,6 +37,7 @@ import {
import {
checkQuartzRequirement,
describeQuartzCheckout,
describeDeprecation,
describeRequirementProblem,
formatQuartzVersion,
readQuartzVersion,
@@ -1795,6 +1796,11 @@ export async function handlePluginAdd(
console.log(styleText("yellow", ` ⚠ ${requirement.message}`))
console.log(styleText("gray", ` ${requirement.hint}`))
}
const deprecation = describeDeprecation(configName, manifest?.deprecated)
if (deprecation) {
console.log(styleText("yellow", ` ⚠ ${deprecation.message}`))
console.log(styleText("gray", ` ${deprecation.hint}`))
}
if (plugin.buildFailed) {
console.log(
styleText(
@@ -2698,6 +2704,8 @@ export async function handlePluginDoctor({ verbose = false, fix = false } = {})
if (requirement) {
report(enabled ? "error" : "info", null, requirement.message, requirement.hint)
}
const deprecation = describeDeprecation(label, manifest.deprecated)
if (deprecation) report("warning", null, deprecation.message, deprecation.hint)
if (enabled) {
for (const dep of manifest.dependencies ?? []) {
const depEntry =
-3
View File
@@ -91,9 +91,6 @@ plugins:
- source: "@quartz-community/citations"
enabled: false
order: 85
- source: "@quartz-community/hard-line-breaks"
enabled: false
order: 90
- source: "@quartz-community/ox-hugo"
enabled: false
order: 91
-3
View File
@@ -91,9 +91,6 @@ plugins:
- source: "@quartz-community/citations"
enabled: false
order: 85
- source: "@quartz-community/hard-line-breaks"
enabled: false
order: 90
- source: "@quartz-community/ox-hugo"
enabled: false
order: 91
-3
View File
@@ -102,9 +102,6 @@ plugins:
- source: "@quartz-community/citations"
enabled: false
order: 85
- source: "@quartz-community/hard-line-breaks"
enabled: true
order: 90
- source: "@quartz-community/ox-hugo"
enabled: false
order: 91
-3
View File
@@ -102,9 +102,6 @@ plugins:
- source: "@quartz-community/citations"
enabled: false
order: 85
- source: "@quartz-community/hard-line-breaks"
enabled: true
order: 90
- source: "@quartz-community/ox-hugo"
enabled: false
order: 91
+4
View File
@@ -39,6 +39,7 @@ import { registerPluginOrigin, reportError, warn } from "../../util/diagnostics"
import { firstPluginFrame } from "../../util/trace"
import {
checkQuartzRequirement,
describeDeprecation,
describeRequirementProblem,
incompatiblePluginsFailBuild,
brokenPluginsFailBuild,
@@ -270,6 +271,7 @@ async function readManifestFromPackageJson(source: PluginSource): Promise<Plugin
issues: issuesUrl(pkg),
category: q.category,
quartzVersion: q.quartzVersion,
deprecated: q.deprecated,
dependencies: q.dependencies,
capabilities: q.capabilities,
defaultOrder: q.defaultOrder,
@@ -398,6 +400,8 @@ export async function loadQuartzConfig(
const problem = describeRequirementProblem(name, requirement, manifest.version)
if (problem) warn({ area: "versions", plugin: name, ...problem })
if (requirement.status === "incompatible") incompatible.push(name)
const deprecation = describeDeprecation(name, manifest.deprecated)
if (deprecation) warn({ area: "plugins", plugin: name, ...deprecation })
}
// The quiet install-plugins prebuild pass doesn't print, so the real build reports the failure.
if (
+2
View File
@@ -54,6 +54,8 @@ export interface PluginManifest {
keywords?: string[]
category?: PluginCategory | PluginCategory[]
quartzVersion?: string
/** Set when the plugin is deprecated: why, and what replaces it (warned about at build time). */
deprecated?: string
/** Plugin sources this plugin depends on (e.g., "@quartz-community/crawl-links") */
dependencies?: string[]
/** Default numeric execution order (0-100 convention, lower = runs first). Defaults to 50. */