Remove all whitespace from search option if it contains any line breaks and handle triple+ slashes for file links.

This commit is contained in:
Tom Alexander
2023-10-08 13:23:12 -04:00
parent d987b9b75b
commit ba55e0df4f
3 changed files with 55 additions and 1 deletions

View File

@@ -1,13 +1,17 @@
use nom::branch::alt;
use nom::bytes::complete::tag;
use nom::bytes::complete::take;
use nom::bytes::complete::take_until;
use nom::combinator::consumed;
use nom::combinator::flat_map;
use nom::combinator::map;
use nom::combinator::map_parser;
use nom::combinator::opt;
use nom::combinator::peek;
use nom::combinator::recognize;
use nom::combinator::rest;
use nom::combinator::verify;
use nom::multi::many1_count;
use nom::sequence::tuple;
use super::org_source::OrgSource;
@@ -114,6 +118,10 @@ fn parse_file_angle_link<'b, 'g, 'r, 's>(
)),
|(_, application, _)| application,
)(input)?;
let (remaining, _) = opt(flat_map(
peek(map(verify(many1_count(tag("/")), |c| *c >= 3), |c| c - 1)),
take,
))(remaining)?;
let (remaining, path) = alt((take_until("::"), rest))(remaining)?;
let (remaining, search_option) = opt(map(tuple((tag("::"), rest)), |(_, search_option)| {
search_option