@quartz-community/obsidian-flavored-markdown 1.0.0 → 2.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,55 @@
1
1
  # Changelog
2
2
 
3
+ ## 2.1.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 8575260: Highlights render as in Obsidian: `==text==` becomes `<mark class="text-highlight">` and keeps what's inside it. Formatting in a highlight no longer deletes text (`==**bold** and *italic*==` rendered only " and "), and links and tags in a highlight work. Coloured highlights (Obsidian 1.14) now work too: a highlight that starts with a colour emoji (🔴 🟠 🟡 🟢 🔵 🟣, or the matching squares) is coloured and the emoji removed, e.g. `==🔴 urgent==`.
8
+
9
+ ## 2.0.0
10
+
11
+ ### Major Changes
12
+
13
+ - 8ef556e: Parse with remark-obsidian 2.1 and render with rehype-obsidian 1.2: Markdown now renders as it does in Obsidian (remark-obsidian's `legacy` preset parses with Obsidian's own parser).
14
+
15
+ - New `preset` option: `"legacy"` (default) parses exactly as Obsidian. It replaces the Markdown parser, so other plugins' syntax extensions are not consulted and only YAML frontmatter is recognized. `"strict"` parses CommonMark/GFM as specified plus Obsidian's syntax, and keeps other plugins' syntax extensions — use it for TOML (`+++`) frontmatter or plugins that add Markdown syntax.
16
+ - Callouts are parsed by remark-obsidian (closer to Obsidian: titles, nesting, empty titles), rendered with the same markup as before. Callout syntax inside code blocks is no longer altered (a stray `> ` line used to be added).
17
+ - Inline footnotes (`text^[note]`) are rendered as numbered footnotes; an undefined footnote reference shows its bare label, as in Obsidian.
18
+ - **Line breaks now follow Obsidian:** a single line break inside a paragraph renders as `<br>`, as in Obsidian's default reading view. This changes how existing sites render. The new `strictLineBreaks` option mirrors Obsidian's "Strict line breaks" setting: set it to `true` for the previous behaviour (a space). It defaults to `true` under `preset: "strict"`. This replaces the HardLineBreaks plugin, which is deprecated.
19
+ - Math follows Obsidian's rules, e.g. `I have $1 and you have $2` stays text.
20
+
21
+ - 552a54c: Run after `github-flavored-markdown` (`defaultOrder` 30 → 40)
22
+
23
+ A combined micromark extension prepends its constructs, so where two plugins claim
24
+ the same character the **later-registered** one wins. Ordered before
25
+ `github-flavored-markdown`, this plugin lost every shared character to GFM — `~`
26
+ most visibly — so Obsidian's own tokenizers never ran.
27
+
28
+ Obsidian's strikethrough is not GFM's: it closes on the first `~~` it reaches,
29
+ honours no escape, and has no single-tilde form. Reproducing that needs this plugin
30
+ to register last.
31
+
32
+ Measured on `remark-obsidian`'s recorded Obsidian corpus: the reorder on its own is
33
+ behaviour-neutral (0 cases fixed, 0 broken, which also clears the one real risk —
34
+ both plugins claim `[`, GFM's footnote against this plugin's wikilink), and it lets
35
+ 21 strikethrough cases match with no regression.
36
+
37
+ Rendered output changes for notes using `~~`, hence the major bump.
38
+
39
+ ### Minor Changes
40
+
41
+ - 4c8c26b: Markdown images read Obsidian's size suffix: `![alt|300](image.png)` and `![alt|100x145](image.png)` set the width (and height) instead of keeping `|300` in the alt text. SVG embeds now escape their alt text and URL in the generated `<object>`.
42
+ - 8ef556e: New `diagramRenderer: "pele"` option draws Mermaid fences with [Pele](https://pele.run) (default stays `"mermaid"`; Mermaid.js is deprecated). Pele is only downloaded on pages with a Mermaid fence: on Quartz 5.1+ it is self-hosted as a plugin asset and fetches only the chunks for the diagram types on the page; older Quartz versions load it from jsDelivr. Contributed by @aarnphm (#14).
43
+
44
+ Also fixed for both renderers: reopening the expanded diagram no longer stacks pan/zoom toolbars, diagrams aren't wired up twice when `nav` and `render` both fire, and the expand button is visible when focused with the keyboard.
45
+
46
+ ### Patch Changes
47
+
48
+ - 7c7b8d2: Inline `#tags` only link to a tag page that exists: when the tag-page plugin is disabled, a tag without a hand-written `tags/<tag>` page renders as `<span class="tag-link">`, styled like the link, instead of a link to a missing page.
49
+ - 0d4b377: Mermaid diagrams no longer crash when the syntax-highlighting plugin (clipboard button) is disabled; control lookups are null-guarded.
50
+ - 0a35a3c: Mermaid diagrams render with themes whose colour variables use `hsl(calc(...))`, `var(...)` or other colour spaces: theme colours are resolved to concrete colours before they are passed to Mermaid (jackyzha0/quartz#2595).
51
+ - 4c4d8a4: Embedded SVGs (`![[file.svg]]`) no longer overflow the page: wide SVGs are capped to the article width and keep their aspect ratio; small SVGs and explicit sizes are unchanged (jackyzha0/quartz#2452).
52
+
3
53
  ## 1.0.0
4
54
 
5
55
  ### Major Changes
package/README.md CHANGED
@@ -1,6 +1,10 @@
1
1
  # @quartz-community/obsidian-flavored-markdown
2
2
 
3
- Transforms Obsidian-specific markdown syntax including wikilinks, callouts, highlights, mermaid diagrams, tags, and media embeds.
3
+ Transforms Obsidian-specific markdown syntax including wikilinks, callouts, highlights, Mermaid diagrams, tags, and media embeds.
4
+
5
+ Mermaid fences use Mermaid.js by default. Set `diagramRenderer: pele` to use [Pele](https://pele.run) instead. Mermaid.js is deprecated and will move to Pele later.
6
+
7
+ Both renderers are only loaded on pages with a Mermaid fence. On Quartz 5.1+ Pele is self-hosted (shipped as a plugin asset to `static/plugins/obsidian-flavored-markdown/pele/`) and fetches only the code for the diagram types on the page; on older Quartz versions it is loaded from jsDelivr, as Mermaid.js always is.
4
8
 
5
9
  ## Installation
6
10
 
@@ -17,6 +21,7 @@ plugins:
17
21
  options:
18
22
  enableInHtmlEmbed: false
19
23
  enableCheckbox: true
24
+ # diagramRenderer: pele
20
25
  ```
21
26
 
22
27
  For advanced use cases, you can override in TypeScript:
@@ -27,24 +32,28 @@ import * as ExternalPlugin from "./.quartz/plugins";
27
32
  ExternalPlugin.ObsidianFlavoredMarkdown({
28
33
  enableInHtmlEmbed: false,
29
34
  enableCheckbox: true,
35
+ diagramRenderer: "pele",
30
36
  });
31
37
  ```
32
38
 
33
39
  ## Configuration
34
40
 
35
- | Option | Type | Default | Description |
36
- | ---------------------- | --------- | ------- | ------------------------------------------- |
37
- | `comments` | `boolean` | `true` | Whether to parse Obsidian-style comments. |
38
- | `highlight` | `boolean` | `true` | Whether to parse Obsidian-style highlights. |
39
- | `wikilinks` | `boolean` | `true` | Whether to parse wikilinks. |
40
- | `callouts` | `boolean` | `true` | Whether to parse callouts. |
41
- | `mermaid` | `boolean` | `true` | Whether to parse Mermaid diagrams. |
42
- | `parseTags` | `boolean` | `true` | Whether to parse tags. |
43
- | `parseBlockReferences` | `boolean` | `true` | Whether to parse block references. |
44
- | `enableInHtmlEmbed` | `boolean` | `false` | Whether to enable parsing in HTML embeds. |
45
- | `enableYouTubeEmbed` | `boolean` | `true` | Whether to enable YouTube embeds. |
46
- | `enableVideoEmbed` | `boolean` | `true` | Whether to enable video embeds. |
47
- | `enableCheckbox` | `boolean` | `false` | Whether to enable checkboxes. |
41
+ | Option | Type | Default | Description |
42
+ | ---------------------- | ------------------------ | ----------- | ---------------------------------------------------------------------------------------------------------------------------------------------------- |
43
+ | `preset` | `"legacy"` \| `"strict"` | `"legacy"` | `legacy`: parse exactly as Obsidian. `strict`: CommonMark/GFM + Obsidian syntax, keeps other plugins' syntax extensions (TOML frontmatter). |
44
+ | `strictLineBreaks` | `boolean` | by preset | Obsidian's "Strict line breaks": `false` (default under `legacy`) renders a single line break as `<br>`; `true` (default under `strict`) as a space. |
45
+ | `comments` | `boolean` | `true` | Whether to parse Obsidian-style comments. |
46
+ | `highlight` | `boolean` | `true` | Whether to parse Obsidian-style highlights. |
47
+ | `wikilinks` | `boolean` | `true` | Whether to parse wikilinks. |
48
+ | `callouts` | `boolean` | `true` | Whether to parse callouts. |
49
+ | `mermaid` | `boolean` | `true` | Whether to parse Mermaid diagram fences. |
50
+ | `diagramRenderer` | `"mermaid"` \| `"pele"` | `"mermaid"` | Renderer for Mermaid fences. Default Mermaid.js; Pele is opt-in (Mermaid.js deprecated). |
51
+ | `parseTags` | `boolean` | `true` | Whether to parse tags. |
52
+ | `parseBlockReferences` | `boolean` | `true` | Whether to parse block references. |
53
+ | `enableInHtmlEmbed` | `boolean` | `false` | Whether to enable parsing in HTML embeds. |
54
+ | `enableYouTubeEmbed` | `boolean` | `true` | Whether to enable YouTube embeds. |
55
+ | `enableVideoEmbed` | `boolean` | `true` | Whether to enable video embeds. |
56
+ | `enableCheckbox` | `boolean` | `false` | Whether to enable checkboxes. |
48
57
 
49
58
  ## Documentation
50
59
 
package/dist/index.d.ts CHANGED
@@ -1,12 +1,28 @@
1
1
  import { QuartzTransformerPlugin } from '@quartz-community/types';
2
2
  export { QuartzTransformerPlugin } from '@quartz-community/types';
3
3
 
4
+ type DiagramRenderer = "mermaid" | "pele";
4
5
  interface ObsidianFlavoredMarkdownOptions {
6
+ /**
7
+ * How remark-obsidian parses Markdown. `legacy` (default) parses as Obsidian does (its
8
+ * remark-parse 8 fork), so pages render as in the app; it replaces the Markdown parser, so
9
+ * syntax extensions of other plugins are not consulted. `strict` parses CommonMark/GFM as
10
+ * specified (micromark) plus Obsidian's syntax, and keeps other plugins' syntax extensions —
11
+ * use it for TOML (`+++`) frontmatter or plugins that add Markdown syntax.
12
+ */
13
+ preset: "legacy" | "strict";
14
+ /**
15
+ * Obsidian's "Strict line breaks" setting: when `true`, a single line break inside a paragraph
16
+ * is a space (CommonMark); when `false`, it is a `<br>`, as in Obsidian's default reading view.
17
+ * Defaults to `false` under `preset: "legacy"` and `true` under `"strict"`.
18
+ */
19
+ strictLineBreaks?: boolean;
5
20
  comments: boolean;
6
21
  highlight: boolean;
7
22
  wikilinks: boolean;
8
23
  callouts: boolean;
9
24
  mermaid: boolean;
25
+ diagramRenderer: DiagramRenderer;
10
26
  parseTags: boolean;
11
27
  parseBlockReferences: boolean;
12
28
  enableInHtmlEmbed: boolean;