I have a file “foo.lit” in a custom document format which I would like to parse into a ProseMirror document schema. I’m looking for advice on how best to do this.
The thing is, the grammar for “.lit” files is nicely captured by the ProseMirror schema. For instance, the node specification looks something like:
doc: { content: "head? title? (block|chapter)+"}
head: { content: "setup_instruction+"}
setup_instruction: { content: text*}
chapter: { content: title? (block | section)+ }
...
This suggests that a parser module that “speaks the language of ProseMirror schemas” would be the best fit for the job. It would be nice if ProseMirror had a FileParser class where I could say
FileParser.parse({my_scheme}, {file_name}, {rules for matching content in the file})
Well, at any rate, what are your suggestions for building my parser? Should I try use lezer
? Or should I build it from scratch?
For instance, how would one best go about building a parser which takes a Markdown file to a ProseMirror document schema?