Compare commits

..

No commits in common. "56348a6d54485a5cf7524a95e1085883dec2087d" and "ab337308308dcebcdea1825f8672625e30433be6" have entirely different histories.

3 changed files with 3 additions and 13 deletions

View File

@ -1,6 +1,3 @@
[[./simple.org]]
[[../simple.org]]
[[/simple.org]]
[[file:simple.org]] [[file:simple.org]]
[[file:sim ple.org]] [[file:sim ple.org]]

View File

@ -4,4 +4,3 @@
[[cat::bat]] [[cat::bat]]
#+LINK: cat dog%s #+LINK: cat dog%s
[[cat:bat]]

View File

@ -2,7 +2,6 @@ use std::borrow::Cow;
use nom::branch::alt; use nom::branch::alt;
use nom::bytes::complete::escaped; use nom::bytes::complete::escaped;
use nom::bytes::complete::is_a;
use nom::bytes::complete::tag; use nom::bytes::complete::tag;
use nom::bytes::complete::take_till1; use nom::bytes::complete::take_till1;
use nom::bytes::complete::take_until; use nom::bytes::complete::take_until;
@ -184,8 +183,8 @@ fn apply_link_templates<'b, 'g, 'r, 's>(
) -> Option<String> { ) -> Option<String> {
let (remaining, key) = opt(map( let (remaining, key) = opt(map(
tuple(( tuple((
recognize(take_until::<_, _, nom::error::Error<_>>(":")), recognize(take_until::<_, _, nom::error::Error<_>>("::")),
is_a(":"), tag("::"),
)), )),
|(key, _)| key, |(key, _)| key,
))(input) ))(input)
@ -206,7 +205,6 @@ fn apply_link_templates<'b, 'g, 'r, 's>(
let inject_value = Into::<&str>::into(remaining); let inject_value = Into::<&str>::into(remaining);
let mut ret = String::with_capacity(replacement_template.len() + inject_value.len()); let mut ret = String::with_capacity(replacement_template.len() + inject_value.len());
let mut state = ParserState::Normal; let mut state = ParserState::Normal;
let mut injected_value = false;
for c in replacement_template.chars() { for c in replacement_template.chars() {
state = match (&state, c) { state = match (&state, c) {
(ParserState::Normal, '%') => ParserState::Percent, (ParserState::Normal, '%') => ParserState::Percent,
@ -216,7 +214,6 @@ fn apply_link_templates<'b, 'g, 'r, 's>(
} }
(ParserState::Percent, 's') => { (ParserState::Percent, 's') => {
ret.push_str(inject_value); ret.push_str(inject_value);
injected_value = true;
ParserState::Normal ParserState::Normal
} }
(ParserState::Percent, _) => { (ParserState::Percent, _) => {
@ -231,15 +228,12 @@ fn apply_link_templates<'b, 'g, 'r, 's>(
} }
_ => {} _ => {}
} }
if !injected_value {
ret.push_str(inject_value);
}
Some(ret) Some(ret)
} }
fn file_path_reg<'s>(input: OrgSource<'s>) -> Res<OrgSource<'s>, PathReg<'s>> { fn file_path_reg<'s>(input: OrgSource<'s>) -> Res<OrgSource<'s>, PathReg<'s>> {
let (remaining, (raw_link, (_, path, search_option))) = consumed(tuple(( let (remaining, (raw_link, (_, path, search_option))) = consumed(tuple((
alt((tag("file:"), peek(tag(".")), peek(tag("/")))), tag("file:"),
recognize(many_till(anychar, alt((peek(tag("::")), eof)))), recognize(many_till(anychar, alt((peek(tag("::")), eof)))),
opt(map(tuple((tag("::"), rest)), |(_, search_option)| { opt(map(tuple((tag("::"), rest)), |(_, search_option)| {
search_option search_option