# HG changeset patch # User Steve Losh # Date 1273678467 14400 # Node ID 08c53a25024252144ccb81e52c6c862be6c12e37 # Parent bf29ac6dbdab384e8892561227ee33e291405158 Add VIM textile syntax files. diff -r bf29ac6dbdab -r 08c53a250242 vim/doc/textile.txt --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/vim/doc/textile.txt Wed May 12 11:34:27 2010 -0400 @@ -0,0 +1,52 @@ +*textile.txt* Textile for Vim Last Change: November 3, 2008 + +=============================================================================== +REQUIREMENTS *textile-requirements* + +- ruby - http://ruby-lang.org/ (seperate executable, not compiled in) +- RedCloth - http://whytheluckystiff.net/ruby/redcloth/ + +Files with the extension *.textile will auto-detected. If editing a new file, +or otherwise, run ":setf textile" to enable textile commands. + + +============================================================================== +CHANGELOG *textile-changelog* + +0.3 - Fixed keymappings in the documentation +0.2 - Added multiple colors for headers, and alternating colors for list + items + - Fixed error in the vim script for TextileRenderBufferToFile + - Changed shortcut keys from \tp to \rp (render preview instead of + textile preview, since it's file-type specific anyways) +0.1 - Initial Release + +============================================================================== +COMMANDS *textile-commands* + +h2. Commands + +:TextilePreview - Render the current buffer to a temp file, and open it in + your web browser (OSX only) + + rp + +:TextileRenderTab - ... to a new tab + + rt + +:TextileRenderFile - ... to a file + + rf + + is \ by default, so rp == \rp + +============================================================================== +CREDITS *textile-credits* + +- "Dominic Mitchell":http://happygiraffe.net/: initial syntax highlighting +- "Aaron Bieber":http://blog.aaronbieber.com/: improved syntax highlighting +- "Tim Harper":http://tim.theenchanter.com/ : improved syntax highlighting, + plugin + +vim:tw=78:noet:wrap:ts=2:expandtab:ft=help:norl: diff -r bf29ac6dbdab -r 08c53a250242 vim/ftplugin/textile.vim --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/vim/ftplugin/textile.vim Wed May 12 11:34:27 2010 -0400 @@ -0,0 +1,51 @@ +" textile.vim +" +" Tim Harper (tim.theenchanter.com) + +command! -nargs=0 TextileRenderFile call TextileRenderBufferToFile() +command! -nargs=0 TextileRenderTab call TextileRenderBufferToTab() +command! -nargs=0 TextilePreview call TextileRenderBufferToPreview() +noremap rp :TextilePreview +noremap rf :TextileRenderFile +noremap rt :TextileRenderTab +setlocal ignorecase +setlocal wrap +setlocal lbr + +function! TextileRender(lines) + if (system('which ruby') == "") + throw "Could not find ruby!" + end + + let text = join(a:lines, "\n") + let html = system("ruby -e \"def e(msg); puts msg; exit 1; end; begin; require 'rubygems'; rescue LoadError; e('rubygems not found'); end; begin; require 'redcloth'; rescue LoadError; e('RedCloth gem not installed. Run this from the terminal: sudo gem install RedCloth'); end; puts(RedCloth.new(\\$stdin.read).to_html(:textile))\"", text) + return html +endfunction + +function! TextileRenderFile(lines, filename) + let html = TextileRender(getbufline(bufname("%"), 1, '$')) + let html = "" . bufname("%") . "\n" . html . "\n" + return writefile(split(html, "\n"), a:filename) +endfunction + +function! TextileRenderBufferToPreview() + let filename = "/tmp/textile-preview.html" + call TextileRenderFile(getbufline(bufname("%"), 1, '$'), filename) + + " Modify this line to make it compatible on other platforms + call system("open -a Safari ". filename) +endfunction + +function! TextileRenderBufferToFile() + let filename = input("Filename:", substitute(bufname("%"), "textile$", "html", ""), "file") + call TextileRenderFile(getbufline(bufname("%"), 1, '$'), filename) + echo "Rendered to '" . filename . "'" +endfunction + +function! TextileRenderBufferToTab() + let html = TextileRender(getbufline(bufname("%"), 1, '$')) + tabnew + call append("^", split(html, "\n")) + set syntax=html +endfunction + diff -r bf29ac6dbdab -r 08c53a250242 vim/plugin/textile.vim --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/vim/plugin/textile.vim Wed May 12 11:34:27 2010 -0400 @@ -0,0 +1,5 @@ +" textile.vim +" +" Tim Harper (tim.theenchanter.com) + +au BufRead,BufNewFile *.textile setf textile diff -r bf29ac6dbdab -r 08c53a250242 vim/syntax/textile.vim --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/vim/syntax/textile.vim Wed May 12 11:34:27 2010 -0400 @@ -0,0 +1,87 @@ +" +" You will have to restart vim for this to take effect. In any case +" it is a good idea to read ":he new-filetype" so that you know what +" is going on, and why the above lines work. +" +" Written originally by Dominic Mitchell, Jan 2006. +" happygiraffe.net +" +" Modified by Aaron Bieber, May 2007. +" blog.aaronbieber.com +" +" Modified by Tim Harper, July 2008 - current +" tim.theenchanter.com +" @(#) $Id$ + +if version < 600 + syntax clear +elseif exists("b:current_syntax") + finish +endif + +" Textile commands like "h1" are case sensitive, AFAIK. +syn case match + +" Textile syntax: + +" Inline elements. +syn match txtEmphasis /_[^_]\+_/ +syn match txtBold /\*[^*]\+\*/ +syn match txtCite /??.\+??/ +syn match txtDeleted /-[^-]\+-/ +syn match txtInserted /+[^+]\++/ +syn match txtSuper /\^[^^]\+\^/ +syn match txtSub /\~[^~]\+\~/ +syn match txtSpan /%[^%]\+%/ +syn match txtFootnoteRef /\[[0-9]\+]/ +syn match txtCode /@[^@]\+@/ + +" Block elements. +syn match txtHeader /^h1\. .\+/ +syn match txtHeader2 /^h2\. .\+/ +syn match txtHeader3 /^h[3-6]\..\+/ +syn match txtBlockquote /^bq\./ +syn match txtFootnoteDef /^fn[0-9]\+\./ +syn match txtListBullet /\v^\*+ / +syn match txtListBullet2 /\v^(\*\*)+ / +syn match txtListNumber /\v^#+ / +syn match txtListNumber2 /\v^(##)+ / + +syn cluster txtBlockElement contains=txtHeader,txtBlockElement,txtFootnoteDef,txtListBullet,txtListNumber + + +" Everything after the first colon is from RFC 2396, with extra +" backslashes to keep vim happy... Original: +" ^(([^:/?#]+):)?(//([^/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))? +" +" Revised the pattern to exclude spaces from the URL portion of the +" pattern. Aaron Bieber, 2007. +syn match txtLink /"[^"]\+":\(\([^:\/?# ]\+\):\)\?\(\/\/\([^\/?# ]*\)\)\?\([^?# ]*\)\(?\([^# ]*\)\)\?\(#\([^ ]*\)\)\?/ + +syn cluster txtInlineElement contains=txtEmphasis,txtBold,txtCite,txtDeleted,txtInserted,txtSuper,txtSub,txtSpan + +if version >= 508 || !exists("did_txt_syn_inits") + if version < 508 + let did_txt_syn_inits = 1 + command -nargs=+ HiLink hi link + else + command -nargs=+ HiLink hi def link + endif + + HiLink txtHeader Title + HiLink txtHeader2 Question + HiLink txtHeader3 Statement + HiLink txtBlockquote Comment + HiLink txtListBullet Operator + HiLink txtListBullet2 Constant + HiLink txtListNumber Operator + HiLink txtListNumber2 Constant + HiLink txtLink String + HiLink txtCode Identifier + hi def txtEmphasis term=underline cterm=underline gui=italic + hi def txtBold term=bold cterm=bold gui=bold + + delcommand HiLink +endif + +" vim: set ai et sw=4 :