ftml/render/null.rs
1/*
2 * render/null.rs
3 *
4 * ftml - Library to parse Wikidot text
5 * Copyright (C) 2019-2026 Wikijump Team
6 *
7 * This program is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU Affero General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU Affero General Public License for more details.
16 *
17 * You should have received a copy of the GNU Affero General Public License
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
19 */
20
21//! A trivial renderer.
22//!
23//! This implementation of `Render` will consume any input syntax tree
24//! and produce a unit value as output.
25
26use super::prelude::*;
27
28#[derive(Debug)]
29pub struct NullRender;
30
31impl Render for NullRender {
32 type Output = ();
33
34 #[inline]
35 fn render(
36 &self,
37 _tree: &SyntaxTree,
38 _page_info: &PageInfo,
39 _settings: &WikitextSettings,
40 ) {
41 info!("Running null renderer");
42 // do nothing
43 }
44}
45
46#[test]
47fn null() {
48 use crate::layout::Layout;
49 use crate::tree::BibliographyList;
50
51 let page_info = PageInfo::dummy();
52 let settings = WikitextSettings::from_mode(WikitextMode::Page, Layout::Wikidot);
53 let result = SyntaxTree::from_element_result(
54 vec![],
55 vec![],
56 (vec![], vec![]),
57 vec![],
58 (vec![], true),
59 BibliographyList::new(),
60 0,
61 );
62 let (tree, _) = result.into();
63 NullRender.render(&tree, &page_info, &settings);
64}