Skip to content

Commit ae32d68

Browse files
committed
Render and return HTML for passed Markdown
1 parent e1f6e5d commit ae32d68

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

src/lib.rs

+8-4
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,20 @@
22
extern crate mlua_derive;
33

44
use mlua::prelude::*;
5+
use pulldown_cmark::{html, Options, Parser};
56

6-
fn hello(_: &Lua, name: String) -> LuaResult<String> {
7-
let a: String = String::from(format!("not you {} he he", name));
8-
Ok(a)
7+
fn render_html(_: &Lua, buffer: String) -> LuaResult<String> {
8+
let options = Options::all();
9+
let parser = Parser::new_ext(buffer.as_str(), options);
10+
let mut html_output = String::new();
11+
html::push_html(&mut html_output, parser);
12+
Ok(html_output)
913
}
1014

1115
#[lua_module]
1216
fn libvim_pandoc_syntax(lua: &Lua) -> LuaResult<LuaTable> {
1317
let exports = lua.create_table()?;
14-
exports.set("hello", lua.create_function(hello)?)?;
18+
exports.set("render_html", lua.create_function(render_html)?)?;
1519
Ok(exports)
1620
}
1721

0 commit comments

Comments
 (0)