Skip to content

Commit

Permalink
inlines: clean up nested lets.
Browse files Browse the repository at this point in the history
  • Loading branch information
kivikakk committed Jul 10, 2024
1 parent e5eeb57 commit 2f4faec
Showing 1 changed file with 12 additions and 15 deletions.
27 changes: 12 additions & 15 deletions src/parser/inlines.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1221,23 +1221,20 @@ impl<'a, 'r, 'o, 'd, 'i, 'c, 'subj> Subject<'a, 'r, 'o, 'd, 'i, 'c, 'subj> {

#[cfg(feature = "shortcodes")]
pub fn handle_shortcodes_colon(&mut self) -> Option<&'a AstNode<'a>> {
if let Some(matchlen) = scanners::shortcode(&self.input[self.pos + 1..]) {
let shortcode = unsafe {
str::from_utf8_unchecked(&self.input[self.pos + 1..self.pos + 1 + matchlen - 1])
};
let matchlen = scanners::shortcode(&self.input[self.pos + 1..])?;

if let Ok(nsc) = NodeShortCode::try_from(shortcode) {
self.pos += 1 + matchlen;
let inl = self.make_inline(
NodeValue::ShortCode(nsc),
self.pos - 1 - matchlen,
self.pos - 1,
);
return Some(inl);
}
}
let shortcode = unsafe {
str::from_utf8_unchecked(&self.input[self.pos + 1..self.pos + 1 + matchlen - 1])
};

None
let nsc = NodeShortCode::try_from(shortcode).ok()?;
self.pos += 1 + matchlen;

Some(self.make_inline(
NodeValue::ShortCode(nsc),
self.pos - 1 - matchlen,
self.pos - 1,
))
}

pub fn handle_autolink_with<F>(
Expand Down

0 comments on commit 2f4faec

Please sign in to comment.