diff --git a/src/utils/mod.rs b/src/utils/mod.rs index aacdb1c7..df997d5e 100644 --- a/src/utils/mod.rs +++ b/src/utils/mod.rs @@ -69,7 +69,7 @@ pub fn id_from_content(content: &str) -> String { fn adjust_links<'a>(event: Event<'a>, with_base: &str) -> Event<'a> { lazy_static! { static ref HTTP_LINK: Regex = Regex::new("^https?://").unwrap(); - static ref MD_LINK: Regex = Regex::new("(?P.*).md(?P#.*)?").unwrap(); + static ref MD_LINK: Regex = Regex::new(r"(?P.*)\.md(?P#.*)?").unwrap(); } match event { @@ -230,6 +230,12 @@ mod tests { render_markdown("[example_anchor](example.md#anchor)", false), "

example_anchor

\n" ); + + // this anchor contains 'md' inside of it + assert_eq!( + render_markdown("[phantom data](foo.html#phantomdata)", false), + "

phantom data

\n" + ); } #[test]