fix(highlights): new italic format not displayed

This commit is contained in:
Elian Doran 2025-03-29 14:08:57 +02:00
parent 9a3f765d42
commit 04a7ad8d4e
No known key found for this signature in database
2 changed files with 17 additions and 1 deletions

View File

@ -0,0 +1,16 @@
import { describe, expect, it } from "vitest";
import HighlightsListWidget from "./highlights_list.js";
describe("getHighlightList", () => {
let widget = new HighlightsListWidget();
it("supports old italics", async () => {
const highlights = await widget.getHighlightList("This is <i>italic</i> text", [ "italic" ]);
expect(highlights.$highlightsList.html()).toBe("<li><i>italic</i></li>");
});
it("supports new italics", async () => {
const highlights = await widget.getHighlightList("This is <em>italic</em> text", [ "italic" ]);
expect(highlights.$highlightsList.html()).toBe("<li><em>italic</em></li>");
});
})

View File

@ -203,7 +203,7 @@ export default class HighlightsListWidget extends RightPanelWidget {
// matches a span containing color
const regex2 = /<span[^>]*style\s*=\s*[^>]*[^-]color:[^>]*?>[\s\S]*?<\/span>/gi;
// match italics
const regex3 = /<i>[\s\S]*?<\/i>/gi;
const regex3 = /(<i>[\s\S]*?<\/i>|<em>[\s\S]*?<\/em>)/gi;
// match bold
const regex4 = /<strong>[\s\S]*?<\/strong>/gi;
// match underline