diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e0f246c..beaf9e0 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -17,7 +17,7 @@ jobs: - uses: actions-rs/toolchain@v1 with: profile: minimal - toolchain: 1.77.2 + toolchain: 1.85.0 override: true - run: rustup component add rustfmt - uses: actions-rs/cargo@v1 @@ -31,7 +31,7 @@ jobs: - uses: actions/checkout@v2 - uses: actions-rs/toolchain@v1 with: - toolchain: 1.77.2 + toolchain: 1.85.0 components: clippy override: true - uses: actions-rs/clippy-check@v1 @@ -68,9 +68,9 @@ jobs: matrix: include: - os: ubuntu-latest - rust: 1.77.2 + rust: 1.85.0 - os: windows-latest - rust: 1.77.2 + rust: 1.85.0 runs-on: ${{ matrix.os }} steps: - uses: actions/checkout@main diff --git a/CHANGELOG.md b/CHANGELOG.md index 27bd9d9..9ce8cdd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,8 @@ ## Unreleased +- update rust toolchain version to match MSRV of chatmail core: 1.85.0 + ## 0.14.1 - Allow country TLDs in scheme-less links - allow country TLDs in scheme-less links @@ -62,7 +64,7 @@ - upgraded nom to 7 - The following generic schemes (schemes that don't end in `://`) get linkified now: `mailto:`, `news:`, `feed:`, `tel:`, `sms:`, `geo:`, `maps:`, `bitcoin:`, `bitcoincash:`, `eth:`, `ethereum:`, `magnet:` -- added `scheme` property to `LinkDestination` +- added `scheme` property to `LinkDestination` ## 0.7.0 - All the Hashtags diff --git a/docs.md b/docs.md index 1f14f09..9f02a9a 100644 --- a/docs.md +++ b/docs.md @@ -47,3 +47,13 @@ The third priority is binary size, so be careful with huge extra libraries, mayb 7. `cd message_parser_wasm/` 8. `wasm-pack build --scope deltachat --target web` 9. `wasm-pack publish --target web` + + +### Reorder imports +We use [`group_imports="StdExternalCrate"`](https://github.com/rust-lang/rustfmt/blob/master/Configurations.md#group_imports) to group imports, +which requires the nightly version of the rust toolchain, +so you need to run the following comand to fix the order of the imports: + +``` +cargo +nightly fmt -- --config=group_imports="StdExternalCrate" +``` diff --git a/rust-toolchain b/rust-toolchain index 369f996..f288d11 100644 --- a/rust-toolchain +++ b/rust-toolchain @@ -1 +1 @@ -1.77.2 +1.85.0 diff --git a/src/parser/is_emoji.rs b/src/parser/is_emoji.rs index 456fd25..7a5c029 100644 --- a/src/parser/is_emoji.rs +++ b/src/parser/is_emoji.rs @@ -243,20 +243,11 @@ mod emoji_test { #[test] fn test_string_contains_only_emojis_and_count() { assert_eq!(count_emojis_if_only_contains_emoji("#️⃣"), Some(1)); - assert_eq!( - count_emojis_if_only_contains_emoji("πŸ‘©πŸ½β€β€οΈβ€πŸ‘¨πŸ½Hashtag"), - None - ); + assert_eq!(count_emojis_if_only_contains_emoji("πŸ‘©πŸ½β€β€οΈβ€πŸ‘¨πŸ½Hashtag"), None); assert_eq!(count_emojis_if_only_contains_emoji("❀️‍πŸ”₯"), Some(1)); assert_eq!(count_emojis_if_only_contains_emoji("πŸ‘©πŸ½β€β€οΈβ€πŸ‘¨πŸ½"), Some(1)); - assert_eq!( - count_emojis_if_only_contains_emoji("πŸ‘©πŸ½β€β€οΈβ€πŸ‘¨πŸ½πŸ‘©πŸ½β€β€οΈβ€πŸ‘¨πŸ½"), - Some(2) - ); - assert_eq!( - count_emojis_if_only_contains_emoji("πŸ‘©πŸ½β€β€οΈβ€πŸ‘¨πŸ½β€οΈβ€πŸ”₯πŸ‘©πŸ½β€β€οΈβ€πŸ‘¨πŸ½"), - Some(3) - ); + assert_eq!(count_emojis_if_only_contains_emoji("πŸ‘©πŸ½β€β€οΈβ€πŸ‘¨πŸ½πŸ‘©πŸ½β€β€οΈβ€πŸ‘¨πŸ½"), Some(2)); + assert_eq!(count_emojis_if_only_contains_emoji("πŸ‘©πŸ½β€β€οΈβ€πŸ‘¨πŸ½β€οΈβ€πŸ”₯πŸ‘©πŸ½β€β€οΈβ€πŸ‘¨πŸ½"), Some(3)); // hair color assert_eq!(count_emojis_if_only_contains_emoji("πŸ‘¨β€πŸ¦°"), Some(1)); assert_eq!(count_emojis_if_only_contains_emoji("πŸ‘¨β€πŸ¦³"), Some(1)); diff --git a/src/parser/link_url/ip/ipv6.rs b/src/parser/link_url/ip/ipv6.rs index 7e0b05c..00bcbcc 100644 --- a/src/parser/link_url/ip/ipv6.rs +++ b/src/parser/link_url/ip/ipv6.rs @@ -8,9 +8,8 @@ use nom::{ IResult, }; -use crate::parser::{parse_from_text::base_parsers::CustomError, utils::is_hex_digit}; - use super::ipv4::ipv4; +use crate::parser::{parse_from_text::base_parsers::CustomError, utils::is_hex_digit}; fn h16(input: &str) -> IResult<&str, &str, CustomError<&str>> { take_while_m_n(1, 4, is_hex_digit)(input) diff --git a/src/parser/link_url/parse_link.rs b/src/parser/link_url/parse_link.rs index d9d4d97..3ecd489 100644 --- a/src/parser/link_url/parse_link.rs +++ b/src/parser/link_url/parse_link.rs @@ -10,6 +10,11 @@ use nom::{ IResult, Slice, }; +use super::{ + allowed_tlds::check_if_tld_is_allowed, + parenthesis_counter::count_chars_in_complete_parenthesis, + punycode_warning::get_puny_code_warning, +}; use crate::parser::{ link_url::{ ip::{ip_literal::ip_literal, ipv4::ipv4}, @@ -22,12 +27,6 @@ use crate::parser::{ }, }; -use super::{ - allowed_tlds::check_if_tld_is_allowed, - parenthesis_counter::count_chars_in_complete_parenthesis, - punycode_warning::get_puny_code_warning, -}; - /// determines which generic schemes (without '://') get linkifyed fn is_allowed_generic_scheme(scheme: &str) -> bool { matches!( diff --git a/src/parser/parse_from_text/desktop_subset.rs b/src/parser/parse_from_text/desktop_subset.rs index b525efd..786c325 100644 --- a/src/parser/parse_from_text/desktop_subset.rs +++ b/src/parser/parse_from_text/desktop_subset.rs @@ -7,12 +7,11 @@ use nom::{ IResult, }; -use crate::parser::LinkDestination; - use super::base_parsers::CustomError; use super::markdown_elements::{delimited_email_address, delimited_link}; use super::text_elements::parse_text_element; use super::Element; +use crate::parser::LinkDestination; // [labeled](https://link) pub(crate) fn labeled_link(input: &str) -> IResult<&str, Element, CustomError<&str>> { diff --git a/src/parser/parse_from_text/hashtag_content_char_ranges.rs b/src/parser/parse_from_text/hashtag_content_char_ranges.rs index 0d816ec..07264d7 100644 --- a/src/parser/parse_from_text/hashtag_content_char_ranges.rs +++ b/src/parser/parse_from_text/hashtag_content_char_ranges.rs @@ -1,6 +1,7 @@ -use crate::parser::utils::is_in_one_of_ranges; use std::ops::RangeInclusive; +use crate::parser::utils::is_in_one_of_ranges; + const NUMBER_OF_RANGES: usize = 850; /* @@ -882,9 +883,10 @@ pub(crate) fn hashtag_content_char(c: char) -> bool { #[cfg(test)] mod test { + use std::ops::RangeInclusive; + use crate::parser::parse_from_text::hashtag_content_char_ranges::hashtag_content_char; use crate::parser::utils::is_in_one_of_ranges; - use std::ops::RangeInclusive; #[test] fn test_range_function() { diff --git a/src/parser/parse_from_text/text_elements.rs b/src/parser/parse_from_text/text_elements.rs index f7edab0..cf5f9a9 100644 --- a/src/parser/parse_from_text/text_elements.rs +++ b/src/parser/parse_from_text/text_elements.rs @@ -1,8 +1,3 @@ -/// nom parsers for text elements -use crate::parser::link_url::LinkDestination; - -use super::hashtag_content_char_ranges::hashtag_content_char; -use super::Element; use nom::{ bytes::{ complete::{tag, take, take_while, take_while1}, @@ -15,6 +10,10 @@ use nom::{ }; use super::base_parsers::CustomError; +use super::hashtag_content_char_ranges::hashtag_content_char; +use super::Element; +/// nom parsers for text elements +use crate::parser::link_url::LinkDestination; fn linebreak(input: &str) -> IResult<&str, char, CustomError<&str>> { char('\n')(input) diff --git a/tests/text_to_ast/desktop_set.rs b/tests/text_to_ast/desktop_set.rs index 9614da8..8328acb 100644 --- a/tests/text_to_ast/desktop_set.rs +++ b/tests/text_to_ast/desktop_set.rs @@ -1,6 +1,7 @@ -use super::*; use deltachat_message_parser::parser::{link_url::PunycodeWarning, parse_desktop_set}; +use super::*; + #[test] fn do_not_parse_markdown_elements() { assert_eq!( diff --git a/tests/text_to_ast/markdown.rs b/tests/text_to_ast/markdown.rs index b50ba8c..334f194 100644 --- a/tests/text_to_ast/markdown.rs +++ b/tests/text_to_ast/markdown.rs @@ -1,6 +1,7 @@ -use super::*; use deltachat_message_parser::parser::parse_markdown_text; +use super::*; + #[test] fn bold_capitalized_command_suggestion() { let input = "**/TELL** world"; diff --git a/tests/text_to_ast/text_only.rs b/tests/text_to_ast/text_only.rs index 9f349ec..635d3f0 100644 --- a/tests/text_to_ast/text_only.rs +++ b/tests/text_to_ast/text_only.rs @@ -1,6 +1,7 @@ -use super::*; use deltachat_message_parser::parser::parse_only_text; +use super::*; + #[test] fn do_not_parse_markdown_elements() { assert_eq!(