Skip to content

Instantly share code, notes, and snippets.

@cmuller
Last active December 14, 2015 19:09
Show Gist options
  • Save cmuller/5134993 to your computer and use it in GitHub Desktop.
Save cmuller/5134993 to your computer and use it in GitHub Desktop.
A 'sed' command to switch from (# and ##) markdown titles to (=== and ----) underlined ones

I'm always surprised by the power and concision of sed! The only problem being able to find the (few) characters that do what I want :-)

aaronsw's html2text is doing a fine job converting html to markdown, but I prefer the underlined format for h1 and h2 titles as it is prettier (imho) when viewing the ascii code, so, here comes sed:

./html2text.py <url> | sed -e '/^# / {s/^# //p;s/./=/g}' -e '/^## / {s/^## //p;s/./-/g}' > url.md
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment