/    Sign up×
Community /Pin to ProfileBookmark

How can I generate an automatically styled bookmarks.html file?

You know how when you export your browser bookmarks to an html file and it looks like this: https://imgpile.com/images/NeiEnG.png

Well, is there any way I could create a css style sheet (or any other preexisting external page with some kind of styling code) on my computer that would reference the generated bookmarks.html page and automatically style it without changing the code in the bookmarks.html page? So that when I opened the bookmarks.html page in my browser it had maybe a black background and white text links instead of a white background and blue text links? Or the links were positioned differently on the page? Just some basic alterations to the style.

Thanks for any help. Will check back here regularly for any replies.

to post a comment
PHP

5 Comments(s)

Copy linkTweet thisAlerts:
@NogDogSep 17.2021 — Just spit-balling a possible quick-and-dirty approach here...
[code=php]
<!DOCTYPE html>
<html lang="en">
<head>
<title>Bookmarks</title>
<style>
/* your CSS here */
</style>
</head>
<?php
$html = file_get_contents(path/to/file.html);
$content = preg_match('/<body.*/is', $html, $matches);
echo $matches[0];
[/code]
Copy linkTweet thisAlerts:
@fsirauthorSep 17.2021 — @NogDog#1637169

Thanks...I'm gonna try it now...But isn't that php code supposed to be closed or am I not understanding how it works?
Copy linkTweet thisAlerts:
@fsirauthorSep 17.2021 — @NogDog#1637169

i thought that might work but not yet...just a blank page.
Copy linkTweet thisAlerts:
@NogDogSep 17.2021 — > @fsir#1637172 But isn't that php code supposed to be closed

You don't have to close the &lt;?php tag at the very end of a PHP file if there is no non-PHP text to follow it. It's good practice to not have unnecessary closing tags as a habit, as they can mess things up when you start including/requiring a PHP file from another PHP script.

> @fsir#1637173 i thought that might work but not yet...just a blank page.

Maybe add this to the beginning of the PHP:
[code=php]
<?php
ini_set('display_errors', true);
error_reporting(E_ALL);
[/code]

...then find out what either I or you did wrong. :)

PS: I assume you actually have a PHP-enabled web server running locally and the PHP script is being accessed by a http URL (not a file:/// sort of reference) in your browser?
Copy linkTweet thisAlerts:
@fsirauthorSep 17.2021 — > @NogDog#1637176 PS: I assume you actually have a PHP-enabled web server running locally and the PHP script is being accessed by a http URL (not a file:/// sort of reference) in your browser?

oh, actually i forgot i can't test php on my computer...lol. my apologies. this is actually for a browser start page that will never go online. i'm trying to make a neat, fast-loading offline start page with just links and a bit of style. i could do a simple page with static links but i want friends to be able to automatically customize all the links with a few simple steps like just exporting their bookmarks to a file that auto updates the start page with their own bookmarks while keeping the style.
×

Success!

Help @fsir spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 4.25,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...