initial attempt at converting html back to markdown
This commit is contained in:
parent
ff61376c07
commit
5373007301
1 changed files with 15 additions and 1 deletions
|
@ -40,11 +40,25 @@ function parseHtmlMessage(html, room) {
|
||||||
switch (prefix) {
|
switch (prefix) {
|
||||||
case "@": return new UserPillPart(resourceId, n.textContent, room.getMember(resourceId));
|
case "@": return new UserPillPart(resourceId, n.textContent, room.getMember(resourceId));
|
||||||
case "#": return new RoomPillPart(resourceId);
|
case "#": return new RoomPillPart(resourceId);
|
||||||
default: return new PlainPart(n.textContent);
|
default: {
|
||||||
|
if (href === n.textContent) {
|
||||||
|
return new PlainPart(n.textContent);
|
||||||
|
} else {
|
||||||
|
return new PlainPart(`[${n.textContent}](${href})`);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
case "BR":
|
case "BR":
|
||||||
return new NewlinePart("\n");
|
return new NewlinePart("\n");
|
||||||
|
case "EM":
|
||||||
|
return new PlainPart(`*${n.textContent}*`);
|
||||||
|
case "STRONG":
|
||||||
|
return new PlainPart(`**${n.textContent}**`);
|
||||||
|
case "PRE":
|
||||||
|
return new PlainPart(`\`\`\`${n.textContent}\`\`\``);
|
||||||
|
case "CODE":
|
||||||
|
return new PlainPart(`\`${n.textContent}\``);
|
||||||
default:
|
default:
|
||||||
return new PlainPart(n.textContent);
|
return new PlainPart(n.textContent);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue