3

I would like to manage my bookmarks with org-mode and be able to export them so they could be used within a browser (Firefox, Chromium, Brave, etc.). Here is an example of an org file storing some bookmarks :

- [[https://emacs.stackexchange.com/][Emacs StackExchange]]
- [[https://stackoverflow.com/][Stackoverflow]]
* Data
** Finance
*** Crypto
- [[https://no.tradingeconomics.com/xmreur:cur][XMREUR]]
* Webapps
** Code
- [[https://creativetechguy.com/utilities/codedetector][Detect language from code]]
*** Bash
- [[https://www.shellcheck.net/][ShellCheck]]
  finds bugs in your shell scripts.
*** JSON
- [[https://stedolan.github.io/jq/manual/][jq Manual]]
  jq is a lightweight and flexible command-line JSON processor.
- [[https://jqplay.org/][jq online GUI]]
- [[https://www.json.org/json-en.html][JSON Intro]]
** Diagrams
- [[https://asciiflow.com/#/][asciiflow]]
- [[https://app.diagrams.net/][draw.io]]
** E-mail
- [[https://temp-mail.org][temp email]]   

When I export such an org file to an HTML file, it cannot be imported by a browser.

So I was wondering how could I write a function that could export this org file to an HTML file that could be imported by a browser.

Note that each heading would have to be exported as a folder and each link as a bookmark.

EDIT:

After some research, I found that the format used by most browsers to import and export bookmarks to HTML is called Netscape Bookmarks. Here is how Org-Mode managed bookmarks could be exported to Netscape Bookmarks :

  • Have the following block at the beginning of the exported HTML
<!DOCTYPE NETSCAPE-Bookmark-file-1>
<!--This is an automatically generated file.
    It will be read and overwritten.
    Do Not Edit! -->
<Title>Bookmarks</Title>
<H1>Bookmarks</H1>
  • The rest of the exported HTML should be as follow, where {item} may be either a folder or a bookmark:
<DL>
 {item}
 {item}
 {item}
 .
 .
 .
</DL>
  • If {item} refers to a folder, it is:
<DT><H3 FOLDED ADD_DATE="{date}">{title}</H3>
<DL><p>
 {item}
 {item}
 {item}
 .
 .
 .
</DL><p>  

Where {date} is a decimal integer that represents the number of seconds elapsed since midnight January 1, 1970, e.g. 1661350152. And {title} is the name of the folder corresponding to an Orgdown headline.

  • If {item} refers to a bookmark, it is:
<DT><A HREF="{Bookmark URL}" ADD_DATE="{date}" LAST_MODIFIED="1661350203">{Bookmark Name}</A>  

Corresponding to Orgdown [[{Bookmark URL}][{Bookmark Name}]]

7
  • My first step would be to find some documentation on the schema (the markup convention) of HTML bookmark files -- in other words, what does a browser expect to find in such a file. That's what you might call the rational approach, which you might contrast with the empirical approach: go to your browser of choice and export your current bookmarks, and see if you can deduce the schema from the exported file. Then you can work out what kind of mismatch there is between Org's HTML export schema and the schema you need. Aug 23 at 21:10
  • I second @PhilHudson's "rational" approach. My recommendation would be to target a specialized HTML exporter to the freedesktop bookmark spec. My hope is that the bookmarks can then be imported to any browser - although I don't know if that is true or not and will require some research, targeting a particular browser's format seems like a very bad idea to me.
    – NickD
    Aug 24 at 16:32
  • 1
    After some research, I found that the format is called Netscape Bookmarks. I exported bookmarks from 3 different browsers (chromium, firefox and brave) and the format seems to be the same. Unfortunately, documentation is quite limited. I only found one useful tool (netscape-bookmarks) but it is written in javascript, which I don't understand.
    – crocefisso
    Aug 24 at 18:53
  • That is a better situation than I thought (although I wonder what the compatibility story of the Windows/MacOS browsers is). Maybe you can export to the format that netcsape-bookmarks expects and then invoke it explicitly to get to the final result (the same way that the LaTeX/PDF exporter invokes a LaTeX processor as an external program to get from the intermediate LaTeX format to the final PDF). You don't need to understand JS for that.
    – NickD
    Aug 24 at 21:56
  • 1
    I don't know about Safari, but MS browsers seem to use Netscape Bookmarks format since they documented it. Indeed, netscape-bookmarks input seems to be a simple JSON. However, I exported the org example to a JSON through Pandoc-mode, and the result was quite far from netscape-bookmarks input. Is it a lot of work to build a custom exporter that would produce netscape-bookmarks input?
    – crocefisso
    Aug 24 at 23:06

1 Answer 1

1
  1. Install org-bookmarks-extractor package from Melpa and restart Emacs.
  2. From the org file used to manage the bookmarks do M-x org-bookmarks-extractor-extract to export the bookmarks into a Netscape bookmarks formatted HTML.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.