Last active
October 27, 2023 01:25
-
-
Save nashingofteeth/132acccf6cf12eb81fdb41ceafb24bdd to your computer and use it in GitHub Desktop.
convert Pinboard JSON export to Markdown
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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