diff --git a/src/parser/lesser_block.rs b/src/parser/lesser_block.rs index a04e562..411edc0 100644 --- a/src/parser/lesser_block.rs +++ b/src/parser/lesser_block.rs @@ -15,9 +15,9 @@ use nom::combinator::peek; use nom::combinator::recognize; use nom::combinator::verify; use nom::multi::many_till; -use nom::multi::separated_list0; use nom::multi::separated_list1; use nom::sequence::tuple; +use nom::InputTake; use super::org_source::OrgSource; use crate::context::parser_with_context; @@ -425,13 +425,18 @@ fn _example_src_switches<'s>( let (remaining, (source, words)) = if language.is_none() { consumed(separated_list1(space1, switch_word(stop_at_parameters)))(remaining)? } else { - map( + let (remain, maybe_words) = opt(map( tuple(( space1, - consumed(separated_list0(space1, switch_word(stop_at_parameters))), + consumed(separated_list1(space1, switch_word(stop_at_parameters))), )), |(_, words)| words, - )(remaining)? + ))(remaining)?; + if let Some((source, words)) = maybe_words { + (remain, (source, words)) + } else { + (remain, (remaining.take(0), Vec::new())) + } }; let mut state = SwitchState::Normal;