i’ve created a custom parser that’s kinda-sorta based on @lezer/markdown (which you can find here if you’re interested and if you can excuse my colourful commit messages).
what i’m trying to do is add a foldNodeProp to certain syntax nodes; first by defining my node types…
let nodeTypes = [NodeType.none];
for (let i = 1, name; (name = Type[i]); i++) {
let properties = [];
if (name === "Scene") {
properties.push(
foldNodeProp.add({
Scene: foldInside
}))
}
nodeTypes[i] = NodeType.define({
id: i,
name,
props: properties,
});
}
… and then finally attaching them to the parser like this:
const parser = new FountainParser(
new NodeSet(nodeTypes),
Object.keys(DefaultBlockParsers).map((n) => DefaultBlockParsers[n]),
Object.keys(DefaultBlockParsers).map((n) => DefaultLeafBlocks[n]),
Object.keys(DefaultBlockParsers),
DefaultEndLeaf,
DefaultSkipMarkup,
Object.keys(DefaultInline).map((n) => DefaultInline[n]),
Object.keys(DefaultInline),
[]
);
const data = defineLanguageFacet({ BoneYard: { open: "/*", close: "*/" } });
export function ftn(exts?: Extension[]) {
return new LanguageSupport(new Language(data, parser, exts));
}
(Type
is an enum containing the names of my node types.)
when i searched through the forum earlier, i found this – foldNodeProp does not seem to work for ATX heading
foldNodeProp
is used to make the extent of certain syntax nodes foldable. Since a heading node only spans the actual heading, if you’re expecting this to fold that heading plus any content below it, that won’t work.
The folding system will only call this for nodes that span across the end of the line that’s being folded.
however, i’ve made sure that the nodes i’m trying to fold span across/include newlines.
could i be doing something wrong?