Skip to content

Instantly share code, notes, and snippets.

@teppeis
Created September 11, 2014 04:15
Show Gist options
  • Save teppeis/715771a870b33b4dcc39 to your computer and use it in GitHub Desktop.
Save teppeis/715771a870b33b4dcc39 to your computer and use it in GitHub Desktop.
Convert Markdown to Confluence
#!/bin/sh
# Convert Markdown to Confluence
#
# Supported syntax
# * heading (1-6)
# * blockquote (only single line ".bq")
# * code block fence (```)
# * inline code (`foo`)
# * link ([name](url))
cat - | sed \
-e 's/^# /h1. /g' \
-e 's/^## /h2. /g' \
-e 's/^### /h3. /g' \
-e 's/^#### /h4. /g' \
-e 's/^##### /h5. /g' \
-e 's/^###### /h6. /g' \
-e 's/^> /bq. /g' \
-e 's/^```\(.\+\)/{code:language=\1}/g' \
-e 's/^```$/{code}/g' \
-e 's/\s\?`\([^`]\+\)`\s\?/ {{\1}} /g' \
-e 's/\[\([^]]*\)\](\([^)]*\))/[\1|\2]/g' \
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment