Crates.io | deltachat_message_parser |
lib.rs | deltachat_message_parser |
version | 0.11.0 |
source | src |
created_at | 2022-03-04 22:51:22.466037 |
updated_at | 2024-06-04 11:51:32.973393 |
description | email, link, hashtag, md and more - parsing for deltachat messages |
homepage | |
repository | https://github.com/deltachat/message-parser |
max_upload_size | |
id | 543702 |
size | 139,352 |
Parsing of Links, Email adresses, simple text formatting (markdown subset), user mentions, hashtags and more in DeltaChat messages.
The specification can be found in spec.md.
WASM Demo: https://deltachat.github.io/message-parser/
Have the same rich message parsing on all platforms.
The basic idea is that core can use this library to convert messages to an AST format, that can then be displayed by the UIs how they see fit, for desktop it will be converted to react elements.
Desktop already uses this package (minus the markdown, because it does not make sense to only have markdown only on one platform) as wasm module (see
./message_parser_wasm
), later this will probably be integrated into deltachat core.
If used for message parsing, don't parse messages that are over 10 000
chars in size to ensure performance stays excellent. (the lib could and should support more than that and should aim to be fast enough for it, but on slow devices or transpiled to wasm or asmjs limiting it makes sense to avoid laggy/freezed interface)
cargo install cargo-criterion
benchmark:
cargo criterion
docs about benchmarking: https://bheisler.github.io/criterion.rs/book/criterion_rs.html
These days most CPUs change their performance according to some rules to save power. To produce consistent benchmark results, CPU performance must not change between benchmarks. There are various ways to achieve this. If you've got a laptop, the first step might be connecting the AC adapter to ensure your laptop won't go on power saving mode and thus changing the CPU frequency. The next step is to change CPU frequency to a constant value under the maximum frequency CPU can handle. Because the CPUs usually can't handle the maximum possible frequency on all cores.
On Linux, you can set the CPU frequency using cpupower
utility:
cpupower frequency-set --min 3500 --max 3500 # this to set maximum and minimum to the same value
cpupower frequency-set -f 3500 # set frequency explicitly if the kernel module is available
Older discussion on introducing markdown into deltachat: https://github.com/deltachat/interface/pull/20
Feature request for message markdown in the forum: https://support.delta.chat/t/markdown-support-in-chat/159
Additionally to message parsing this crate also contains some useful functions for working with emojis.
parser::is_emoji::emoji
(rust only) - nom parser that eats one emoji
parser::is_emoji::get_first_emoji(text)
- get first emoji if text begins with an emoji
parser::is_emoji::count_emojis_if_only_contains_emoji(text)
- counts emojis in texts that contain only emojis