mirror of
https://github.com/zadam/trilium.git
synced 2026-05-06 13:56:15 +02:00
fix(server): bookmarks not processed due to self-closing tag
This commit is contained in:
@@ -860,6 +860,9 @@
|
||||
"no_inherited_attributes": "No inherited attributes.",
|
||||
"none": "none"
|
||||
},
|
||||
"auto_link_attribute_list": {
|
||||
"title": "System Links"
|
||||
},
|
||||
"note_info_widget": {
|
||||
"note_id": "Note ID",
|
||||
"created": "Created",
|
||||
|
||||
@@ -31,4 +31,12 @@ describe("findBookmarks", () => {
|
||||
const content = `<a id="same"></a><a id="same"></a>`;
|
||||
expect(findBookmarks(content)).toEqual(["same"]);
|
||||
});
|
||||
|
||||
it("matches self-closing bookmark anchors (CKEditor empty elements)", () => {
|
||||
const content = `<p>Text</p><a id="my-bookmark"></a><p>More</p>`;
|
||||
// CKEditor may also output without closing tag
|
||||
const contentNoClose = `<p>Text</p><a id="my-bookmark"><p>More</p>`;
|
||||
expect(findBookmarks(content)).toEqual(["my-bookmark"]);
|
||||
expect(findBookmarks(contentNoClose)).toEqual(["my-bookmark"]);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -459,7 +459,7 @@ function findImageLinks(content: string, foundLinks: FoundLink[]) {
|
||||
* Bookmarks are stored as labels on the note so they can be looked up without parsing content.
|
||||
*/
|
||||
export function findBookmarks(content: string): string[] {
|
||||
const re = /<a\s+id="([^"]+)"[^>]*><\/a>/g;
|
||||
const re = /<a\s+id="([^"]+)"[^>]*>(<\/a>)?/g;
|
||||
const bookmarks: string[] = [];
|
||||
let match;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user