Created
October 6, 2014 12:23
-
-
Save rafi/e3904cfce120f0eb45a2 to your computer and use it in GitHub Desktop.
Atlassian JIRA markup to Markdown. Oh the horror! Inspiration: https://github.com/FokkeZB/J2M
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function! s:convert_to_markdown(txt) | |
let txt = a:txt | |
let txt = substitute(txt, 'h\(\d\+\)\. ', '\=repeat("#", submatch(1))." "', 'g') | |
let txt = substitute(txt, '{code\(:\([a-z]\+\)\)\?}', '```\2', 'g') | |
let txt = substitute(txt, '{{\([^}\n]\+\)}}', '`\1`', 'g') | |
let txt = substitute(txt, '\*\([^\*\n]\{-}\)\*', '\*\*\1\*\*', 'g') | |
let txt = substitute(txt, '_\([^_\n]\{-}\)_', '\*\1\*', 'g') | |
let txt = substitute(txt, '\s\zs-\([^-\n]\{-}\)-', '~~~\1~~~', 'g') | |
let txt = substitute(txt, '+\([^+\n]\+\)+', '<ins>\1</ins>', 'g') | |
let txt = substitute(txt, '\^\([^\^\n]\+\)\^', '<sup>\1</sup>', 'g') | |
let txt = substitute(txt, '??\([^?\n]\+\)??', '<cite>\1</cite>', 'g') | |
let txt = substitute(txt, '\[\([^|\]\n]\+\)|\([^\]\n]\+\)\]', '[\1](\2)', 'g') | |
let txt = substitute(txt, '\[\([\([^\]\n]\+\)\]\([^(]*\)', '<\1>\2', 'g') | |
let txt = substitute(txt, "\r", '', 'g') | |
return txt | |
endfunction |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment