-
-
Save vtmx/1447aa00ae08d653769e5faa472a8821 to your computer and use it in GitHub Desktop.
bk2md.awk
This file contains hidden or 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
| #!/usr/bin/awk -f | |
| # Usage: ./bk2md bookmarks.html | |
| # Usa arquivo bookmarks.html por padrão | |
| BEGIN { | |
| if (ARGC == 1) { | |
| ARGV[1] = "bookmarks.html" | |
| ARGC = 2 | |
| } | |
| } | |
| # Título | |
| /<TITLE/ { | |
| h1 = gensub(/<TITLE>([^<]+).*$/, "\\1", 1) | |
| print "# " h1 | |
| } | |
| # Subtítulo | |
| /^[[:space:]]{4}<DT><H3/ { | |
| h2 = gensub(/[[:space:]]+<DT><H3.+">([^<]+).*$/, "\\1", "g") | |
| printf "\n## %s \n\n", h2 | |
| } | |
| # Links | |
| /DT><A / { | |
| title= gensub(/^[ \t]*<DT><A HREF=".+>([^<]+).*$/, "\\1", "g") | |
| link = gensub(/^.*<DT><A HREF="([^"]+)".*$/, "\\1", "g") | |
| printf "- [%s] (%s)\n", title, link | |
| } | |
| # ft=awk |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment