matrix-rust-sdk
matrix-rust-sdk copied to clipboard
Add helpers to generate pills
Is your feature request related to a problem? Please describe. When building a message, it would be nice if there were helpers to generate pills, so references to rooms and users look nice.
Describe the solution you'd like Either something that parses references to rooms/users out of a message and turns them into pills, or helper functions that generate the correct HTML for a pill, and can be concatenated into a message.
Describe alternatives you've considered It's straightforward to do manually, but would be nicer if the library make it easy.
Additional context I asked if any helpers were available in the Matrix room and was told it should be relatively easy to add.
I would like having helpers directly on RoomAliasId / RoomId / UserId in Ruma. Where is the format documented?
I believe https://spec.matrix.org/unstable/client-server-api/#user-room-and-group-mentions is the docs, even though it doesn't call them pills.
Seems like for the full pill, even though clients that support them natively don't show the <a>s inner text anyways, one should fill it with a display name of sorts. This means there probably is little sense in having this on UserId and friends which are not aware of these things. I'll add .matrix_to_url() methods though with example that shows how to construct the mention / pill HTML.
Ruma now contains helper methods on UserId, RoomId and RoomAliasId to generate the URLs (though not in a crates.io release yet). Generating the pill HTML can be built on top of that (after #357).
Hey @gnunicorn, @jplatte, could I take this issue as my first issue? In order to set up a test setup, I need a dev account or something in Matrix.org or I can just use my original account ? Also, is the wiki all good in order to set up a dev environnement ?
You don't need to set up anything special, as far as I remember pills are just some special HTML link. This could be done using unit tests alone.
If you really need a real world place to test this you can create a test room on your main account.
Not sure what you mean by the wiki being all good, could you clarify?
In order to test the SDK I was thinking I need to install the weechat-matrix-rs plugin in Weechat, it looks pretty simple, there are not much steps actually. But do I even need the weechat-matrix-rs plugin to test the SDK ? Maybe I just don't need it
From where the unit tests are being run ? Are they GitHub Actions or are they like Rust unit tests, ran with cargo test something alike?
cargo test will run the unit tests, there's also cargo xtask which helps you run them in different configurations. Those same unit tests are of course run as part of our CI in Github Actions.