Tholp's bespoke website generator
1// This file for implementations of short blocks, im qualifying that as less than 30ish lines
2use crate::{
3 project::{Indexing, Project},
4 types::{SkidContext, Token},
5};
6
7pub fn macro_comment(
8 _origin_index: usize,
9 _origin_line: usize,
10 _context: &mut Project,
11 _skid_context: &mut SkidContext,
12 _args: &Vec<String>,
13 _scope: &[Token],
14) -> Vec<Token> {
15 return Vec::new();
16}
17
18pub fn macro_section(
19 _origin_index: usize,
20 _origin_line: usize,
21 proj_context: &mut Project,
22 _skid_context: &mut SkidContext,
23 args: &Vec<String>,
24 scope: &[Token],
25) -> Vec<Token> {
26 let mut tokens = Vec::new();
27 if args.len() == 1 {
28 let section_index = proj_context.index_of_section_name(&args[0]);
29 for tok in scope {
30 let mut new = tok.clone();
31 new.section_index = section_index;
32 tokens.push(new);
33 }
34 } else {
35 for tok in scope {
36 tokens.push(tok.clone());
37 }
38 }
39
40 return tokens;
41}
42
43pub fn macro_repeat(
44 _origin_index: usize,
45 _origin_line: usize,
46 _context: &mut Project,
47 _skid_context: &mut SkidContext,
48 args: &Vec<String>,
49 scope: &[Token],
50) -> Vec<Token> {
51 let mut count = 0;
52 if args.len() > 0 {
53 count = args[0].parse().unwrap_or(0);
54 }
55
56 let mut tokens = Vec::new();
57 for _i in 0..count {
58 for tok in scope {
59 tokens.push(tok.clone());
60 }
61 }
62 return tokens;
63}