mirror of
https://github.com/crate-ci/typos.git
synced 2024-12-22 15:42:23 -05:00
parent
a329a99ec7
commit
0c49c3ea2b
1 changed files with 12 additions and 4 deletions
|
@ -216,7 +216,14 @@ mod parser {
|
||||||
<T as nom::InputTakeAtPosition>::Item: AsChar + Copy,
|
<T as nom::InputTakeAtPosition>::Item: AsChar + Copy,
|
||||||
<T as nom::InputIter>::Item: AsChar + Copy,
|
<T as nom::InputIter>::Item: AsChar + Copy,
|
||||||
{
|
{
|
||||||
terminated(
|
fn is_sep(c: impl AsChar) -> bool {
|
||||||
|
let c = c.as_char();
|
||||||
|
// Avoid markdown throwing off our ordinal detection
|
||||||
|
['_'].contains(&c)
|
||||||
|
}
|
||||||
|
|
||||||
|
recognize(tuple((
|
||||||
|
take_while(is_sep),
|
||||||
take_while1(is_dec_digit),
|
take_while1(is_dec_digit),
|
||||||
alt((
|
alt((
|
||||||
pair(char('s'), char('t')),
|
pair(char('s'), char('t')),
|
||||||
|
@ -224,7 +231,8 @@ mod parser {
|
||||||
pair(char('r'), char('d')),
|
pair(char('r'), char('d')),
|
||||||
pair(char('t'), char('h')),
|
pair(char('t'), char('h')),
|
||||||
)),
|
)),
|
||||||
)(input)
|
take_while(is_sep),
|
||||||
|
)))(input)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn dec_literal<T>(input: T) -> IResult<T, T>
|
fn dec_literal<T>(input: T) -> IResult<T, T>
|
||||||
|
@ -935,10 +943,10 @@ mod test {
|
||||||
fn tokenize_ignore_ordinal() {
|
fn tokenize_ignore_ordinal() {
|
||||||
let parser = TokenizerBuilder::new().build();
|
let parser = TokenizerBuilder::new().build();
|
||||||
|
|
||||||
let input = "Hello 1st 2nd 3rd 4th World";
|
let input = "Hello 1st 2nd 3rd 4th __5th__ World";
|
||||||
let expected: Vec<Identifier> = vec![
|
let expected: Vec<Identifier> = vec![
|
||||||
Identifier::new_unchecked("Hello", Case::None, 0),
|
Identifier::new_unchecked("Hello", Case::None, 0),
|
||||||
Identifier::new_unchecked("World", Case::None, 22),
|
Identifier::new_unchecked("World", Case::None, 30),
|
||||||
];
|
];
|
||||||
let actual: Vec<_> = parser.parse_bytes(input.as_bytes()).collect();
|
let actual: Vec<_> = parser.parse_bytes(input.as_bytes()).collect();
|
||||||
assert_eq!(expected, actual);
|
assert_eq!(expected, actual);
|
||||||
|
|
Loading…
Reference in a new issue