Don't pillify code blocks (#7861)

* Don't pillify code blocks

Signed-off-by: Robin Townsend <robin@robin.town>

* Test that pills do not appear in code blocks

Signed-off-by: Robin Townsend <robin@robin.town>

* Use snapshot instead for test

Signed-off-by: Robin Townsend <robin@robin.town>
This commit is contained in:
Robin 2022-02-22 06:46:34 -05:00 committed by GitHub
parent d79d5ceeac
commit bb79c6086a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 33 additions and 1 deletions

View file

@ -44,7 +44,11 @@ export function pillifyLinks(nodes: ArrayLike<Element>, mxEvent: MatrixEvent, pi
while (node) {
let pillified = false;
if (node.tagName === "A" && node.getAttribute("href")) {
if (node.tagName === "PRE" || node.tagName === "CODE") {
// Skip code blocks
node = node.nextSibling as Element;
continue;
} else if (node.tagName === "A" && node.getAttribute("href")) {
const href = node.getAttribute("href");
const parts = parsePermalink(href);
// If the link is a (localised) matrix.to link, replace it with a pill