Plain text compare not yet working because the text is quoted from the sexp.
This commit is contained in:
@@ -60,5 +60,9 @@ pub use lesser_element::Planning;
|
||||
pub use lesser_element::SrcBlock;
|
||||
pub use lesser_element::TableCell;
|
||||
pub use lesser_element::VerseBlock;
|
||||
pub use object::Object;
|
||||
pub use object::PlainText;
|
||||
pub use object::RegularLink;
|
||||
pub use object::TextMarkup;
|
||||
pub use source::Source;
|
||||
type Context<'r, 's> = &'r parser_context::ContextTree<'r, 's>;
|
||||
|
||||
@@ -27,9 +27,9 @@ pub enum Token<'s> {
|
||||
#[derive(Debug)]
|
||||
pub struct TextWithProperties<'s> {
|
||||
#[allow(dead_code)]
|
||||
text: &'s str,
|
||||
pub text: &'s str,
|
||||
#[allow(dead_code)]
|
||||
properties: Vec<Token<'s>>,
|
||||
pub properties: Vec<Token<'s>>,
|
||||
}
|
||||
|
||||
impl<'s> Token<'s> {
|
||||
@@ -47,6 +47,13 @@ impl<'s> Token<'s> {
|
||||
}?)
|
||||
}
|
||||
|
||||
pub fn as_text<'p>(&'p self) -> Result<&'p TextWithProperties<'s>, Box<dyn std::error::Error>> {
|
||||
Ok(match self {
|
||||
Token::TextWithProperties(body) => Ok(body),
|
||||
_ => Err(format!("wrong token type {:?}", self)),
|
||||
}?)
|
||||
}
|
||||
|
||||
pub fn as_map<'p>(
|
||||
&'p self,
|
||||
) -> Result<HashMap<&'s str, &'p Token<'s>>, Box<dyn std::error::Error>> {
|
||||
|
||||
Reference in New Issue
Block a user