4 ms·
I once experimented this, and it worked. I wanted to do this because I needed a decent and fast CommonMark library, but Rust didn't have one. (Yes, I tried to e
by barosl 11y ago
I once experimented this, and it worked. I wanted to do this because I needed a decent and fast CommonMark library, but Rust didn't have one. (Yes, I tried to embed JavaScript in Rust just to parse some MarkDown text!)
There are two libraries that embed V8 in Rust, but all of them seem to be abandoned for now. However if there become enough interests, a new project will arise I think.
(FWIW, I ended up calling CommonMark library written in Python from Rust, because embedding CPython was easier than embedding V8. Unfortunately CPython's performance is worse than V8, but as I know Python better than JavaScript it was a reasonable choice.)
- thristian 11y agoYou know there's a CommonMark reference implementation in C, right? https://github.com/jgm/cmark https://github.com/jgm/cmark I haven't tried it, but I would expect it would be easier to link with Rust than an entire other language VM.
- barosl 11y agoOh, yes. I had also tried that, but found some convenient features missing, e.g. line breaks treated as `<br>` (not two consecutive blank lines), GitHub-flavored tables, and the strikethrough syntax. I'll have to wait until the official CommonMark spec includes them. Also the third-party CommonMark libraries are usually easier to extend, with your own syntax addition.