#message-parser #markdown #dc #text-formatting #deltachat #deltachat-messenger

bin+lib deltachat_message_parser

email, link, hashtag, md and more - parsing for deltachat messages

7 releases (breaking)

0.9.0 Nov 16, 2023
0.8.0 Oct 9, 2023
0.7.0 Sep 4, 2023
0.6.0 Aug 13, 2023
0.3.0 Mar 4, 2022

#412 in Parser implementations

MPL-2.0 license

72KB
2K SLoC

DeltaChat Message Parser

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/

Idea behind it

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.

Coding Principles

  • many test cases
  • aim to be fast - so also benchmarks to make sure the lib stays fast enough

Recomendations:

If used for message parsing, don't parse messages that are over 10 000 chars in size to ensure performance stays excelent. (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)

Benchmarking:

cargo install cargo-criterion

benchmark:

cargo criterion

docs about benchmarking: https://bheisler.github.io/criterion.rs/book/criterion_rs.html

References

Dependencies

~1.2–2MB
~42K SLoC