Delete bookmark
Searches for bookmarks containing a specific word in their text and deletes them from the document.
(function () {
let textToRemove = "test";
let caseSensitive = false; // Set this to true to enable case sensitivity
let doc = Api.GetDocument();
let bookmarkNames = doc.GetAllBookmarksNames();
for (let i = 0; i < bookmarkNames.length; i++) {
let bookmarkName = bookmarkNames[i];
let bookmark = doc.GetBookmark(bookmarkName);
let bookmarkText = bookmark.GetText();
let textToCompare = caseSensitive
? bookmarkText
: bookmarkText.toLowerCase();
if (textToCompare.includes(textToRemove)) {
doc.DeleteBookmark(bookmarkName);
}
}
})();
Methods used: GetDocument, GetAllBookmarksNames, GetBookmark, GetText, DeleteBookmark
Result