import { Tokens } from "../helpers/regexp.js";
import { findAndReplace } from "../nast/find-and-replace.js";
/** Finds and creates web links in the tree */
export function links() {
    return (tree) => {
        findAndReplace(tree, [
            [
                Tokens.link,
                (_) => {
                    try {
                        return {
                            type: "link",
                            href: new URL(_).toString(),
                            value: _,
                        };
                    }
                    catch (error) { }
                    return false;
                },
            ],
        ]);
    };
}
