Skip to content

Commit

Permalink
feat(#104): process links as unlintable (not as a config option yet)
Browse files Browse the repository at this point in the history
  • Loading branch information
grantlemons committed Oct 17, 2024
1 parent c5bb790 commit dd038a9
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion harper-core/src/parsers/markdown.rs
Original file line number Diff line number Diff line change
Expand Up @@ -202,9 +202,15 @@ impl Parser for Markdown {
});
continue;
}
if matches!(tag, Tag::Link { .. }) {
tokens.push(Token {
span: Span::new_with_len(traversed_chars, text.chars().count()),
kind: TokenKind::Unlintable,
});
continue;
}

if !(matches!(tag, Tag::Paragraph)
|| matches!(tag, Tag::Link { .. })
|| matches!(tag, Tag::Heading { .. })
|| matches!(tag, Tag::Item)
|| matches!(tag, Tag::TableCell)
Expand Down Expand Up @@ -353,4 +359,15 @@ mod tests {

assert!(matches!(token_kinds.as_slice(), &[TokenKind::Word(_)]))
}

#[test]
fn link_title_unlintable() {
let source = r#"[elijah-potter/harper](https://github.com/elijah-potter/harper)"#;
let tokens = Markdown.parse_str(source);
let token_kinds = tokens.iter().map(|t| t.kind).collect::<Vec<_>>();

dbg!(&token_kinds);

assert!(matches!(token_kinds.as_slice(), &[TokenKind::Unlintable]))
}
}

0 comments on commit dd038a9

Please sign in to comment.