内容一覧
こんにちわ!
ひでゆきです^^(dehichan0728)
今日は記事中のソースコードを紹介したいと思ったときに、綺麗に表示させることができるプラグインを紹介します!
ソースコードっていうのは、ページ上で右クリックすると見れます。


Crayon Syntax Highlighterとは
Crayon Syntax Highlighterは、WordPressの記事中のソースコードを綺麗に表示させることができるプラグインです。
他の人にコードを紹介したい!
というときに、このプラグインを使います。
そのまま貼るのはちょっとなしよねぇ~
<p class=”post-date”>投稿日:<time datetime=”<?php the_time(‘Y-m-d’); ?>” itemprop=”datePublished” content=”<?php the_time(‘Y-m-d’); ?>” ><?php the_time(get_option(‘date_format’)); ?></time> | 更新日:<time datetime=”<?php the_time(‘Y-m-d’); ?>” itemprop=”dateModified” content=”<?php the_modified_date(‘Y-m-d’) ?>” ><?php the_modified_date(get_option(‘date_format’)); ?></time></p>
こうやってみます?
<p class=”post-date”>投稿日:<time datetime=”<?php the_time(‘Y-m-d’); ?>” itemprop=”datePublished” content=”<?php the_time(‘Y-m-d’); ?>” ><?php the_time(get_option(‘date_format’)); ?></time> | 更新日:<time datetime=”<?php the_time(‘Y-m-d’); ?>” itemprop=”dateModified” content=”<?php the_modified_date(‘Y-m-d’) ?>” ><?php the_modified_date(get_option(‘date_format’)); ?></time></p>
どうせならソースの色味とかそのままの方が見栄えいいですよね。

そんな時に「Crayon Syntax Highlighter」プラグインを使えばソースを綺麗に表示できちゃいます!
<p class="post-date">投稿日:<time datetime="<?php the_time('Y-m-d'); ?>" itemprop="datePublished" content="<?php the_time('Y-m-d'); ?>" ><?php the_time(get_option('date_format')); ?></time> | 更新日:<time datetime="<?php the_time('Y-m-d'); ?>" itemprop="dateModified" content="<?php the_modified_date('Y-m-d') ?>" ><?php the_modified_date(get_option('date_format')); ?></time></p>
どうでしょうか、この方がカッコいいでしょ?笑
見た感じもソースなんだ。ということが伝わりやすいです。
では、インストール方法、設定、使い方を説明していきます!
Crayon Syntax Highlighterのインストール方法
WordPressでプラグインをインストールしたことないよ!
という方はこちらWordPress入門「プラグインとは」「インストールする方法」
Crayon Syntax Highlighter設定方法
このプラグインは設定不要で使えます!
それぞれがカスタマイズすることができるのでお好みでお願いします~
ダッシュボード「設定」→「crayon」

テーマ選択
テーマは好きなものを選択してください!

テーマの一部こんな感じ…
全部書きだすの途中で諦めました。ごめんなさい!
1c kod
1 2 3 4 5 6 7 8 | // A sample class class Human { private int age = 0; public void birthday() { age++; print('Happy Birthday!'); } } |
1c Zapros
1 2 3 4 5 6 7 8 | // A sample class class Human { private int age = 0; public void birthday() { age++; print('Happy Birthday!'); } } |
809finset
1 2 3 4 5 6 7 8 | // A sample class class Human { private int age = 0; public void birthday() { age++; print('Happy Birthday!'); } } |
Ado
1 2 3 4 5 6 7 8 | // A sample class class Human { private int age = 0; public void birthday() { age++; print('Happy Birthday!'); } } |
Amity
1 2 3 4 5 6 7 8 | // A sample class class Human { private int age = 0; public void birthday() { age++; print('Happy Birthday!'); } } |
Arduino ldo
1 2 3 4 5 6 7 8 | // A sample class class Human { private int age = 0; public void birthday() { age++; print('Happy Birthday!'); } } |
Bncplusplus
1 2 3 4 5 6 7 8 | // A sample class class Human { private int age = 0; public void birthday() { age++; print('Happy Birthday!'); } } |
Capactitacionti
1 2 3 4 5 6 | class Human { private int age = 0; public void birthday() { age++; print('Happy Birthday!'); } |
Cg Cookie
1 2 3 4 5 6 7 | // A sample class class Human { private int age = 0; public void birthday() { age++; print('Happy Birthday!'); } |
Cisco Router
1 2 3 4 5 6 7 8 | // A sample class class Human { private int age = 0; public void birthday() { age++; print('Happy Birthday!'); } } |
Classic
1 2 3 4 5 6 7 8 | // A sample class class Human { private int age = 0; public void birthday() { age++; print('Happy Birthday!'); } } |
Code Spesial Board
1 2 3 4 5 6 7 8 | // A sample class class Human { private int age = 0; public void birthday() { age++; print('Happy Birthday!'); } } |
Coy
1 2 3 4 5 6 7 8 | // A sample class class Human { private int age = 0; public void birthday() { age++; print('Happy Birthday!'); } } |
Dark Terminal
1 2 3 4 5 6 7 8 | // A sample class class Human { private int age = 0; public void birthday() { age++; print('Happy Birthday!'); } } |
Eclipsc
1 2 3 4 5 6 7 8 | // A sample class class Human { private int age = 0; public void birthday() { age++; print('Happy Birthday!'); } } |
Epicgeeks
1 2 3 4 5 6 7 8 | // A sample class class Human { private int age = 0; public void birthday() { age++; print('Happy Birthday!'); } } |
Familiar
1 2 3 4 5 6 7 8 | // A sample class class Human { private int age = 0; public void birthday() { age++; print('Happy Birthday!'); } } |
Feeldesign
1 2 3 4 5 6 7 8 | // A sample class class Human { private int age = 0; public void birthday() { age++; print('Happy Birthday!'); } } |
Flatui Ligt
1 2 3 4 5 6 7 8 | // A sample class class Human { private int age = 0; public void birthday() { age++; print('Happy Birthday!'); } } |
まだまだ種類ありますが、この辺にしときましょう。笑
ここで好きなテーマを選んでください、特に選ばなくても使えます。
フォント選択
もう見本は出しません…数が多すぎます!!笑

こんな感じに変わったりします、フォントを選択したらその場でサンプル変わります。
1 2 3 4 5 6 7 8 | // A sample class class Human { private int age = 0; public void birthday() { age++; print('Happy Birthday!'); } } |
サイズ選択
気になる方はやってください!笑

それ以降の設定
そのままでも使えます!

このままで問題なーし!

Crayon Syntax Highlighter使い方
プラグインを有効化すると、記事の装飾関連に追加されます。
ビジュアル

テキスト

それぞれのボタンをクリックすると以下の画面がでます。

①タイトルを記入

②1文章として表示
改行がないソースで使います。
どっちでも使えます、見やすさを考えるとチェックをした方がいいでしょう。
チェックなし
1 | <li class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-1046"><a href="https://dehichan.com/category/beginner/open-set/"> |
チェックあり
<li class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-1046"><a href="https://dehichan.com/category/beginner/open-set/">
③挿入
これをクリックすることでソースを記事内に表示します。
④コードを貼り付ける場所
綺麗に表示したいソースを貼り付けます。
Crayon Syntax Highlighterまとめ
使い方は本当にシンプルです!!
設定不要で使えることも嬉しいですね。
そのまま貼り付けでもいいですが、見栄えを考えるとプラグインを使った方がいいでしょう!!
見栄えと手軽さでこのプラグインが1番いいですよ^^
では!!
コメントを残す