1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
mod parser;
pub use self::parser::{Parser, PluginParser};
use dashmap::DashMap;
use notedown_ast::ASTNode;
use notedown_error::{NoteError, Result};
use std::{
collections::BTreeSet,
fmt::{Debug, Display, Formatter},
hash::{Hash, Hasher},
};
#[derive(Debug, Default)]
pub struct PluginSystem {
parsers: DashMap<String, PluginParser>,
}
impl PluginSystem {
#[inline]
pub fn register_parser(&self, new: PluginParser) -> Option<PluginParser> {
self.parsers.insert(new.name.to_owned(), new)
}
pub fn get_parser(&self, name: &str) -> Option<Parser> {
match self.parsers.get(name) {
None => None,
Some(s) => Some(s.parser),
}
}
pub fn get_parser_by_extension(&self, e: &str) -> Option<Parser> {
for parser in &self.parsers {
if parser.name.contains(e) {
return Some(parser.parser);
}
}
return None;
}
}
#[derive(Debug, Clone)]
pub struct ExtendedPackage {}