Coverage for m->d ordered list start attribute

This commit is contained in:
Cadence Ember 2023-11-23 13:41:31 +13:00
parent 53a009ca45
commit 8026cf0cad
2 changed files with 43 additions and 1 deletions

View File

@ -122,7 +122,7 @@ turndownService.addRule("listItem", {
if (parent.nodeName === "OL") {
var start = parent.getAttribute("start")
var index = Array.prototype.indexOf.call(parent.children, node)
prefix = (start ? Number(start) + index : index + 1) + ". "
prefix = (start ? Number(start) + index : index + 1) + ". "
}
return prefix + content + (node.nextSibling && !/\n$/.test(content) ? "\n" : "")
}

View File

@ -561,6 +561,48 @@ test("event2message: lists have appropriate line breaks", async t => {
)
})
test("event2message: ordered list start attribute works", async t => {
t.deepEqual(
await eventToMessage({
content: {
body: 'i am not certain what you mean by "already exists with as discord". my goals are\n' +
'1. bridgeing specific channels with existing matrix rooms\n' +
' 2. optionally maybe entire "servers"\n' +
'3. offering the bridge as a public service ',
format: 'org.matrix.custom.html',
formatted_body: '<p>i am not certain what you mean by "already exists with as discord". my goals are</p>\n' +
'<ol>\n' +
'<li>bridgeing specific channels with existing matrix rooms\n' +
'<ol start="2">\n' +
'<li>optionally maybe entire "servers"</li>\n' +
'</ol>\n' +
'</li>\n' +
'<li>offering the bridge as a public service</li>\n' +
'</ol>\n',
'm.mentions': {},
msgtype: 'm.text'
},
room_id: '!cBxtVRxDlZvSVhJXVK:cadence.moe',
sender: '@Milan:tchncs.de',
type: 'm.room.message',
}, {}, {
api: {
getStateEvent: async () => ({displayname: "Milan"})
}
}),
{
ensureJoined: [],
messagesToDelete: [],
messagesToEdit: [],
messagesToSend: [{
username: "Milan",
content: `i am not certain what you mean by "already exists with as discord". my goals are\n\n1. bridgeing specific channels with existing matrix rooms\n 2. optionally maybe entire "servers"\n2. offering the bridge as a public service`,
avatar_url: undefined
}]
}
)
})
test("event2message: m.emote plaintext works", async t => {
t.deepEqual(
await eventToMessage({