sponsor Vim development Vim logo Vim Book Ad

Yankcode : Paste syntax code to webpage quickly

 script karma  Rating 1/1, Downloaded by 839  Comments, bugs, improvements  Vim wiki

created by
Sheng Yang
 
script type
utility
 
description
Many times when I using my old blog system, I fell in bad mood when I have to mix my source code with content, or no support for source code like syntax highlighted. And when I use vim’s script TOhtml to deal with these thing, I feel that it’s handy, but still not enough convenient. I have to choose and copy the html code by my hand, then add a something like <quoteblock class=”vimblock”>(”vimblock” is a user-defined CSS element, will be mention later) tag to differentiate these code from common <quoteblock>. It’s too inconvenient, also seems easy to be done with a script. So I wrote this.  

With this script, pasting syntax code is only: "V"(selection) and ":Yankcode" and ctrl-v in editor.

The script based on TOhtml written by Bram Moolenarr. It convert the current selection to html using 2html, then get the body of html and wrap it with <blockquote class=”vimblock”>. In the end, it send the wrapped section of syntax code to clipboard for the further use.

Welcome any advice.
 
install details
Copy to your plugin directory.
You also need specify CSS for using the code generate by this script.
The default CSS of your schema can be generated by TOhtml, though it will only generate the elements that used by current file, you can find a file with most kinds of elements to generate the basis and modify it when you need more elements.
After generation, just copy the section between <!– –> just below the <style type=”text/css”>, replace element name “body” with “.vimblock” and append it to your CSS file( usually style.css).
After have well defined your CSS, you can use the "V"(optional) and ":Yankcode" and paste to editor with you syntax code in xhtml.

More  information including my css section and the effect of the script can be found at http://www.yasker.org/en/blog/a-vim-script-for-pasting-syntax-code-to-webpage-33
 

rate this script Life Changing Helpful Unfulfilling 
script versions (upload new version)

Click on the package to download.

package script version date Vim version user release notes
yankcode.tar.gz 0.1 2007-03-09 7.0 Sheng Yang Initial upload
ip used for rating: 34.203.221.104

If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to the maillist. Help Bram help Uganda.
   
Vim at Github