Skip to content

Commit

Permalink
fix(panic): when documents include emojis
Browse files Browse the repository at this point in the history
  • Loading branch information
elijah-potter committed Mar 8, 2024
1 parent 70e0fd4 commit bc932c5
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 2 deletions.
11 changes: 10 additions & 1 deletion harper-core/src/lexing/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ pub fn lex_token(source: &[char]) -> Option<FoundToken> {
lex_number,
lex_url,
lex_email_address,
lex_word
lex_word,
lex_catch
];

for lexer in lexers {
Expand Down Expand Up @@ -174,3 +175,11 @@ fn lex_quote(source: &[char]) -> Option<FoundToken> {
None
}
}

/// Covers cases not covered by the other lints.
fn lex_catch(_source: &[char]) -> Option<FoundToken> {
Some(FoundToken {
next_index: 1,
token: TokenKind::Unlintable
})
}
2 changes: 1 addition & 1 deletion harper-core/src/linting/lint_group.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ create_lint_group_config!(
AnA => true,
SentenceCapitalization => true,
UnclosedQuotes => true,
WrongQuotes => true,
WrongQuotes => false,
LongSentences => true,
RepeatedWords => true,
Spaces => true,
Expand Down
13 changes: 13 additions & 0 deletions harper-core/src/parsers/markdown.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,3 +97,16 @@ impl Parser for Markdown {
tokens
}
}

#[cfg(test)]
mod tests {
use super::super::StrParser;
use super::Markdown;

#[test]
fn survives_emojis() {
let source = r#"🤷."#;

Markdown.parse_str(source);
}
}

0 comments on commit bc932c5

Please sign in to comment.