import html from typing import List from bookmarks.models import Bookmark BookmarkDocument = List[str] def export_netscape_html(bookmarks: List[Bookmark]): doc = [] append_header(doc) append_list_start(doc) [append_bookmark(doc, bookmark) for bookmark in bookmarks] append_list_end(doc) return "\n\r".join(doc) def append_header(doc: BookmarkDocument): doc.append("") doc.append('') doc.append("
") def append_bookmark(doc: BookmarkDocument, bookmark: Bookmark): url = bookmark.url title = html.escape(bookmark.resolved_title or "") desc = html.escape(bookmark.resolved_description or "") if bookmark.notes: desc += f"[linkding-notes]{html.escape(bookmark.notes)}[/linkding-notes]" tag_names = bookmark.tag_names if bookmark.is_archived: tag_names.append("linkding:archived") tags = ",".join(tag_names) toread = "1" if bookmark.unread else "0" private = "0" if bookmark.shared else "1" added = int(bookmark.date_added.timestamp()) doc.append( f'
")