Skip to content

Commit

Permalink
feat(quarto): create parser wrapper around mask
Browse files Browse the repository at this point in the history
  • Loading branch information
grantlemons committed Feb 25, 2025
1 parent abaab67 commit 7f29874
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions harper-quarto/src/lib.rs
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)
}
}

0 comments on commit 7f29874

Please sign in to comment.