为网站生成可点击的点图



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

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

Follows: exp1.md exp2.md

我运行了一个脚本来制作所有实验的DOT语言图:

#!/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;
}

但我一直找不到任何软件可以把它变成一个可点击的图像地图。解决方案可以根据需要进行破解!我只会亲自使用它,并在内部实验室网络上托管该网站。

事实证明它还不错。只需将属性添加到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;
}

并创建图像地图代码+图像:

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

最新更新