// @ts-check
import { defineMdastPlugin } from "satteri";
// the go renderer's dashes (appview/pages/markup/extension/dashes.go), which the
// posts are written for: `--` is an em dash, and a hyphen between two digits
// (50-100) an en dash. satteri's own smart dashes make `--` an en dash instead, so
// they're off (astro.config.mjs) and this does the dashes; code is left alone
export const dashes = defineMdastPlugin({
name: "tangled-dashes",
text(node, ctx) {
const value = node.value.replace(/--/g, "\u2014").replace(/(\d)-(?=\d)/g, "$1\u2013");
if (value !== node.value) ctx.replaceNode(node, { type: "text", value });
},
});