Rename contents to source to match objects that need to store a separate source.
This commit is contained in:
parent
448dcfac72
commit
89758721ed
@ -30,7 +30,7 @@ pub fn bold<'r, 's>(context: Context<'r, 's>, i: &'s str) -> Res<&'s str, Bold<'
|
|||||||
let (remaining, captured) = recognize(tuple((bold_start, |i| {
|
let (remaining, captured) = recognize(tuple((bold_start, |i| {
|
||||||
context_many_till(&parser_context, text_element, context_bold_end)(i)
|
context_many_till(&parser_context, text_element, context_bold_end)(i)
|
||||||
})))(i)?;
|
})))(i)?;
|
||||||
let ret = Bold { contents: captured };
|
let ret = Bold { source: captured };
|
||||||
Ok((remaining, ret))
|
Ok((remaining, ret))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -27,7 +27,7 @@ pub fn link<'r, 's>(context: Context<'r, 's>, i: &'s str) -> Res<&'s str, Link<'
|
|||||||
let (remaining, captured) = recognize(tuple((link_start, |i| {
|
let (remaining, captured) = recognize(tuple((link_start, |i| {
|
||||||
context_many_till(&parser_context, text_element, context_link_end)(i)
|
context_many_till(&parser_context, text_element, context_link_end)(i)
|
||||||
})))(i)?;
|
})))(i)?;
|
||||||
let ret = Link { contents: captured };
|
let ret = Link { source: captured };
|
||||||
Ok((remaining, ret))
|
Ok((remaining, ret))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -21,19 +21,19 @@ use super::token::TextElement;
|
|||||||
use super::Context;
|
use super::Context;
|
||||||
|
|
||||||
pub fn line_break(input: &str) -> Res<&str, LineBreak> {
|
pub fn line_break(input: &str) -> Res<&str, LineBreak> {
|
||||||
map(line_ending, |s: &str| LineBreak { contents: s })(input)
|
map(line_ending, |s: &str| LineBreak { source: s })(input)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn space(input: &str) -> Res<&str, Space> {
|
fn space(input: &str) -> Res<&str, Space> {
|
||||||
map(space1, |s: &str| Space { contents: s })(input)
|
map(space1, |s: &str| Space { source: s })(input)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn span(input: &str) -> Res<&str, Span> {
|
fn span(input: &str) -> Res<&str, Span> {
|
||||||
map(alphanumeric1, |s: &str| Span { contents: s })(input)
|
map(alphanumeric1, |s: &str| Span { source: s })(input)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn symbol(symbol_tag: &'static str) -> impl for<'a> Fn(&'a str) -> Res<&'a str, Symbol<'a>> {
|
pub fn symbol(symbol_tag: &'static str) -> impl for<'a> Fn(&'a str) -> Res<&'a str, Symbol<'a>> {
|
||||||
move |i: &str| map(tag(symbol_tag), |s: &str| Symbol { contents: s })(i)
|
move |i: &str| map(tag(symbol_tag), |s: &str| Symbol { source: s })(i)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// A line containing only whitespace and then a line break
|
/// A line containing only whitespace and then a line break
|
||||||
@ -45,7 +45,7 @@ pub fn blank_line(input: &str) -> Res<&str, BlankLine> {
|
|||||||
map(space, TextElement::Space),
|
map(space, TextElement::Space),
|
||||||
map(line_break, TextElement::LineBreak),
|
map(line_break, TextElement::LineBreak),
|
||||||
)),
|
)),
|
||||||
|contents| BlankLine { contents },
|
|contents| BlankLine { source: contents },
|
||||||
)(input)
|
)(input)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -28,42 +28,42 @@ pub enum TextElement<'a> {
|
|||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct Span<'a> {
|
pub struct Span<'a> {
|
||||||
pub contents: &'a str,
|
pub source: &'a str,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct Space<'a> {
|
pub struct Space<'a> {
|
||||||
pub contents: &'a str,
|
pub source: &'a str,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct LineBreak<'a> {
|
pub struct LineBreak<'a> {
|
||||||
pub contents: &'a str,
|
pub source: &'a str,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct Symbol<'a> {
|
pub struct Symbol<'a> {
|
||||||
pub contents: &'a str,
|
pub source: &'a str,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct BlankLine<'a> {
|
pub struct BlankLine<'a> {
|
||||||
pub contents: &'a str,
|
pub source: &'a str,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct Sequence<'a> {
|
pub struct Sequence<'a> {
|
||||||
pub contents: &'a str,
|
pub source: &'a str,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct Bold<'a> {
|
pub struct Bold<'a> {
|
||||||
pub contents: &'a str,
|
pub source: &'a str,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct Link<'a> {
|
pub struct Link<'a> {
|
||||||
pub contents: &'a str,
|
pub source: &'a str,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
@ -80,12 +80,12 @@ pub trait Source<'a> {
|
|||||||
impl<'a> Source<'a> for TextElement<'a> {
|
impl<'a> Source<'a> for TextElement<'a> {
|
||||||
fn get_source(&'a self) -> &'a str {
|
fn get_source(&'a self) -> &'a str {
|
||||||
match self {
|
match self {
|
||||||
TextElement::Span(elem) => elem.contents,
|
TextElement::Span(elem) => elem.source,
|
||||||
TextElement::Space(elem) => elem.contents,
|
TextElement::Space(elem) => elem.source,
|
||||||
TextElement::LineBreak(elem) => elem.contents,
|
TextElement::LineBreak(elem) => elem.source,
|
||||||
TextElement::Symbol(elem) => elem.contents,
|
TextElement::Symbol(elem) => elem.source,
|
||||||
TextElement::Bold(elem) => elem.contents,
|
TextElement::Bold(elem) => elem.source,
|
||||||
TextElement::Link(elem) => elem.contents,
|
TextElement::Link(elem) => elem.source,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user