Skip to content

Instantly share code, notes, and snippets.

@khornberg
Created January 14, 2014 18:04
Show Gist options
  • Save khornberg/8422787 to your computer and use it in GitHub Desktop.
Save khornberg/8422787 to your computer and use it in GitHub Desktop.
Convert markdown file to WordPress readme format.
#! /bin/bash
# Script to convert markdown file to WordPress readme format
# @author Kyle Hornberg
# @date 2014-01-14
#
# Changes
# # Header 1 -> === Header 1 ===
# ## Header 2 -> == Header 2 ==
# ### Header 3 -> = Header 3 =
# #### Header 4 -> **Header 4**
# ##### Header 5 -> **Header 5**
#
# Example
# convert-readme.sh SOURCE DEST
# ./convert-readme.sh readme.md readme.txt
sed -e 's/^#\{1\} \(.*\)/=== \1 ===/g' -e 's/^#\{2\} \(.*\)/== \1 ==/g' -e 's/^#\{3\} \(.*\)/= \1 =/g' -e 's/^#\{4,5\} \(.*\)/**\1**/g' "$1" > "$2"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment