为网站生成可点击的点图?

时间:2013-08-28 02:40:19

标签: markdown dot directed-acyclic-graphs html-generation

我有一组降价文件(虚拟实验室笔记本中的实验)将用于生成静态网页,我还想生成一个索引,与它们一起显示它们之间的关系作为DAG(有向无环图)。

到目前为止,每个markdown文件都以这样的元数据开头(对于exp3.md):

Follows: exp1.md exp2.md

我运行一个脚本来制作所有实验的DOT language图表:

#!/bin/bash

arrows=$(
  for r in *.md; do
    for l in $(cat "$r" | grep Follows: | cut -d':' -f2); do
      echo "  $l -> $r;"
    done
  done
)

echo "digraph notebook {"
echo "$arrows" | sort | uniq
echo "}"

就像

一样
digraph notebook {
  exp1.md -> exp3.md;
  exp2.md -> exp3.md;
}

但是我找不到任何软件可以将其变成可点击的图像映射。根据需要,解决方案可以像hacky一样!我将亲自使用这个并在内部实验室网络上托管该网站。

1 个答案:

答案 0 :(得分:1)

事实证明它并不坏。只需将属性添加到DOT图:

digraph notebook {
  exp1 [label="experiment 1",URL="http://example.com/1"]
  exp2 [label="experiment 2",URL="http://example.com/2"]
  exp3 [label="experiment 3",URL="http://example.com/3"]
  exp1 -> exp3;
  exp2 -> exp3;
}

并创建imagemap代码+ image:

dot -Tcmapx graph.dot > graph.html
dot -Tpng   graph.dot > graph.png