This is a simple parser used with PegJS to parse a NETSCAPE-Bookmark-file. I've only tested this with safari export.
You have to remove these tags:
<HTML>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=UTF-8">
<Title>Bookmarks</Title>
<H1>Bookmarks</H1>
</HTML>
Example valid input:
<!DOCTYPE NETSCAPE-Bookmark-file-1>
<DT><H3 FOLDED>Favorites</H3>
<DL><p>
<DT><A HREF="....">.....</A>
<DT><A HREF="....">.....</A>
</DL><p>
<DT><H3 FOLDED>Bookmarks Menu</H3>
<DL><p>
<DT><H3 FOLDED>ABC</H3>
<DL><p>
<DT><A HREF="....">.....</A>
<DT><A HREF="....">.....</A>
<DT><A HREF="....">.....</A>
<DT><H3 FOLDED>ABC</H3>
<DL><p>
<DT><A HREF="....">.....</A>
</DL><p>
</DL><p>
</DL><p>
Output:
[
{
"type": "folder",
"name": "Favorites",
"items": [
{
"type": "link",
"url": "....",
"label": "....."
},
{
"type": "link",
"url": "....",
"label": "....."
}
]
},
{
"type": "folder",
"name": "Bookmarks Menu",
"items": [
{
"type": "folder",
"name": "ABC",
"items": [
{
"type": "link",
"url": "....",
"label": "....."
},
{
"type": "link",
"url": "....",
"label": "....."
},
{
"type": "link",
"url": "....",
"label": "....."
},
{
"type": "folder",
"name": "ABC",
"items": [
{
"type": "link",
"url": "....",
"label": "....."
}
]
}
]
}
]
}
]