Created
May 7, 2014 01:47
-
-
Save sangwook/4152ed044293df56a42b to your computer and use it in GitHub Desktop.
vim 정규표현식으로 Markdown 을 Confluence wiki markup 으로 변환하기
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
" vim 정규표현식으로 Markdown 을 Confluence wiki markup 으로 변환하기 | |
function! MarkdownToWiki() | |
execute '%s%^- %* %Ig' | |
execute '%s%^\t- %\t** %Ig' | |
execute '%s%^\t\t- %\t\t*** %Ig' | |
execute '%s%^\t\t\t- %\t\t\t**** %Ig' | |
execute '%s%^\t\t\t\t- %\t\t\t\t***** %Ig' | |
execute '%s%^\t\t\t\t\t- %\t\t\t\t\t****** %Ig' | |
execute '%s%^\t\t\t\t\t\t- %\t\t\t\t\t\t******* %Ig' | |
execute '%s%^# %h1. %Ig' | |
execute '%s%^## %h2. %Ig' | |
execute '%s%^### %h3. %Ig' | |
execute '%s%^#### %h4. %Ig' | |
execute '%s%^##### %h5. %Ig' | |
execute '%s%^###### %h6. %Ig' | |
" replace [title](url) with [title|url] | |
execute '%s%\v\[([^]]+)\]\(([^)]+)\)%[\1|\2]%Ig' | |
" https://confluence.atlassian.com/display/DOC/Confluence+Wiki+Markup#ConfluenceWikiMarkup-images | |
execute '%s%\v\<img src\=\"([^"]+)\"[^>]*\>%!\1!%Ig' | |
endfunction | |
command! MarkdownToWiki call MarkdownToWiki() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment