A blazingly fast( possibly the fastest) markdown to html parser and syntax highlighter built using Rust's pulldown-cmark and tree-sitter-highlight crate natively for Node's Foreign Function Interface. PRs are welcome. Very much a WIP
A blazingly fast( possibly the fastest) markdown to html parser and syntax highlighter built using Rust's pulldown-cmark and tree-sitter-highlight crate natively for Node's Foreign Function Interface. PRs are welcome. Very much a WIP
``sh`
npm i @benwis/femark
It is recomended to run this on the server side, since it has a fairly large package size. If you are using Remix, I recommend you use this in your loaders or actions.
`ts`
let {content, toc} = processMarkdownToHtml('# Hello, World!');
- Rust
- Typescript
- Tsx
- Javascript
- Jsx
- Dockerfile
- Python
- Go
- C
- HTML
- TOML
- JSON
Currently the supported languages are driven mostly by my needs, but I am open to PRs to add additional language support if they are popular.
By default, this package does not style your code blocks, merely decorates the elements with classes that range from hh0 to hh20. The indices refer to the elements in this list:`rust
let highlight_names = [
"attribute",
"constant",
"function.builtin",
"function",
"keyword",
"operator",
"property",
"punctuation",
"punctuation.bracket",
"punctuation.delimiter",
"string",
"string.special",
"tag",
"type",
"type.builtin",
"variable",
"variable.builtin",
"variable.parameter",
"comment",
"macro",
"label",
]
`TSFunction
For example, hh0 would refer to an attribute and hh20 would be a label. You'll want to add some css classes for each attribute. Because this is a common tree-sitter theme, if you search for neovim themes that support tree-sitter, you can find items like and TSAttribute with examples. A basic theme is provided below:`css
.hh4 {
color: purple;
}
.hh3 {
color: blue;
}
.hh13 {
color: pink;
}
.hh10 {
color: green;
}
.hh5 {
color: gray;
}
.hh18 {
color: lightgray;
}
`
and npm run build` commands from the root of the package.