Skip to content

Commit

Permalink
feat(Automattic#104): process links as unlintable (not as a config op…
Browse files Browse the repository at this point in the history
…tion yet)
  • Loading branch information
grantlemons committed Dec 6, 2024
1 parent df33c5f commit 72a1596
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions harper-core/src/parsers/markdown.rs
Original file line number Diff line number Diff line change
Expand Up @@ -202,9 +202,14 @@ 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 @@ -369,4 +374,15 @@ mod tests {
let tokens = Markdown.parse_str(source);
assert_eq!(tokens.iter_unlintables().count(), 1);
}

#[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 72a1596

Please sign in to comment.