vimwiki_macros 0.1.0

Macro library that provides macros to generate vimwiki language at compile time.
Documentation
use crate::tokens::{
    utils::{
        root_crate, tokenize_cow_str_type, tokenize_hashmap, tokenize_option,
    },
    Tokenize, TokenizeContext,
};
use proc_macro2::TokenStream;
use quote::quote;
use vimwiki_core::CodeBlock;

impl_tokenize!(tokenize_code_block, CodeBlock<'a>, 'a);
fn tokenize_code_block(
    ctx: &TokenizeContext,
    code_block: &CodeBlock,
) -> TokenStream {
    let root = root_crate();
    let lang = tokenize_option(ctx, &code_block.language, |ctx, x| {
        do_tokenize!(ctx, x)
    });
    let metadata = tokenize_hashmap(
        &code_block.metadata,
        tokenize_cow_str_type(),
        tokenize_cow_str_type(),
        |x| do_tokenize!(ctx, x),
        |x| do_tokenize!(ctx, x),
    );
    let lines = code_block.lines.iter().map(|x| do_tokenize!(ctx, x));
    quote! {
        #root::CodeBlock::new(
            #lang,
            #metadata,
            ::std::vec![#(#lines),*],
        )
    }
}