Skip to content

Instantly share code, notes, and snippets.

@johana-star
Created February 28, 2012 08:55
Show Gist options
  • Select an option

  • Save johana-star/1931397 to your computer and use it in GitHub Desktop.

Select an option

Save johana-star/1931397 to your computer and use it in GitHub Desktop.
Kindle to Markdown v0.0001
# The flaw of this method is it assumes that there will be five lines per highlight/bookmark,
# which will not be the case on multiple paragraph highlights.
NR % 5 == 2 { if ($2) {print "> "$0; token = "true"} else {token = "false"} }
NR % 5 == 0 { if (token == "true") {printf "<div align='right'>–" $0 "</div>\n\n"} }
#!/bin/bash
cp /Volumes/Kindle/documents/My\ Clippings.txt My\ Clippings.txt
# From awk one-liners, this line reverses the line order of a text file.
awk '{a[i++]=$0} END {for (j=i-1; j>=0;) print a[j--] }' My\ Clippings.txt > tmp.txt
# Not sure how to incorporate the awk commands in kindle.awk into this shell script.
awk -f kindle.awk tmp.txt > Quotes.md
rm tmp.txt My\ Clippings.txt
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment