Skip to content

Instantly share code, notes, and snippets.

@DC3
Forked from teppeis/md2cf.sh
Last active March 14, 2019 02:07
Show Gist options
  • Save DC3/9ba9bc2cd3a88bb30e11 to your computer and use it in GitHub Desktop.
Save DC3/9ba9bc2cd3a88bb30e11 to your computer and use it in GitHub Desktop.
#!/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