-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
(Thank you, @JulesGuesnon!)
- Loading branch information
Showing
8 changed files
with
269 additions
and
83 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 |
---|---|---|
|
@@ -11,4 +11,5 @@ rust-version = "1.72.0" | |
|
||
[dependencies] | ||
nom = "7.1" | ||
nom-span = "0.1.1" | ||
thiserror = "1.0.50" |
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,23 +1,19 @@ | ||
use nom::{multi::many1, IResult}; | ||
|
||
use crate::primitives::non_empty_line; | ||
use crate::{primitives::non_empty_line, Span}; | ||
|
||
/// A block that's treated as contiguous lines of paragraph text (and subject to | ||
/// normal substitutions) (e.g., a paragraph block). | ||
#[derive(Clone, Debug, Eq, PartialEq)] | ||
pub struct SimpleBlock<'a> { | ||
/// Lines that were found. | ||
pub inlines: Vec<&'a str>, | ||
pub inlines: Vec<Span<'a>>, | ||
} | ||
|
||
impl<'a> SimpleBlock<'a> { | ||
/// Parse a byte-slice as a simple AsciiDoc block. | ||
/// | ||
/// Returns a tuple of the remaining input and the simple block. | ||
#[allow(dead_code)] // TEMPORARY | ||
pub fn from_str(i: &'a str) -> IResult<&str, Self> { | ||
pub(crate) fn parse(i: Span<'a>) -> IResult<Span, Self> { | ||
let (i, inlines) = many1(non_empty_line)(i)?; | ||
|
||
Ok((i, Self { inlines })) | ||
} | ||
} |
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
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
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
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,6 +1,13 @@ | ||
//! Contains various primitive parsing routines. | ||
//! Not part of the public API surface. | ||
|
||
mod line; | ||
#[allow(unused_imports)] | ||
pub(crate) use line::{line, non_empty_line, normalized_line}; | ||
|
||
/// Represents a subset of the overall input stream. | ||
/// | ||
/// Annotated with 1-based line and column numbers relative to the | ||
/// beginning of the overall input stream. | ||
/// | ||
/// Called `Span` because its `data` member can be consumed | ||
/// to yield another `Span` with annotations for the end of the | ||
/// syntactic element in question. | ||
pub type Span<'a> = nom_span::Spanned<&'a str>; |
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
Oops, something went wrong.