Handle 3 or more slashes in the path for regular links.
This commit is contained in:
parent
bbcafef8bf
commit
120a06055f
20
org_mode_samples/object/regular_link/multiple_slashes.org
Normal file
20
org_mode_samples/object/regular_link/multiple_slashes.org
Normal file
@ -0,0 +1,20 @@
|
||||
[[file:foo]]
|
||||
[[file:/bar]]
|
||||
[[file://baz]]
|
||||
[[file:///lorem]]
|
||||
[[file:////ipsum]]
|
||||
[[file://///dolar]]
|
||||
|
||||
[[foo]]
|
||||
[[/bar]]
|
||||
[[//baz]]
|
||||
[[///lorem]]
|
||||
[[////ipsum]]
|
||||
[[/////dolar]]
|
||||
|
||||
[[https:foo]]
|
||||
[[https:/bar]]
|
||||
[[https://baz]]
|
||||
[[https:///lorem]]
|
||||
[[https:////ipsum]]
|
||||
[[https://///dolar]]
|
@ -4,11 +4,13 @@ use nom::branch::alt;
|
||||
use nom::bytes::complete::escaped;
|
||||
use nom::bytes::complete::is_a;
|
||||
use nom::bytes::complete::tag;
|
||||
use nom::bytes::complete::take;
|
||||
use nom::bytes::complete::take_till1;
|
||||
use nom::bytes::complete::take_until;
|
||||
use nom::character::complete::anychar;
|
||||
use nom::combinator::consumed;
|
||||
use nom::combinator::eof;
|
||||
use nom::combinator::flat_map;
|
||||
use nom::combinator::map;
|
||||
use nom::combinator::map_parser;
|
||||
use nom::combinator::opt;
|
||||
@ -16,6 +18,7 @@ use nom::combinator::peek;
|
||||
use nom::combinator::recognize;
|
||||
use nom::combinator::rest;
|
||||
use nom::combinator::verify;
|
||||
use nom::multi::many1_count;
|
||||
use nom::multi::many_till;
|
||||
use nom::sequence::tuple;
|
||||
use nom::InputTake;
|
||||
@ -261,7 +264,7 @@ fn file_path_reg<'b, 'g, 'r, 's>(
|
||||
});
|
||||
let parser_context = context.with_additional_node(&parser_context);
|
||||
|
||||
let (remaining, (raw_link, (application, path, search_option))) = consumed(tuple((
|
||||
let (remaining, (raw_link, (application, _, path, search_option))) = consumed(tuple((
|
||||
alt((
|
||||
map(
|
||||
tuple((
|
||||
@ -277,6 +280,10 @@ fn file_path_reg<'b, 'g, 'r, 's>(
|
||||
map(peek(tag(".")), |_| None),
|
||||
map(peek(tag("/")), |_| None),
|
||||
)),
|
||||
opt(flat_map(
|
||||
peek(map(verify(many1_count(tag("/")), |c| *c >= 3), |c| c - 1)),
|
||||
take,
|
||||
)),
|
||||
parser_with_context!(text_until_exit)(&parser_context),
|
||||
opt(map(
|
||||
tuple((
|
||||
|
Loading…
Reference in New Issue
Block a user