Change-Id: Ic7467f459015c39c73f87c61a048319eaf1243be Reviewed-on: https://cl.tvl.fyi/c/depot/+/8714 Tested-by: BuildkiteCI Reviewed-by: tazjin <tazjin@tvl.su>
		
			
				
	
	
		
			27 lines
		
	
	
	
		
			726 B
		
	
	
	
		
			Rust
		
	
	
	
	
	
			
		
		
	
	
			27 lines
		
	
	
	
		
			726 B
		
	
	
	
		
			Rust
		
	
	
	
	
	
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()
 | 
						|
}
 |