2017 © Pedro Pelรกez
 

library netscape-bookmark-parser

Generic Netscape bookmark parser

image

shaarli/netscape-bookmark-parser

Generic Netscape bookmark parser

  • Saturday, February 10, 2018
  • by Shaarli Community
  • Repository
  • 6 Watchers
  • 6 Stars
  • 10,370 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 14 Forks
  • 2 Open issues
  • 14 Versions
  • 10 % Grown

The README.md

GH release GH license GH stars Build Status, (*1)

Shaarli Netscape Bookmark Parser

This library provides a decoder that is able of parsing Netscape bookmarks (as exported by common Web browsers and bookmarking services), and an encoder that is able to export data to bookmarks format., (*2)

๐Ÿš€ Installation

Using Composer (package):, (*3)

$ composer require shaarli/netscape-bookmark-parser

๐Ÿ”ฅ Usage

Import from Bookmark file

<?php
// parse.php
require_once 'vendor/autoload.php';

use Shaarli\NetscapeBookmarkParser\NetscapeBookmarkParser;

$parser = new NetscapeBookmarkParser();
$bookmarks = $parser->parseFile('./tests/Fixtures/Encoder/input/netscape_basic.htm');
var_dump($bookmarks);

Above example will return following array:, (*4)

array(2) {
  [0] => array(7) {
    ["name"] => string(12) "Secret stuff"
    ["image"] => NULL
    ["url"] => string(19) "https://private.tld"
    ["tags"] => array(2) {
      [0] => string(7) "private"
      [1] => string(6) "secret"
    }
    ["description"] => string(52) "Super-secret stuff you're not supposed to know about"
    ["dateCreated"] => int(971175336)
    ["public"] => bool(false)
  }
  [1] => array(7) {
    ["name"] => string(12) "Public stuff"
    ["image"] => NULL
    ["url"] => string(17) "http://public.tld"
    ["tags"] => array(3) {
      [0] => string(6) "public"
      [1] => string(5) "hello"
      [2] => string(5) "world"
    }
    ["description"] => NULL
    ["dateCreated"] => int(1456433748)
    ["public"] => bool(true)
  }
}

Export to file

<?php
// export.php
require_once 'vendor/autoload.php';

use Shaarli\NetscapeBookmarkParser\NetscapeBookmarkParser;

$data = [
    [
        'name'        => 'shaarli/Shaarli',
        'url'         => 'https://github.com/shaarli/Shaarli',
        'image'       => 'data:image/png;base64, ...'
        'description' => 'The personal, minimalist, super-fast, database free, bookmarking service',
        'public'      => true,
        'tags'        => ['shaarli'],
    ],
    [
        'name'         => 'shaarli/netscape-bookmark-parser',
        'url'          => 'https://github.com/shaarli/netscape-bookmark-parser',
        'public'       => false,
        'dateCreated'  => '1612572000',
        'dateModified' => '1612572000',
        'tags'         => ['shaarli'],
    ],
];

$parser = new NetscapeBookmarkParser();

$parser->export($data, './export.htm');

Above example will write following string into file:, (*5)

<!DOCTYPE NETSCAPE-Bookmark-file-1>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=UTF-8">
<TITLE>Bookmarks</TITLE>
<H1>Bookmarks</H1>
<DL><p>
<DT><H3>shaarli</H3>
<DL><p>
<DT><A HREF="https://github.com/shaarli/Shaarli" PRIVATE="0" ICON="data:image/png;base64, ...">shaarli/Shaarli</A>
<DD>The personal, minimalist, super-fast, database free, bookmarking service
<DT><A HREF="https://github.com/shaarli/netscape-bookmark-parser"> ADD_DATE="1612572000" LAST_MODIFIED="1612572000">shaarli/netscape-bookmark-parser</A>
<\DL><p>
<\DL><p>

๐Ÿ’ป Dependencies

Shaarli Netscape Bookmark Parser requires the following dependencies:, (*6)

  • PHP
  • Composer
  • Make (optional)

๐Ÿ˜ PHP

Learn how to install PHP from official documentation here, (*7)


๐Ÿ“ฆ Composer

Learn how to install Composer from official documentation here, (*8)


๐Ÿ›  Make

๐Ÿง Install Make (Linux)

On linux machine enter following command, (*9)

$ sudo apt-get install --assume-yes make

๐Ÿ Install Make (Windows)

On windows machine you will need to install cygwin or GnuWin make first to execute make script., (*10)

๐ŸŽ Install Make (OSX)

Make should be available by default on OSX system, but you can upgrade make version with following command, (*11)

$ brew install make

๐Ÿ“‘ About

โšก A word from Kafene

The motivations behind developing this parser are the following: - the Netscape format has a very loose specification: no DTD nor XSL stylesheet to constrain how data is formatted. - software and web services export bookmarks using a wild variety of attribute names and values. - using standard SAX or DOM parsers is thus not straightforward., (*12)

How it works: - the input bookmark file is trimmed and sanitized to improve parsing results - the resulting data is then parsed using PCRE patterns to match attributes and values corresponding to the most likely: - attribute names: description vs. note, tags vs. labels, date vs. time, etc. - data formats: comma,separated,tags vs. space separated labels, UNIX epochs vs. human-readable dates, newlines & carriage returns, etc. - an associative array containing all successfully parsed links with their attributes is returned, (*13)

โšก Shaarli community fork

This friendly fork is maintained by the Shaarli community at https://github.com/shaarli/netscape-bookmark-parser and is used by the open-source Shaarli bookmarking service. This is a community fork of the original netscape-bookmark-parser project by Kafene., (*14)

๐Ÿค Contributing

Thank you for your interrest in contributing to Shaarli Netscape Bookmark Parser., (*15)

Please review the code of conduct and contribution guidelines before starting to work on any features., (*16)

If you want to open an issue, please check first if it was not reported already before creating a new one., (*17)

๐Ÿ“œ License

Copyrights (c) 2021 "Shaarli community", (*18)

License Distributed under the MIT license., (*19)

If you like Shaarli Netscape Bookmark Parser please star or tweet about it:, (*20)

GitHub stars Twitter, (*21)

๐Ÿ™ Acknowledgements

The Versions

10/02 2018

dev-master

9999999-dev https://github.com/shaarli/netscape-bookmark-parser

Generic Netscape bookmark parser

  Sources   Download

MIT

The Requires

 

The Development Requires

link parse bookmark netscape

05/02 2018

dev-travis/trusty

dev-travis/trusty https://github.com/shaarli/netscape-bookmark-parser

Generic Netscape bookmark parser

  Sources   Download

MIT

The Requires

 

The Development Requires

link parse bookmark netscape

30/01 2018

v2.0.5

2.0.5.0 https://github.com/shaarli/netscape-bookmark-parser

Generic Netscape bookmark parser

  Sources   Download

MIT

The Requires

 

The Development Requires

link parse bookmark netscape

18/11 2017

dev-hotfix/scuttle-new-line

dev-hotfix/scuttle-new-line https://github.com/shaarli/netscape-bookmark-parser

Generic Netscape bookmark parser

  Sources   Download

MIT

The Requires

 

The Development Requires

link parse bookmark netscape

18/11 2017

dev-hotfix/sanatizing-improvements

dev-hotfix/sanatizing-improvements https://github.com/shaarli/netscape-bookmark-parser

Generic Netscape bookmark parser

  Sources   Download

MIT

The Requires

 

The Development Requires

link parse bookmark netscape

30/07 2017

v2.0.4

2.0.4.0 https://github.com/shaarli/netscape-bookmark-parser

Generic Netscape bookmark parser

  Sources   Download

MIT

The Requires

 

The Development Requires

link parse bookmark netscape

30/07 2017

v2.0.3

2.0.3.0 https://github.com/shaarli/netscape-bookmark-parser

Generic Netscape bookmark parser

  Sources   Download

MIT

The Requires

 

The Development Requires

link parse bookmark netscape

10/06 2017

v2.0.2

2.0.2.0 https://github.com/shaarli/netscape-bookmark-parser

Generic Netscape bookmark parser

  Sources   Download

MIT

The Requires

 

The Development Requires

link parse bookmark netscape

08/03 2017

v2.0.1

2.0.1.0 https://github.com/shaarli/netscape-bookmark-parser

Generic Netscape bookmark parser

  Sources   Download

MIT

The Requires

 

The Development Requires

link parse bookmark netscape

19/02 2017

v2.0.0

2.0.0.0 https://github.com/shaarli/netscape-bookmark-parser

Generic Netscape bookmark parser

  Sources   Download

MIT

The Requires

 

The Development Requires

link parse bookmark netscape

15/02 2017

v1.1.1

1.1.1.0 https://github.com/shaarli/netscape-bookmark-parser

Generic Netscape bookmark parser

  Sources   Download

MIT

The Requires

  • php >=5.3.4

 

The Development Requires

link parse bookmark netscape

10/08 2016

v1.0.1

1.0.1.0 https://github.com/shaarli/netscape-bookmark-parser

Generic Netscape bookmark parser

  Sources   Download

MIT

The Requires

  • php >=5.3.4

 

The Development Requires

link parse bookmark netscape

01/07 2016

v1.0.0

1.0.0.0 https://github.com/kafene/netscape-bookmark-parser

Generic Netscape bookmark parser

  Sources   Download

MIT

The Requires

  • php >=5.3.4

 

The Development Requires

link parse bookmark netscape

18/09 2015

v0.0.1

0.0.1.0 https://github.com/kafene/BookmarkParser

Parse Netscape format bookmark files

  Sources   Download

MIT

parse bookmark netscape