fix parsing @@ modules with >2 segments

This commit is contained in:
outfoxxed 2025-10-30 03:45:43 -07:00
parent 09f8d03ab3
commit 2086232a7d
Signed by: outfoxxed
GPG key ID: 4C88A185FB89301E

View file

@ -33,35 +33,33 @@ const remarkParseAtTypes: RemarkPlugin<[]> = () => (root: Md.Root): Md.Root => {
const node = rawNode as Md.Literal; const node = rawNode as Md.Literal;
node.value = node.value.replace( node.value = node.value.replace(
/@@((?<module>([A-Z]\w*\.)*)(?<type>([A-Z]\w*))(\.(?!\s|$))?)?((?<member>[a-z]\w*)((?<function>\(\))|(?<signal>\(s\)))?)?(?=[$.,;:)\s]|$)/g, /@@(?<path>([A-Z]\w*\.)+)((?<member>[a-z]\w*)((?<function>\(\))|(?<signal>\(s\)))?)?(?=[$.,;:)\s]|$)/g,
(_full, ...args) => { (_full, ...args) => {
type Capture = { type Capture = {
module: string | undefined; path: string | undefined;
type: string | undefined;
member: string | undefined; member: string | undefined;
function: string | undefined; function: string | undefined;
signal: string | undefined; signal: string | undefined;
}; };
const groups = args.pop() as Capture; const groups = args.pop() as Capture;
const pathp = groups.path.split('.').filter(Boolean);
let type = (pathp.length >= 1 ? pathp.pop() : "");
let module = pathp.join('_');
if (groups.module) { if (module) {
groups.module = groups.module.substring( const isQs = module.startsWith("Quickshell");
0, module = `99M${isQs ? "QS" : "QT_qml"}_${module}`;
groups.module.length - 1 } else module = ""; // WARNING: rehype parser can't currently handle intra-module links
);
const isQs = groups.module.startsWith("Quickshell");
groups.module = `99M${isQs ? "QS" : "QT_qml"}_${groups.module.replace(".", "_")}`;
} else groups.module = ""; // WARNING: rehype parser can't currently handle intra-module links
groups.type = groups.type ? `99N${groups.type}` : ""; type = type ? `99N${type}` : "";
groups.member = groups.member groups.member = groups.member
? `99V${groups.member}` ? `99V${groups.member}`
: ""; : "";
const type = groups.member const typep = groups.member
? `99T${groups.function ? "func" : groups.signal ? "signal" : "prop"}` ? `99T${groups.function ? "func" : groups.signal ? "signal" : "prop"}`
: ""; : "";
return `TYPE${groups.module}${groups.type}${groups.member}${type}99TYPE`; return `TYPE${module}${type}${groups.member}${typep}99TYPE`;
} }
); );
} }