There’s no native way to insert codes in Blogger (ie – no button on the editor toolbar). However we can manage to overcome the problem.
The easiest way is to write the full content in markdown and then copy it into the blog editor. It comes with full syntax highlighting in the language of your choice.
For example, we can write java code like this:
1 2 3 4 5 6 7 8 9 |
```java public class MyApp { public static void main(String[] args) { System.out.println("Hello World!"); } } ``` |
And the result:
1 2 3 4 5 6 7 |
public class MyApp { public static void main(String[] args) { System.out.println("Hello World!"); } } |
We can write markdown in VsCode, typora or Dillinger Online .
The second way is a little tedious. The steps:
- Convert code to html using converters and copy it
- Switch the blogger editor to HTML mode and insert the html
- Switch back to the Compose mode to see the result
markup.su and hilite.me are two common code snippets converters.