Install google-code-prettify and post the program (source code) on your blog

Install google-code-prettify and post the program (source code) on your blog

Hello, this is naouniverse ( @naouniverse708 ).

The article from the other day,

Post the program (source code) on your blog using Quick Highlighter

I tried posting the program (source code) on my blog, but it didn't seem to display well on my smartphone, so I decided to try google-code-prettify

<head>I inserted the following inside the tag.

<link rel="stylesheet" href="https://google-code-prettify.googlecode.com/svn/trunk/src/prettify.css" type="text/css" media="screen" /> <script type="text/javascript" src="https://google-code-prettify.googlecode.com/svn/trunk/src/prettify.js"></script> <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.2.6/jquery.min.js"></script> <script type="text/javascript"> $(document).ready(function(){ prettyPrint(); }); </script> <style type="text/css"> pre.prettyprint { background-color: rgb(248, 248, 248); color: gray; padding: 0 0 0 3px; } ol.linenums li { list-style: decimal outside; line-height: 1.5; border-left: solid 3px #6CE26C; padding-left: 3px; margin-left: .7em; background-color: rgb(248, 248, 248); } </style>

And put the code in the article,

<pre class="prettyprint linenums">#import "ViewController.h" @implementation ViewController - (void)viewDidLoad { [super viewDidLoad]; NSLog(@"Hello World!"); } @end</pre>

If you enter it like this,

#import "ViewController.h" @implementation ViewController - (void)viewDidLoad { [super viewDidLoad]; NSLog(@"Hello World!"); } @end

It will be displayed like this.

There is room for improvement in the display on smartphones, but I personally think it's on point compared to the previous Quick Highlighter.

  • Add this entry to Hatena Bookmarks

At "naouniverse.com", the administrator writes about things, things, and the world that interest him.
Gadgets, cameras, design, programming, L'Arc~en~Ciel, etc...