chore(corp/rih): move frontend to a separate folder
Change-Id: Ic7467f459015c39c73f87c61a048319eaf1243be Reviewed-on: https://cl.tvl.fyi/c/depot/+/8714 Tested-by: BuildkiteCI Reviewed-by: tazjin <tazjin@tvl.su>
This commit is contained in:
parent
6fa6f3a7f4
commit
5dee4780da
11 changed files with 0 additions and 0 deletions
12
corp/rih/frontend/static-markdown/Cargo.toml
Normal file
12
corp/rih/frontend/static-markdown/Cargo.toml
Normal file
|
@ -0,0 +1,12 @@
|
|||
[package]
|
||||
version = "1.0.0"
|
||||
name = "static_markdown"
|
||||
edition = "2018"
|
||||
|
||||
[lib]
|
||||
proc-macro = true
|
||||
|
||||
[dependencies]
|
||||
syn = "1.0"
|
||||
quote = "1.0"
|
||||
comrak = "0.18"
|
27
corp/rih/frontend/static-markdown/src/lib.rs
Normal file
27
corp/rih/frontend/static-markdown/src/lib.rs
Normal file
|
@ -0,0 +1,27 @@
|
|||
extern crate proc_macro;
|
||||
|
||||
use comrak::{markdown_to_html, ComrakOptions};
|
||||
use proc_macro::TokenStream;
|
||||
use quote::quote;
|
||||
use syn::{parse_macro_input, LitStr};
|
||||
|
||||
#[proc_macro]
|
||||
pub fn markdown(input: TokenStream) -> TokenStream {
|
||||
let input = parse_macro_input!(input as LitStr);
|
||||
|
||||
let mut options = ComrakOptions::default();
|
||||
options.extension.strikethrough = true;
|
||||
options.extension.tagfilter = true;
|
||||
options.extension.table = true;
|
||||
options.extension.autolink = true;
|
||||
|
||||
let rendered_html = markdown_to_html(&input.value(), &options);
|
||||
|
||||
let tokens = quote! {
|
||||
yew::virtual_dom::VNode::VRaw(yew::virtual_dom::VRaw {
|
||||
html: #rendered_html.into(),
|
||||
})
|
||||
};
|
||||
|
||||
tokens.into()
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue