I created this blog to share various things, but mostly to bring interesting and useful source code. For this purpose, had to find a clear and easy way to post source code here.
The strange is that google (as you see I'm using blogger) do not provide any meaningful default solution.
I seek for different solutions and this was the coolest one Source Code Highlighting - In Blogger!. It uses vi editor and works great for me.
However I need to do some modifications.
First one is before executing :TOhtml command I do enable xhtml with :let use_xhtml=1. Second one is to remove all the <br /> tags since the rich editor of the blogger is making new lines for me. This can be done with :1,$s/<br \/>//g
Then you can paste the source in the reserved placeholders.
<pre> tag is needed to protect your code from the compose. It will damage it if <pre> is missing..
Here is the result from a simple java file.
package source.in.blogger;
import java.util.List;
/**
* Some commet is here.
*/
@Documented
public class BloggerSource {
// Simple comment
public static void main(String[] args) {
System.out.printf("I'm source code%n");
}
}
It's not extremely easy but works. Try it out and have fun.
Surely I'll use it for my few next post till I find something more useful.
Една седмица в липса на достъп
4 days ago
0 comments:
Post a Comment