Skip to content

Instantly share code, notes, and snippets.

@vtmx
Last active November 24, 2025 17:30
Show Gist options
  • Select an option

  • Save vtmx/1447aa00ae08d653769e5faa472a8821 to your computer and use it in GitHub Desktop.

Select an option

Save vtmx/1447aa00ae08d653769e5faa472a8821 to your computer and use it in GitHub Desktop.
bk2md.awk
#!/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