# BookmarkParser
[](https://hex.pm/packages/bookmark_parser)
[](https://hexdocs.pm/bookmark_parser)
BookmarkParser is an Elixir library for parsing Netscape-format HTML bookmark files exported from browsers like Chrome, Firefox, Safari, and others.
## Installation
The package can be installed by adding `bookmark_parser` to your list of dependencies in `mix.exs`:
```elixir
def deps do
[
{:bookmark_parser, "~> 0.1.0"}
]
end
```
## Usage
```elixir
# Parse a bookmark file
{:ok, bookmarks} = BookmarkParser.parse_file("path/to/bookmarks.html")
# Parse bookmark content from a string
{:ok, bookmarks} = BookmarkParser.parse_string(bookmark_content)
# Get a flattened list of all bookmark entries
entries = BookmarkParser.flatten(bookmarks)
# Count total bookmark entries
count = BookmarkParser.count_entries(bookmarks)
# Filter bookmarks
github_bookmarks = BookmarkParser.filter_bookmarks(bookmarks, fn entry ->
String.contains?(entry.href, "github.com")
end)
```
## Structs
The parser produces two main types of structs:
### BookmarkEntry
Represents a single bookmark with a URL.
```elixir
%BookmarkParser.BookmarkEntry{
href: "https://example.com",
title: "Example Website",
add_date: "1622548800",
last_modified: "1622548800",
icon: "data:image/png;base64,...",
tags: "example,test"
}
```
### BookmarkFolder
Represents a folder that can contain other bookmarks and folders.
```elixir
%BookmarkParser.BookmarkFolder{
title: "My Bookmarks",
add_date: "1622548800",
last_modified: "1622548800",
personal_toolbar_folder: false,
children: [list_of_entries_and_folders]
}
```
## Documentation
Full documentation available at [https://hexdocs.pm/bookmark_parser](https://hexdocs.pm/bookmark_parser).
## License
This project is licensed under the MIT License - see LICENSE file for details.