-
Notifications
You must be signed in to change notification settings - Fork 94
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(quarto): create parser wrapper around mask
- Loading branch information
1 parent
abaab67
commit 7f29874
Showing
1 changed file
with
28 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,30 @@ | ||
use harper_core::{ | ||
Lrc, Token, | ||
parsers::{Markdown, MarkdownOptions, Mask, Parser}, | ||
}; | ||
|
||
mod masker; | ||
pub use masker::QuartoMasker; | ||
|
||
/// Parses a Literate Haskell document by masking out the code and considering text as Markdown. | ||
pub struct QuartoParser { | ||
inner: Lrc<dyn Parser>, | ||
} | ||
|
||
impl QuartoParser { | ||
pub fn new(inner: Lrc<dyn Parser>) -> Self { | ||
Self { inner } | ||
} | ||
|
||
pub fn new_markdown(markdown_options: MarkdownOptions) -> Self { | ||
Self { | ||
inner: Lrc::new(Markdown::new(markdown_options)), | ||
} | ||
} | ||
} | ||
|
||
impl Parser for QuartoParser { | ||
fn parse(&self, source: &[char]) -> Vec<Token> { | ||
Mask::new(QuartoMasker, self.inner.clone()).parse(source) | ||
} | ||
} |