Skip to content

Instantly share code, notes, and snippets.

@davidchambers
Created August 8, 2016 01:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save davidchambers/0b4daa0917d95f1fccaaea53b66714ca to your computer and use it in GitHub Desktop.
Save davidchambers/0b4daa0917d95f1fccaaea53b66714ca to your computer and use it in GitHub Desktop.
function drop(n) {
s = ""
for (i = n + 1; i <= NF; i += 1) { s = s (s == "" ? "" : " ") $i }
return s
}
/^ *\/\/\. ##/ {
indent = substr($2, 2) # reduce indentation by one level
gsub(/#/, " ", indent)
href = tolower(drop(2))
gsub(/ /, "-", href)
print indent "- [" drop(2) "](#" href ")"
}
/^ *\/\/\#/ {
href = $2
sub(/#/, ".prototype.", href)
print indent " - [`" drop(1) "`](#" href ")"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment