LoginSignup
10
10

More than 5 years have passed since last update.

テキストベースでグラフを書く(Octopress/Jekyll 向け)

Last updated at Posted at 2012-08-04

this is non-directed graph

↓って書くと↑こうなる。ってやつを作った。

{% graph %}
a -- b
b -- c
c -- a
{% endgraph %}

有向グラフの時は、{% digraph %} を使う。

{% digraph %}
a -> b
b -> c
c -> a
{% enddigraph %}

インストール方法

Graphviz と Octopress プラグインをインストール

installation.sh
sudo apt-get install graphviz
cd <your_octopress_dir>/plugins
wget https://raw.github.com/kui/octopress-graphviz/master/graphviz_block.rb

もう少し複雑な図を書く

Graphviz の公式サイト を参照してください。

Graphviz のソースコードを書きたい

{% graphviz %} ブロックを使う。

{% graphviz %}
digraph g {
 a -> b
 b -> c
 c -> a
}
{% endgraphviz %}

おわり

HTML 内に SVG 要素を埋め込んでるので、HTML5 前提になってる。一応 altnative text みたいなのには簡単に対応しているので、ひょっとしたらちゃんと表示されるかも。確認していない。

確認していないけど Jekyll でも動くそうな。

10
10
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
10
10