Skip to content

Instantly share code, notes, and snippets.

@nashingofteeth
Last active October 27, 2023 01:25
Show Gist options
  • Save nashingofteeth/132acccf6cf12eb81fdb41ceafb24bdd to your computer and use it in GitHub Desktop.
Save nashingofteeth/132acccf6cf12eb81fdb41ceafb24bdd to your computer and use it in GitHub Desktop.
convert Pinboard JSON export to Markdown
const fs = require('fs'),
data = fs.readFileSync('pinboard.json', { encoding: 'utf8', flag: 'r' }),
bookmarks = JSON.parse(data);
const dir = 'pinboard';
if (fs.existsSync(dir))
fs.rmSync(dir, { recursive: true, force: true });
if (!fs.existsSync(dir))
fs.mkdirSync(dir);
for (bookmark in bookmarks) {
// if ( bookmark > 0 ) continue;
let b = bookmarks[bookmark],
title = b.description ? b.description : 'untitled',
read = b.toread == 'no' ? '- [x] ' : '- [ ] ',
tagsArray = b.tags.split(' '),
tags = tagsArray.join(' #'),
description = b.extended ? `\n ${b.extended}` : '',
date = b.time.slice(0,-10),
file = dir + '/' + date + '.md';
output = `${read}[${title}](${b.href}) #${tags}${description}\n`;
if ( !fs.existsSync(file) ) fs.writeFileSync(file, output);
else fs.appendFileSync(file, output);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment