diff options
| author | Mike Buland <mike@xagasoft.com> | 2026-06-08 12:32:06 -0700 |
|---|---|---|
| committer | Mike Buland <mike@xagasoft.com> | 2026-06-08 12:32:06 -0700 |
| commit | 3e60b2746bb95cfcd9b7fa4b7ed9e1c72259fb23 (patch) | |
| tree | 3034717e3bcaeb4f93b03dc89ce81f77feda9bc7 /src/lib.rs | |
| parent | 55750a223008b256fddd8636ff4d474f959c8a23 (diff) | |
| download | crimtag-3e60b2746bb95cfcd9b7fa4b7ed9e1c72259fb23.tar.gz crimtag-3e60b2746bb95cfcd9b7fa4b7ed9e1c72259fb23.tar.bz2 crimtag-3e60b2746bb95cfcd9b7fa4b7ed9e1c72259fb23.tar.xz crimtag-3e60b2746bb95cfcd9b7fa4b7ed9e1c72259fb23.zip | |
It parses correctly for everything defined.
I think I'll change fragment to view, it's nicer and shorter.
Diffstat (limited to 'src/lib.rs')
| -rw-r--r-- | src/lib.rs | 18 |
1 files changed, 16 insertions, 2 deletions
| @@ -50,6 +50,7 @@ struct Output { | |||
| 50 | 50 | ||
| 51 | type Properties = HashMap<String, String>; | 51 | type Properties = HashMap<String, String>; |
| 52 | 52 | ||
| 53 | #[derive(Debug)] | ||
| 53 | enum Token { | 54 | enum Token { |
| 54 | Root(Vec<Token>), | 55 | Root(Vec<Token>), |
| 55 | Fragment(String,Properties,Vec<Token>), | 56 | Fragment(String,Properties,Vec<Token>), |
| @@ -111,7 +112,7 @@ impl Crimtag { | |||
| 111 | 112 | ||
| 112 | pub fn load_static(&mut self, data: &str) -> Result<(),Box::<dyn Error>> { | 113 | pub fn load_static(&mut self, data: &str) -> Result<(),Box::<dyn Error>> { |
| 113 | let mut p = parser::Parser::new(); | 114 | let mut p = parser::Parser::new(); |
| 114 | p.parse( &data ); | 115 | println!("Parsed token tree: {:?}", p.parse( &data )? ); |
| 115 | 116 | ||
| 116 | Ok(()) | 117 | Ok(()) |
| 117 | } | 118 | } |
| @@ -146,7 +147,20 @@ mod tests { | |||
| 146 | let mut ct = Crimtag::new(); | 147 | let mut ct = Crimtag::new(); |
| 147 | if let Err(e) = ct.load_static(r#"Here is a sample | 148 | if let Err(e) = ct.load_static(r#"Here is a sample |
| 148 | [|fragment "index" theme="standard"|><html><body>Hi</body></html><|fragment|] | 149 | [|fragment "index" theme="standard"|><html><body>Hi</body></html><|fragment|] |
| 149 | That was fun!"#) { | 150 | That was fun! now a placeholder: [|fragment "placeholder"|] and now one with an implicit [|fragment "simple"|>Body [|show "content"|]<|fragment|] aoeu |
| 151 | |||
| 152 | Now with explicit outputs: | ||
| 153 | [|fragment "complex"|> | ||
| 154 | [|output "content"|> | ||
| 155 | Here's a [|show "name"|]. | ||
| 156 | <|output|] | ||
| 157 | [|output "sidebar"|> | ||
| 158 | What's up world? | ||
| 159 | <|output|] | ||
| 160 | [|output "footer"|> | ||
| 161 | Same, I guess! | ||
| 162 | <|output|] | ||
| 163 | <|fragment|]"#) { | ||
| 150 | println!("Error: {:?}", e ); | 164 | println!("Error: {:?}", e ); |
| 151 | } else { | 165 | } else { |
| 152 | println!("It finished"); | 166 | println!("It finished"); |
