Skip to content

Commit 7f29874

Browse files
committed
feat(quarto): create parser wrapper around mask
1 parent abaab67 commit 7f29874

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

harper-quarto/src/lib.rs

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,30 @@
1+
use harper_core::{
2+
Lrc, Token,
3+
parsers::{Markdown, MarkdownOptions, Mask, Parser},
4+
};
5+
16
mod masker;
27
pub use masker::QuartoMasker;
8+
9+
/// Parses a Literate Haskell document by masking out the code and considering text as Markdown.
10+
pub struct QuartoParser {
11+
inner: Lrc<dyn Parser>,
12+
}
13+
14+
impl QuartoParser {
15+
pub fn new(inner: Lrc<dyn Parser>) -> Self {
16+
Self { inner }
17+
}
18+
19+
pub fn new_markdown(markdown_options: MarkdownOptions) -> Self {
20+
Self {
21+
inner: Lrc::new(Markdown::new(markdown_options)),
22+
}
23+
}
24+
}
25+
26+
impl Parser for QuartoParser {
27+
fn parse(&self, source: &[char]) -> Vec<Token> {
28+
Mask::new(QuartoMasker, self.inner.clone()).parse(source)
29+
}
30+
}

0 commit comments

Comments
 (0)