hf-mdrd
v0.1.17
Published
A markdown renderer written in rust, compiled to wasm.
Readme
title: HF-MdRd README description: An brief introduction to HF-MdRd
HF-MdRd
A markdown renderer written in Rust was compiled to wasm.
It can be used in both frontend and backend.
Usage
Node.js
- Install
hf-mdrd
npm install hf-mdrd- Import the module
import { md_to_html } from "hf-mdrd";
const { md_to_html } = require("hf-mdrd");
const html = md_to_html(markdown_content);- Add CSS to the frontend
import "hf-mdrd/css/hf-mdrd.css";Browser
<html>
<head>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/css/hf-mdrd.min.css" crossorigin="anonymous">
</head>
<body>
<script type="module" type="text/javascript">
import init, { md_to_html } from 'https://cdn.jsdelivr.net/npm/[email protected]/browser/hf-mdrd.min.mjs';
await init();
const html = md_to_html(markdown_text);
</script>
</body>
</html>Basic Syntax
using pulldown-cmark to handle basic syntax
Code span
Bold
Italic
~~Strikethrough~~
AutoLink: https://hf-mdrd.hsingfu.tw
Link: link
- List
- List
- List
- Ordered
- List
Don't believe everything you read on the Internet.
— Abraham Lincoln
Break Here
CodeBlock
fn main() {
println!("hello, world!");
}Highlight
using highlight.js to handle syntax highlight
Supported Language
- python
- rust
- typescript
- xml
- html
- fortran
- go
- java
- javascript
- json
- kotlin
- latex
- lua
- markdown
- bash
- c
- cpp
- css
Adding Line Number
fn main() {
println!("hello, world!");
}fn main() {
println!("hello, world!");
}Math
using katex to handle math expression
Euler Formula: $e^{ix} = cos(x) + isin(x)$
Euler Formula: $$e^{ix} = cos(x) + isin(x)$$
Spoiler
:::spoiler The :::
:::spoiler spoiler Content :::
:::spoiler spoiler
Inside
:::
:::spoiler $spoiler$ Spoiler :::
Table
| header | row | | ------ | --- | | body | row |
API
function md_to_html(markdown_content: string): string