How do I create a compiler? #159
-
I would like to create a custom compiler. After combing through docs and code, I gather that I am supposed to create a transformer-like method For context, I am trying to compile Markdown into LaTeX. That is, my processor will look like:
My use case (not to mention my lack of bandwidth and expertise) is rather slim and idiosyncratic, which is why I am not:
I am using So,
|
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 5 replies
-
Heya! rebber is also somewhat what you’re looking for: https://github.com/zestedesavoir/zmarkdown/tree/master/packages/rebber.
Typically the return value of a compiler is a string, which will end up on
I would also recommend, at least architecturally, to go that same route. Your original question, “how do I create a compiler”, can be answered with: function myPlugin() {
this.Compiler = myCompiler
} …so it’s a plugin that attaches a compiler. Where For all the other points, it sounds like you have enough information, now it needs to be build! |
Beta Was this translation helpful? Give feedback.
Heya!
rebber is also somewhat what you’re looking for: https://github.com/zestedesavoir/zmarkdown/tree/master/packages/rebber.
Typically the return value of a compiler is a string, which will end up on
file.value
. Non-strings are set atfile.result
.unist-util-visit
is more typically a utility used in transforms. It could be used in a compiler. But compilers more typically handle each node type and return a string value for them.I would also …