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
1 comments:
Hey, tks!!!! That's works just fine. But you could also use a isValid() internal method instead of use the apache. Take a look:
public boolean isValid(char current) {
if ((current == 0x9) ||
(current == 0xA) ||
(current == 0xD) ||
((current >= 0x20) && (current <= 0xD7FF)) ||
((current >= 0xE000) && (current <= 0xFFFD)) ||
((current >= 0x10000) && (current <= 0x10FFFF)))
return true;
return false;
}
This solved my problem! Bye.
Post a Comment