Skip to content
Find file
Fetching contributors…
Cannot retrieve contributors at this time
executable file 34 lines (31 sloc) 572 Bytes
#!/usr/bin/awk -f
# Usage: a mdtoc file1 file2 file3...
# Summary: Provide a very simple Markdown table of contents
# Help: Loop over all files and output a table of contents for based on
# Markdown-style headers.
#
# Example:
#
# Given a file `example.md` like this:
#
# # Heading 1
#
# Lorem ipsum
#
# ## Heading 2
#
# Foo bar baz
#
# Running `a mdtoc example.md` will output:
#
# Heading 1
# Heading 2
#
/^#{1,2} / {
indent_level = gsub("#", "")
spacing = ""
for(i = 1; i < indent_level; i++) {
spacing = spacing " "
}
print spacing $0
}
Jump to Line
Something went wrong with that request. Please try again.