}
diff --git a/packages/md/lib/markdown.js b/packages/md/lib/markdown.js
index 09ecc63..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 './html-string.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 469adb3..a875a2c 100644
--- a/packages/md/package.json
+++ b/packages/md/package.json
@@ -1,8 +1,8 @@
{
"$schema": "https://json.schemastore.org/package.json",
- "name": "@astropub/md",
- "description": "Render any Markdown content in Astro",
- "version": "1.0.0",
+ "name": "@mashehu/astropub-md",
+ "description": "Render any Markdown content in Astro. Forked from @astropub/md",
+ "version": "3.0.0",
"type": "module",
"license": "CC0-1.0",
"exports": {
@@ -25,7 +25,10 @@
"./package.json": "./package.json"
},
"peerDependencies": {
- "@astrojs/markdown-remark": "^5"
+ "astro": "^7"
+ },
+ "dependencies": {
+ "satteri": "^0.9.2"
},
"main": "astro-md.js",
"types": "astro-md.d.ts",
@@ -52,10 +55,17 @@
"markdown",
"md",
"render",
- "remark"
+ "satteri"
],
"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"
+ }
}