m->d support spoilers
This commit is contained in:
parent
56fe710392
commit
0d9191ed5c
3 changed files with 42 additions and 3 deletions
|
@ -57,6 +57,16 @@ turndownService.addRule("blockquote", {
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
turndownService.addRule("spoiler", {
|
||||||
|
filter: function (node, options) {
|
||||||
|
return node.hasAttribute("data-mx-spoiler")
|
||||||
|
},
|
||||||
|
|
||||||
|
replacement: function (content, node) {
|
||||||
|
return "||" + content + "||"
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
turndownService.addRule("inlineLink", {
|
turndownService.addRule("inlineLink", {
|
||||||
filter: function (node, options) {
|
filter: function (node, options) {
|
||||||
return (
|
return (
|
||||||
|
|
|
@ -120,6 +120,36 @@ test("event2message: basic html is converted to markdown", async t => {
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
test("event2message: spoilers work", async t => {
|
||||||
|
t.deepEqual(
|
||||||
|
await eventToMessage({
|
||||||
|
content: {
|
||||||
|
msgtype: "m.text",
|
||||||
|
body: "wrong body",
|
||||||
|
format: "org.matrix.custom.html",
|
||||||
|
formatted_body: `this <strong>is</strong> a <span data-mx-spoiler><em>test</em></span> of <span data-mx-spoiler="">spoilers</span>`
|
||||||
|
},
|
||||||
|
event_id: "$g07oYSZFWBkxohNEfywldwgcWj1hbhDzQ1sBAKvqOOU",
|
||||||
|
origin_server_ts: 1688301929913,
|
||||||
|
room_id: "!kLRqKKUQXcibIMtOpl:cadence.moe",
|
||||||
|
sender: "@cadence:cadence.moe",
|
||||||
|
type: "m.room.message",
|
||||||
|
unsigned: {
|
||||||
|
age: 405299
|
||||||
|
}
|
||||||
|
}),
|
||||||
|
{
|
||||||
|
messagesToDelete: [],
|
||||||
|
messagesToEdit: [],
|
||||||
|
messagesToSend: [{
|
||||||
|
username: "cadence [they]",
|
||||||
|
content: "this **is** a ||_test_|| of ||spoilers||",
|
||||||
|
avatar_url: undefined
|
||||||
|
}]
|
||||||
|
}
|
||||||
|
)
|
||||||
|
})
|
||||||
|
|
||||||
test("event2message: markdown syntax is escaped", async t => {
|
test("event2message: markdown syntax is escaped", async t => {
|
||||||
t.deepEqual(
|
t.deepEqual(
|
||||||
await eventToMessage({
|
await eventToMessage({
|
||||||
|
|
5
notes.md
5
notes.md
|
@ -3,13 +3,12 @@
|
||||||
## Known issues
|
## Known issues
|
||||||
|
|
||||||
- m->d attachments do not work
|
- m->d attachments do not work
|
||||||
- m->d edits do not work
|
|
||||||
- m->d spoilers do not work
|
|
||||||
- d->m support the rest of the attachments by reading the matrix spec instead of the current approach of whitelisting mime types
|
- d->m support the rest of the attachments by reading the matrix spec instead of the current approach of whitelisting mime types
|
||||||
- d->m emojis do not work at all (inline chat, single emoji size, reactions, bridged state)
|
- d->m emojis do not work at all (inline chat, single emoji size, reactions, bridged state)
|
||||||
- m->d code blocks have slightly too much spacing
|
- m->d code blocks have slightly too much spacing
|
||||||
- m->d some reactions don't work because of the variation selector
|
- m->d some reactions don't work because of the variation selector
|
||||||
- <--> check whether I implemented deletions
|
- d->m check whether I implemented deletions
|
||||||
|
- m->d deletions
|
||||||
- rooms will be set up even if the bridge does not have permission for them, then break when it restarts and tries to reach messages
|
- rooms will be set up even if the bridge does not have permission for them, then break when it restarts and tries to reach messages
|
||||||
- test private threads as part of this
|
- test private threads as part of this
|
||||||
- solution part 1: calculate the permissions to see if the bot should be able to do stuff
|
- solution part 1: calculate the permissions to see if the bot should be able to do stuff
|
||||||
|
|
Loading…
Reference in a new issue