From fa70cf46121846f37f8cc6a91ebba979c2517647 Mon Sep 17 00:00:00 2001 From: mashehu Date: Tue, 14 Jan 2025 12:45:04 +0100 Subject: [PATCH 1/7] update to astro 5 and astro-remark 6 --- demo/package.json | 4 ++-- package.json | 2 +- packages/md/package.json | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/demo/package.json b/demo/package.json index bf0fd2c..79ad05e 100644 --- a/demo/package.json +++ b/demo/package.json @@ -9,7 +9,7 @@ "astro": "astro" }, "devDependencies": { - "@astropub/md": "0.4.0", - "astro": "4" + "@astropub/md": "0.6.0", + "astro": "5" } } diff --git a/package.json b/package.json index d2460e7..94b4d45 100644 --- a/package.json +++ b/package.json @@ -25,7 +25,7 @@ "startCommand": "npm start" }, "devDependencies": { - "astro": "4", + "astro": "5", "types-object": "latest" } } diff --git a/packages/md/package.json b/packages/md/package.json index a446033..56b462b 100644 --- a/packages/md/package.json +++ b/packages/md/package.json @@ -2,7 +2,7 @@ "$schema": "https://json.schemastore.org/package.json", "name": "@astropub/md", "description": "Render any Markdown content in Astro", - "version": "0.5.0", + "version": "0.6.0", "type": "module", "license": "CC0-1.0", "exports": { @@ -25,7 +25,7 @@ "./package.json": "./package.json" }, "peerDependencies": { - "@astrojs/markdown-remark": "^5" + "@astrojs/markdown-remark": "^6" }, "main": "astro-md.js", "types": "astro-md.d.ts", From 92283253ae586a20b33f9a90e8f55bc145dee5ea Mon Sep 17 00:00:00 2001 From: mashehu Date: Wed, 14 Jan 2026 14:33:27 +0100 Subject: [PATCH 2/7] publish own fork --- README.md | 3 +++ packages/md/README.md | 3 +++ packages/md/package.json | 17 ++++++++++++----- 3 files changed, 18 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 7304d51..fd33b6e 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,6 @@ +> [!IMPORTANT] +> This is an updated fork of [@astropub/md](https://github.com/astro-community/md). All the hard work was done by the original authors. + # Astro Markdown **Astro Markdown** lets you render any Markdown content in **[Astro](https://astro.build)**, optionally integrating with any existing configuration. diff --git a/packages/md/README.md b/packages/md/README.md index c44349f..08cbfae 100644 --- a/packages/md/README.md +++ b/packages/md/README.md @@ -1,3 +1,6 @@ +> [!IMPORTANT] +> This is an updated fork of [@astropub/md](https://github.com/astro-community/md). All the hard work was done by the original authors. + # Astro Markdown **Astro Markdown** lets you render any Markdown content in **[Astro](https://astro.build)**, optionally integrating with any existing configuration. diff --git a/packages/md/package.json b/packages/md/package.json index 5b5c77f..5a5fe77 100644 --- a/packages/md/package.json +++ b/packages/md/package.json @@ -1,7 +1,7 @@ { "$schema": "https://json.schemastore.org/package.json", - "name": "@astropub/md", - "description": "Render any Markdown content in Astro", + "name": "@mashehu/astropub-md", + "description": "Render any Markdown content in Astro. Forked from @astropub/md", "version": "1.0.0", "type": "module", "license": "CC0-1.0", @@ -55,7 +55,14 @@ "remark" ], "author": "Jonathan Neal ", - "bugs": "https://github.com/astro-community/md/issues", - "homepage": "https://github.com/astro-community/md", - "repository": "https://github.com/astro-community/md.git" + "contributors": [ + "mashehu" + ], + "bugs": "https://github.com/mashehu/astropub-md/issues", + "homepage": "https://github.com/mashehu/astropub-md", + "repository": { + "type": "git", + "url": "git+https://github.com/mashehu/astropub-md.git", + "directory": "packages/md" + } } From 88f231b38482cd691ce0387bd5def4e067644e38 Mon Sep 17 00:00:00 2001 From: mashehu Date: Wed, 14 Jan 2026 14:36:28 +0100 Subject: [PATCH 3/7] bump to 1.0.1 to publish updated readme --- package.json | 2 +- packages/md/package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 94b4d45..009f751 100644 --- a/package.json +++ b/package.json @@ -13,7 +13,7 @@ "start": "cd demo; astro dev", "build": "cd demo; astro build", "serve": "cd demo; astro preview", - "release": "npm --workspaces publish --access public" + "release": "npm --workspaces packages/md --access public" }, "prettier": { "semi": false, diff --git a/packages/md/package.json b/packages/md/package.json index 5a5fe77..fc355f0 100644 --- a/packages/md/package.json +++ b/packages/md/package.json @@ -2,7 +2,7 @@ "$schema": "https://json.schemastore.org/package.json", "name": "@mashehu/astropub-md", "description": "Render any Markdown content in Astro. Forked from @astropub/md", - "version": "1.0.0", + "version": "1.0.1", "type": "module", "license": "CC0-1.0", "exports": { From f5637f97b3d4d293a3293a30f412ca138f8da5cd Mon Sep 17 00:00:00 2001 From: mashehu Date: Mon, 23 Mar 2026 11:58:22 +0100 Subject: [PATCH 4/7] Support astro 6 --- demo/package.json | 5 +++-- package.json | 5 +++-- packages/md/package.json | 4 ++-- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/demo/package.json b/demo/package.json index 56c7d95..ccd8a1e 100644 --- a/demo/package.json +++ b/demo/package.json @@ -10,6 +10,7 @@ }, "devDependencies": { "@astropub/md": "*", - "astro": "5" - } + "astro": "6" + }, + "version": "2.0.0" } diff --git a/package.json b/package.json index 009f751..710d65a 100644 --- a/package.json +++ b/package.json @@ -25,7 +25,8 @@ "startCommand": "npm start" }, "devDependencies": { - "astro": "5", + "astro": "6", "types-object": "latest" - } + }, + "version": "2.0.0" } diff --git a/packages/md/package.json b/packages/md/package.json index fc355f0..4ee2192 100644 --- a/packages/md/package.json +++ b/packages/md/package.json @@ -2,7 +2,7 @@ "$schema": "https://json.schemastore.org/package.json", "name": "@mashehu/astropub-md", "description": "Render any Markdown content in Astro. Forked from @astropub/md", - "version": "1.0.1", + "version": "2.0.0", "type": "module", "license": "CC0-1.0", "exports": { @@ -25,7 +25,7 @@ "./package.json": "./package.json" }, "peerDependencies": { - "@astrojs/markdown-remark": "^6" + "@astrojs/markdown-remark": "^7" }, "main": "astro-md.js", "types": "astro-md.d.ts", From 189021138f1fa98643bcb6794d6a4de4c47908bf Mon Sep 17 00:00:00 2001 From: mashehu Date: Mon, 23 Mar 2026 17:04:16 +0100 Subject: [PATCH 5/7] switch to astro 6's htmlstring --- demo/package.json | 2 +- demo/src/pages/index.astro | 2 +- packages/md/lib/html-string.d.ts | 3 --- packages/md/lib/html-string.js | 5 ----- packages/md/lib/markdown.js | 2 +- 5 files changed, 3 insertions(+), 11 deletions(-) delete mode 100644 packages/md/lib/html-string.d.ts delete mode 100644 packages/md/lib/html-string.js diff --git a/demo/package.json b/demo/package.json index ccd8a1e..430cabd 100644 --- a/demo/package.json +++ b/demo/package.json @@ -9,7 +9,7 @@ "astro": "astro" }, "devDependencies": { - "@astropub/md": "*", + "@mashehu/astropub-md": "*", "astro": "6" }, "version": "2.0.0" diff --git a/demo/src/pages/index.astro b/demo/src/pages/index.astro index a31905e..4be7729 100644 --- a/demo/src/pages/index.astro +++ b/demo/src/pages/index.astro @@ -1,5 +1,5 @@ --- -import { Markdown, markdown } from '@astropub/md' +import { Markdown, markdown } from '@mashehu/astropub-md' --- diff --git a/packages/md/lib/html-string.d.ts b/packages/md/lib/html-string.d.ts deleted file mode 100644 index f56b56c..0000000 --- a/packages/md/lib/html-string.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -export declare class HTMLString extends String { - get [Symbol.toStringTag](): string -} diff --git a/packages/md/lib/html-string.js b/packages/md/lib/html-string.js deleted file mode 100644 index 345e64e..0000000 --- a/packages/md/lib/html-string.js +++ /dev/null @@ -1,5 +0,0 @@ -export class HTMLString extends String { - get [Symbol.toStringTag]() { - return 'HTMLString' - } -} diff --git a/packages/md/lib/markdown.js b/packages/md/lib/markdown.js index 09ecc63..ca3b3ac 100644 --- a/packages/md/lib/markdown.js +++ b/packages/md/lib/markdown.js @@ -1,6 +1,6 @@ import { createMarkdownProcessor } from '@astrojs/markdown-remark' import { shared } from './shared.js' -import { HTMLString } from './html-string.js' +import { HTMLString } from 'astro/runtime/server/index.js' const processor = await createMarkdownProcessor({ ...shared.markdownConfig, From ad26e66ee816e05e26c7415600baed586c73c09b Mon Sep 17 00:00:00 2001 From: mashehu Date: Mon, 23 Mar 2026 17:05:08 +0100 Subject: [PATCH 6/7] bump to 2.0.1 --- demo/package.json | 2 +- package.json | 2 +- packages/md/package.json | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/demo/package.json b/demo/package.json index 430cabd..f49e129 100644 --- a/demo/package.json +++ b/demo/package.json @@ -12,5 +12,5 @@ "@mashehu/astropub-md": "*", "astro": "6" }, - "version": "2.0.0" + "version": "2.0.1" } diff --git a/package.json b/package.json index 710d65a..ce33c6b 100644 --- a/package.json +++ b/package.json @@ -28,5 +28,5 @@ "astro": "6", "types-object": "latest" }, - "version": "2.0.0" + "version": "2.0.1" } diff --git a/packages/md/package.json b/packages/md/package.json index 4ee2192..3849684 100644 --- a/packages/md/package.json +++ b/packages/md/package.json @@ -2,7 +2,7 @@ "$schema": "https://json.schemastore.org/package.json", "name": "@mashehu/astropub-md", "description": "Render any Markdown content in Astro. Forked from @astropub/md", - "version": "2.0.0", + "version": "2.0.1", "type": "module", "license": "CC0-1.0", "exports": { From a284826c54c7205438002f7d5f0972b5821ef862 Mon Sep 17 00:00:00 2001 From: mashehu Date: Wed, 24 Jun 2026 14:04:10 +0200 Subject: [PATCH 7/7] =?UTF-8?q?update=20to=20astro=207=20and=20switch=20to?= =?UTF-8?q?=20s=C3=A4tteri?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 64 ++++++++++++++++++-------------- demo/astro.config.js | 2 +- demo/package.json | 4 +- package.json | 4 +- packages/md/README.md | 62 +++++++++++++++++-------------- packages/md/global.d.ts | 2 +- packages/md/lib/component.js | 2 - packages/md/lib/integration.d.ts | 3 +- packages/md/lib/integration.js | 25 +++++++++++-- packages/md/lib/markdown.d.ts | 8 ++-- packages/md/lib/markdown.js | 37 +++++++++++------- packages/md/lib/shared.d.ts | 4 +- packages/md/lib/shared.js | 2 +- packages/md/package.json | 9 +++-- 14 files changed, 137 insertions(+), 91 deletions(-) diff --git a/README.md b/README.md index fd33b6e..7d879b8 100644 --- a/README.md +++ b/README.md @@ -1,24 +1,23 @@ > [!IMPORTANT] -> This is an updated fork of [@astropub/md](https://github.com/astro-community/md). All the hard work was done by the original authors. +> This is a fork of [@astropub/md](https://github.com/astro-community/md) — all the original hard work was done by its authors. This fork swaps the rendering engine from remark/rehype to **[Sätteri](https://satteri.bruits.org/)** (a Rust-backed Markdown pipeline) and targets **Astro 7**. # Astro Markdown -**Astro Markdown** lets you render any Markdown content in **[Astro](https://astro.build)**, optionally integrating with any existing configuration. +**Astro Markdown** lets you render any Markdown content in **[Astro](https://astro.build)**, powered by **[Sätteri](https://satteri.bruits.org/)**. [![NPM Version][npm-img]][npm-url] [![NPM Downloads][download-img]][download-url] -[![Open in StackBlitz][stackblitz-img]][stackblitz-url] ```astro --- -import { Markdown } from '@astropub/md' +import { Markdown } from '@mashehu/astropub-md' --- Hi, there!` */} /> ``` ```astro --- -import { markdown } from '@astropub/md' +import { markdown } from '@mashehu/astropub-md' --- { /* Renders `

Hi, there!

` */ @@ -31,14 +30,14 @@ import { markdown } from '@astropub/md' Add **Astro Markdown** to your project. ```shell -npm install @astropub/md +npm install @mashehu/astropub-md ``` Use **Astro Markdown** in your project. ```astro --- -import { markdown } from '@astropub/md' +import { markdown } from '@mashehu/astropub-md' --- @@ -56,33 +55,45 @@ Welcome to my _website_.` ``` -Optionally, integrate **Astro Markdown** with your existing Astro configuration. +Optionally, add the integration. It inherits the relevant parts of your Astro `markdown` configuration (`gfm` and `smartypants`) and lets you pass [Sätteri](https://satteri.bruits.org/) options directly. ```js // astro.config.js import { defineConfig } from 'astro/config' -import markdownIntegration from '@astropub/md' +import markdownIntegration from '@mashehu/astropub-md' export default defineConfig({ integrations: [ - markdownIntegration(), + markdownIntegration({ + // Sätteri `CompileOptions` — applied to every render + features: { + gfm: true, + smartPunctuation: true, + // math: true, + // wikilinks: true, + }, + // mdastPlugins: [], + // hastPlugins: [], + }), ], markdown: { - remarkPlugins: [], - rehypePlugins: [], - // syntaxHighlight: 'shiki' - // syntaxHighlight: 'prism' - } + // `gfm` and `smartypants` are mapped onto Sätteri features automatically + gfm: true, + smartypants: true, + }, }) ``` -Now `markdown` configuration is automatically applied to `` components and `markdown()` functions. +> [!NOTE] +> Sätteri does **not** use the remark/rehype ecosystem, so Astro's `remarkPlugins`, `rehypePlugins`, and `syntaxHighlight` options have no effect here. Use Sätteri's own [`mdastPlugins` / `hastPlugins`](https://satteri.bruits.org/) instead, passed to `markdownIntegration()` or per call as the second argument to `markdown()`. + +Now that configuration is automatically applied to `` components and `markdown()` functions. Use `markdown.inline()` or `` to handle short strings of text without the surrounding paragraph. ```astro --- -import { Markdown } from '@astropub/md' +import { Markdown } from '@mashehu/astropub-md' --- website.` */ @@ -92,7 +103,7 @@ import { Markdown } from '@astropub/md' ```astro --- -import { markdown } from '@astropub/md' +import { markdown } from '@mashehu/astropub-md' --- {await markdown.inline( /* Renders `Welcome to my website.` */ @@ -122,7 +133,7 @@ Inside of this Astro project, you'll see the following folders and files: └── ...etc ``` -This project uses **workspaces** to develop a single package, `@astropub/md`. +This project uses **workspaces** to develop a single package, `@mashehu/astropub-md`. It also includes a minimal Astro project, `demo`, for developing and demonstrating the component. @@ -138,16 +149,13 @@ All commands are run from the root of the project, from a terminal: | `npm run serve` | Preview your build locally, before deploying | Want to learn more? -Read the [Astro documentation][docs-url] or jump into the [Astro Discord][chat-url]. +Read the [Sätteri documentation][satteri-url], the [Astro documentation][docs-url], or jump into the [Astro Discord][chat-url]. [chat-url]: https://astro.build/chat [docs-url]: https://github.com/withastro/astro +[satteri-url]: https://satteri.bruits.org/ -[npm-img]: https://img.shields.io/npm/v/@astropub/md?color=%23444&label=&labelColor=%23CB0000&logo=data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjE1MCAxNTAgNDAwIDQwMCIgZmlsbD0iI0ZGRiI+PHBhdGggZD0iTTE1MCA1NTBoMjAwVjI1MGgxMDB2MzAwaDEwMFYxNTBIMTUweiIvPjwvc3ZnPg==&style=for-the-badge -[npm-url]: https://www.npmjs.com/package/@astropub/md -[stackblitz-img]: https://img.shields.io/badge/-Open%20in%20Stackblitz-%231374EF?color=%23444&labelColor=%231374EF&logo=data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjEwIDggMTIgMTgiIGhlaWdodD0iMTgiIGZpbGw9IiNGRkYiPjxwYXRoIGQ9Ik0xMCAxNy42aDUuMmwtMyA3LjRMMjIgMTQuNGgtNS4ybDMtNy40TDEwIDE3LjZaIi8+PC9zdmc+&style=for-the-badge -[stackblitz-url]: https://stackblitz.com/github/astro-community/md -[bundlejs-img]: https://img.shields.io/badge/dynamic/json?url=https://bundlejs.com/api?q=@astropub/md&query=size.totalCompressedSize&color=%23444&labelColor=%233B82F6&label=&logo=data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCA3MDAgNzAwIiBmaWxsPSIjRkZGIj4KCTxwYXRoIGQ9Ik0xNDYgMkExNzEgMTcxIDAgMCAwIDMgMTM5bC0yIDExdjQwMmwyIDExYzE1IDcyIDcxIDEyNSAxNDMgMTM2bDIwOSAxIDE5OS0xIDktMmM3MC0xNiAxMTktNjYgMTM0LTEzNWwyLTEwVjE1MGwtMi0xMkExNzEgMTcxIDAgMCAwIDU2MiAzbC0xMC0yLTE5OS0xQzE4NyAwIDE1MyAwIDE0NiAyem0xODEgMjUxdjM2bDctM2MxMy02IDMzLTkgNTAtNyA0MSA1IDcwIDM0IDgwIDc4IDIgMTIgMiA0MSAwIDUzLTUgMjItMTMgMzgtMjcgNTJhODIgODIgMCAwIDEtNjMgMjZjLTE1IDAtMTkgMC0yNS0yLTEwLTItMTctNi0yNC0xMGwtNS0zdjExaC00NVYyMTdoNTJ2MzZ6bTI5IDcxYy0yMCAzLTMyIDE5LTM1IDQ4LTMgMjUgMyA0OCAxNCA2MCA1IDYgMTMgMTAgMjMgMTEgMjUgNCA0NC05IDUxLTM2bDMtMTljMC0xNy0xLTI3LTctMzktOS0xOS0yNi0yOC00OS0yNXoiLz4KPC9zdmc+&style=for-the-badge -[bundlejs-url]: https://bundlejs.com/?bundle&q=@astropub/md -[download-url]: https://www.npmjs.com/package/@astropub/md -[download-img]: https://img.shields.io/badge/dynamic/json?url=https://api.npmjs.org/downloads/point/last-week/@astropub/md&query=downloads&label=⇓+week&color=%23444&labelColor=%23EEd100&style=for-the-badge +[npm-img]: https://img.shields.io/npm/v/@mashehu/astropub-md?color=%23444&label=&labelColor=%23CB0000&logo=data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjE1MCAxNTAgNDAwIDQwMCIgZmlsbD0iI0ZGRiI+PHBhdGggZD0iTTE1MCA1NTBoMjAwVjI1MGgxMDB2MzAwaDEwMFYxNTBIMTUweiIvPjwvc3ZnPg==&style=for-the-badge +[npm-url]: https://www.npmjs.com/package/@mashehu/astropub-md +[download-url]: https://www.npmjs.com/package/@mashehu/astropub-md +[download-img]: https://img.shields.io/badge/dynamic/json?url=https://api.npmjs.org/downloads/point/last-week/@mashehu/astropub-md&query=downloads&label=⇓+week&color=%23444&labelColor=%23EEd100&style=for-the-badge diff --git a/demo/astro.config.js b/demo/astro.config.js index 0c4a429..83e88d6 100644 --- a/demo/astro.config.js +++ b/demo/astro.config.js @@ -1,5 +1,5 @@ import { defineConfig } from 'astro/config' -import markdownIntegration from '@astropub/md' +import markdownIntegration from '@mashehu/astropub-md' export default defineConfig({ integrations: [ diff --git a/demo/package.json b/demo/package.json index f49e129..29ee839 100644 --- a/demo/package.json +++ b/demo/package.json @@ -10,7 +10,7 @@ }, "devDependencies": { "@mashehu/astropub-md": "*", - "astro": "6" + "astro": "7" }, - "version": "2.0.1" + "version": "3.0.0" } diff --git a/package.json b/package.json index ce33c6b..a8bfed4 100644 --- a/package.json +++ b/package.json @@ -25,8 +25,8 @@ "startCommand": "npm start" }, "devDependencies": { - "astro": "6", + "astro": "7", "types-object": "latest" }, - "version": "2.0.1" + "version": "3.0.0" } diff --git a/packages/md/README.md b/packages/md/README.md index 08cbfae..fd71d3b 100644 --- a/packages/md/README.md +++ b/packages/md/README.md @@ -1,24 +1,23 @@ > [!IMPORTANT] -> This is an updated fork of [@astropub/md](https://github.com/astro-community/md). All the hard work was done by the original authors. +> This is a fork of [@astropub/md](https://github.com/astro-community/md) — all the original hard work was done by its authors. This fork swaps the rendering engine from remark/rehype to **[Sätteri](https://satteri.bruits.org/)** (a Rust-backed Markdown pipeline) and targets **Astro 7**. # Astro Markdown -**Astro Markdown** lets you render any Markdown content in **[Astro](https://astro.build)**, optionally integrating with any existing configuration. +**Astro Markdown** lets you render any Markdown content in **[Astro](https://astro.build)**, powered by **[Sätteri](https://satteri.bruits.org/)**. [![NPM Version][npm-img]][npm-url] [![NPM Downloads][download-img]][download-url] -[![Open in StackBlitz][stackblitz-img]][stackblitz-url] ```astro --- -import { Markdown } from '@astropub/md' +import { Markdown } from '@mashehu/astropub-md' --- Hi, there!` */} /> ``` ```astro --- -import { markdown } from '@astropub/md' +import { markdown } from '@mashehu/astropub-md' --- { /* Renders `

Hi, there!

` */ @@ -31,14 +30,14 @@ import { markdown } from '@astropub/md' Add **Astro Markdown** to your project. ```shell -npm install @astropub/md +npm install @mashehu/astropub-md ``` Use **Astro Markdown** in your project. ```astro --- -import { markdown } from '@astropub/md' +import { markdown } from '@mashehu/astropub-md' --- @@ -56,33 +55,45 @@ Welcome to my _website_.` ``` -Optionally, integrate **Astro Markdown** with your existing Astro configuration. +Optionally, add the integration. It inherits the relevant parts of your Astro `markdown` configuration (`gfm` and `smartypants`) and lets you pass [Sätteri](https://satteri.bruits.org/) options directly. ```js // astro.config.js import { defineConfig } from 'astro/config' -import markdownIntegration from '@astropub/md' +import markdownIntegration from '@mashehu/astropub-md' export default defineConfig({ integrations: [ - markdownIntegration(), + markdownIntegration({ + // Sätteri `CompileOptions` — applied to every render + features: { + gfm: true, + smartPunctuation: true, + // math: true, + // wikilinks: true, + }, + // mdastPlugins: [], + // hastPlugins: [], + }), ], markdown: { - remarkPlugins: [], - rehypePlugins: [], - // syntaxHighlight: 'shiki' - // syntaxHighlight: 'prism' - } + // `gfm` and `smartypants` are mapped onto Sätteri features automatically + gfm: true, + smartypants: true, + }, }) ``` -Now `markdown` configuration is automatically applied to `` components and `markdown()` functions. +> [!NOTE] +> Sätteri does **not** use the remark/rehype ecosystem, so Astro's `remarkPlugins`, `rehypePlugins`, and `syntaxHighlight` options have no effect here. Use Sätteri's own [`mdastPlugins` / `hastPlugins`](https://satteri.bruits.org/) instead, passed to `markdownIntegration()` or per call as the second argument to `markdown()`. + +Now that configuration is automatically applied to `` components and `markdown()` functions. Use `markdown.inline()` or `` to handle short strings of text without the surrounding paragraph. ```astro --- -import { Markdown } from '@astropub/md' +import { Markdown } from '@mashehu/astropub-md' --- website.` */ @@ -92,7 +103,7 @@ import { Markdown } from '@astropub/md' ```astro --- -import { markdown } from '@astropub/md' +import { markdown } from '@mashehu/astropub-md' --- {await markdown.inline( /* Renders `Welcome to my website.` */ @@ -107,16 +118,13 @@ Enjoy! --- Want to learn more? -Read the [Astro documentation][docs-url] or jump into the [Astro Discord][chat-url]. +Read the [Sätteri documentation][satteri-url], the [Astro documentation][docs-url], or jump into the [Astro Discord][chat-url]. [chat-url]: https://astro.build/chat [docs-url]: https://github.com/withastro/astro +[satteri-url]: https://satteri.bruits.org/ -[npm-img]: https://img.shields.io/npm/v/@astropub/md?color=%23444&label=&labelColor=%23CB0000&logo=data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjE1MCAxNTAgNDAwIDQwMCIgZmlsbD0iI0ZGRiI+PHBhdGggZD0iTTE1MCA1NTBoMjAwVjI1MGgxMDB2MzAwaDEwMFYxNTBIMTUweiIvPjwvc3ZnPg==&style=for-the-badge -[npm-url]: https://www.npmjs.com/package/@astropub/md -[stackblitz-img]: https://img.shields.io/badge/-Open%20in%20Stackblitz-%231374EF?color=%23444&labelColor=%231374EF&logo=data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjEwIDggMTIgMTgiIGhlaWdodD0iMTgiIGZpbGw9IiNGRkYiPjxwYXRoIGQ9Ik0xMCAxNy42aDUuMmwtMyA3LjRMMjIgMTQuNGgtNS4ybDMtNy40TDEwIDE3LjZaIi8+PC9zdmc+&style=for-the-badge -[stackblitz-url]: https://stackblitz.com/github/astro-community/md -[bundlejs-img]: https://img.shields.io/badge/dynamic/json?url=https://bundlejs.com/api?q=@astropub/md&query=size.totalCompressedSize&color=%23444&labelColor=%233B82F6&label=&logo=data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCA3MDAgNzAwIiBmaWxsPSIjRkZGIj4KCTxwYXRoIGQ9Ik0xNDYgMkExNzEgMTcxIDAgMCAwIDMgMTM5bC0yIDExdjQwMmwyIDExYzE1IDcyIDcxIDEyNSAxNDMgMTM2bDIwOSAxIDE5OS0xIDktMmM3MC0xNiAxMTktNjYgMTM0LTEzNWwyLTEwVjE1MGwtMi0xMkExNzEgMTcxIDAgMCAwIDU2MiAzbC0xMC0yLTE5OS0xQzE4NyAwIDE1MyAwIDE0NiAyem0xODEgMjUxdjM2bDctM2MxMy02IDMzLTkgNTAtNyA0MSA1IDcwIDM0IDgwIDc4IDIgMTIgMiA0MSAwIDUzLTUgMjItMTMgMzgtMjcgNTJhODIgODIgMCAwIDEtNjMgMjZjLTE1IDAtMTkgMC0yNS0yLTEwLTItMTctNi0yNC0xMGwtNS0zdjExaC00NVYyMTdoNTJ2MzZ6bTI5IDcxYy0yMCAzLTMyIDE5LTM1IDQ4LTMgMjUgMyA0OCAxNCA2MCA1IDYgMTMgMTAgMjMgMTEgMjUgNCA0NC05IDUxLTM2bDMtMTljMC0xNy0xLTI3LTctMzktOS0xOS0yNi0yOC00OS0yNXoiLz4KPC9zdmc+&style=for-the-badge -[bundlejs-url]: https://bundlejs.com/?bundle&q=@astropub/md -[download-url]: https://www.npmjs.com/package/@astropub/md -[download-img]: https://img.shields.io/badge/dynamic/json?url=https://api.npmjs.org/downloads/point/last-week/@astropub/md&query=downloads&label=⇓+week&color=%23444&labelColor=%23EEd100&style=for-the-badge +[npm-img]: https://img.shields.io/npm/v/@mashehu/astropub-md?color=%23444&label=&labelColor=%23CB0000&logo=data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjE1MCAxNTAgNDAwIDQwMCIgZmlsbD0iI0ZGRiI+PHBhdGggZD0iTTE1MCA1NTBoMjAwVjI1MGgxMDB2MzAwaDEwMFYxNTBIMTUweiIvPjwvc3ZnPg==&style=for-the-badge +[npm-url]: https://www.npmjs.com/package/@mashehu/astropub-md +[download-url]: https://www.npmjs.com/package/@mashehu/astropub-md +[download-img]: https://img.shields.io/badge/dynamic/json?url=https://api.npmjs.org/downloads/point/last-week/@mashehu/astropub-md&query=downloads&label=⇓+week&color=%23444&labelColor=%23EEd100&style=for-the-badge diff --git a/packages/md/global.d.ts b/packages/md/global.d.ts index 43c84ad..71f6aea 100644 --- a/packages/md/global.d.ts +++ b/packages/md/global.d.ts @@ -1,4 +1,4 @@ -declare module "@astropub/md/Markdown" { +declare module "@mashehu/astropub-md/Markdown" { export var Markdown: typeof import('./lib/component')['Markdown'] export default Markdown diff --git a/packages/md/lib/component.js b/packages/md/lib/component.js index bf50c43..6f83248 100644 --- a/packages/md/lib/component.js +++ b/packages/md/lib/component.js @@ -13,7 +13,6 @@ export const Markdown = Object.assign( if (typeof mdl === 'string') { yield await markdown(mdl, { fileURL: new URL(import.meta.url), - contentDir: new URL('./', import.meta.url), }) } else { yield renderSlot(result, slots.default) @@ -35,7 +34,6 @@ export const Markdown = Object.assign( if (typeof mdl === 'string') { yield await markdown.inline(mdl, { fileURL: new URL(import.meta.url), - contentDir: new URL('./', import.meta.url), }) } else { yield renderSlot(result, slots.default) diff --git a/packages/md/lib/integration.d.ts b/packages/md/lib/integration.d.ts index aa621fb..4aadc2b 100644 --- a/packages/md/lib/integration.d.ts +++ b/packages/md/lib/integration.d.ts @@ -1,5 +1,6 @@ import type { AstroIntegration } from 'astro' +import type { CompileOptions } from 'satteri' -export function mdAstro(): AstroIntegration +export function mdAstro(options?: CompileOptions): AstroIntegration export type { AstroIntegration } diff --git a/packages/md/lib/integration.js b/packages/md/lib/integration.js index d875abc..af05bf2 100644 --- a/packages/md/lib/integration.js +++ b/packages/md/lib/integration.js @@ -1,11 +1,30 @@ import { shared } from './shared.js' -export function mdAstro() { +/** + * Astro integration that hands the host project's Markdown configuration to the + * Sätteri renderer used by `markdown()` / ``. + * + * Astro's `config.markdown` is shaped for the remark/rehype pipeline, which + * Sätteri does not use. We map the options that have a Sätteri equivalent + * (`gfm`, `smartypants`) onto Sätteri's feature flags. remark/rehype plugins + * have no Sätteri equivalent and are ignored — pass Sätteri `mdastPlugins` / + * `hastPlugins` to `mdAstro()` instead. + */ +export function mdAstro(/** @type {CompileOptions} */ options = {}) { const integration = /** @type {AstroIntegration} */ ({ name: 'astro:md', hooks: { 'astro:config:done'({ config }) { - shared.markdownConfig = config.markdown + const md = config.markdown || {} + + shared.markdownConfig = { + ...options, + features: { + gfm: md.gfm ?? true, + smartPunctuation: md.smartypants ?? true, + ...options.features, + }, + } }, }, }) @@ -14,4 +33,4 @@ export function mdAstro() { } /** @typedef {import('astro').AstroIntegration} AstroIntegration */ -/** @typedef {import('vite').Plugin} Plugin */ +/** @typedef {import('satteri').CompileOptions} CompileOptions */ diff --git a/packages/md/lib/markdown.d.ts b/packages/md/lib/markdown.d.ts index b9e5550..bee1797 100644 --- a/packages/md/lib/markdown.d.ts +++ b/packages/md/lib/markdown.d.ts @@ -1,15 +1,15 @@ -import type { MarkdownRenderingOptions, MarkdownRenderingResult } from '@astrojs/markdown-remark' +import type { CompileOptions } from 'satteri' -export type { MarkdownRenderingOptions, MarkdownRenderingResult } +export type { CompileOptions } export var markdown: { ( content: string, - options?: MarkdownRenderingOptions + options?: CompileOptions ): Promise inline( content: string, - options?: MarkdownRenderingOptions + options?: CompileOptions ): Promise } diff --git a/packages/md/lib/markdown.js b/packages/md/lib/markdown.js index ca3b3ac..53195e7 100644 --- a/packages/md/lib/markdown.js +++ b/packages/md/lib/markdown.js @@ -1,32 +1,41 @@ -import { createMarkdownProcessor } from '@astrojs/markdown-remark' +import { markdownToHtml } from 'satteri' import { shared } from './shared.js' import { HTMLString } from 'astro/runtime/server/index.js' -const processor = await createMarkdownProcessor({ - ...shared.markdownConfig, -}) +/** Build the Sätteri compile options for a single render. */ +function resolveOptions(/** @type {CompileOptions} */ options) { + return { + ...shared.markdownConfig, + ...options, + features: { + ...shared.markdownConfig.features, + ...(options && options.features), + }, + } +} export async function markdown( /** @type {string} */ content, - /** @type {MarkdownRenderingOptions} */ options = null + /** @type {CompileOptions} */ options = null ) { - const result = await processor.render(content, options) + const result = await markdownToHtml(content, resolveOptions(options)) - return new HTMLString(result.code) + return new HTMLString(result.html) } markdown.inline = async function inlinemarkdown( /** @type {string} */ content, - /** @type {MarkdownRenderingOptions} */ options = null + /** @type {CompileOptions} */ options = null ) { - const result = await processor.render(content, options) + const result = await markdownToHtml(content, resolveOptions(options)) + const code = result.html.trim() return new HTMLString( - result.code.indexOf("

") === 0 && - result.code.indexOf("

") === result.code.length - 4 - ? result.code.slice(3, -4) - : result.code, + code.indexOf('

') === 0 && + code.indexOf('

') === code.length - 4 + ? code.slice(3, -4) + : code ) } -/** @typedef {import('./markdown').MarkdownRenderingOptions} MarkdownRenderingOptions */ +/** @typedef {import('satteri').CompileOptions} CompileOptions */ diff --git a/packages/md/lib/shared.d.ts b/packages/md/lib/shared.d.ts index 508880a..3e0daed 100644 --- a/packages/md/lib/shared.d.ts +++ b/packages/md/lib/shared.d.ts @@ -1,7 +1,7 @@ -import type { AstroConfig } from 'astro' +import type { CompileOptions } from 'satteri' export interface Shared { - markdownConfig: AstroConfig['markdown'] + markdownConfig: CompileOptions } export const shared: Shared diff --git a/packages/md/lib/shared.js b/packages/md/lib/shared.js index 45cee36..bde7eb9 100644 --- a/packages/md/lib/shared.js +++ b/packages/md/lib/shared.js @@ -1,4 +1,4 @@ -export const symbol = Symbol.for('@astropub/md') +export const symbol = Symbol.for('@mashehu/astropub-md') export const shared = /** @type {Shared} */ ( globalThis[symbol] || ( diff --git a/packages/md/package.json b/packages/md/package.json index 3849684..a875a2c 100644 --- a/packages/md/package.json +++ b/packages/md/package.json @@ -2,7 +2,7 @@ "$schema": "https://json.schemastore.org/package.json", "name": "@mashehu/astropub-md", "description": "Render any Markdown content in Astro. Forked from @astropub/md", - "version": "2.0.1", + "version": "3.0.0", "type": "module", "license": "CC0-1.0", "exports": { @@ -25,7 +25,10 @@ "./package.json": "./package.json" }, "peerDependencies": { - "@astrojs/markdown-remark": "^7" + "astro": "^7" + }, + "dependencies": { + "satteri": "^0.9.2" }, "main": "astro-md.js", "types": "astro-md.d.ts", @@ -52,7 +55,7 @@ "markdown", "md", "render", - "remark" + "satteri" ], "author": "Jonathan Neal ", "contributors": [