webforai
Version:
A library that provides a web interface for AI
23 lines (22 loc) • 582 B
JavaScript
// src/mdast-handlers/custom-a-handler.ts
import { defaultHandlers } from "hast-util-to-mdast";
import { toString as hastToString } from "hast-util-to-string";
var customAHandler = (options) => (state, node) => {
if (options?.asText) {
const text = hastToString(node);
if (3 >= text.length) {
return void 0;
}
const link2 = { type: "text", value: text };
state.patch(node, link2);
return link2;
}
const link = defaultHandlers.a(state, node);
if (link.children.length > 0) {
return link;
}
return void 0;
};
export {
customAHandler
};