pub fn parse_variable(input: Span<'_>) -> IResult<Span<'_>, Span<'_>>Expand description
Parse a template placeholder variable. This is a £ followed by a variable
name.
§Examples
Variables must start with a £.
use blogs_md_easy::{parse_variable, Span};
let input = Span::new("£variable");
let (_, variable) = parse_variable(input).unwrap();
assert_eq!(variable.fragment(), &"variable");In keeping with what people are used to, it is also possible to use a $.
use blogs_md_easy::{parse_variable, Span};
let input = Span::new("$variable");
let (_, variable) = parse_variable(input).unwrap();
assert_eq!(variable.fragment(), &"variable");Failing to start with a £ will return an error.
use blogs_md_easy::{parse_variable, Span};
let input = Span::new("variable");
let variable = parse_variable(input);
assert!(variable.is_err());