@takane takane / maketoc.sh
Created at Wed Jan 25 21:41:33 JST 2023
thesis用 参考文献と目次の見出しのバグ回避, サブセクション 10以上対応
maketoc.sh
Raw
#!/bin/bash
echo " <style> h2:before {content:none;}</style>

## 目次

<dl class=\"toc\">"
pdfgrep -n '(^第[0-9]章)|([0-9]\.){2,}|^参考|^謝辞|^付録' $1 |grep '^[0-9]*:[^ ]'|awk -F: '
{
    if ($2 ~ /([0-9]\.){3}/) {
        print "<div><dt class=\"depth-3\">",$2, "</dt><dd>",$1,"</dd></div>"  
    } else if ($2 ~ /([0-9]\.){2}/) {
        print "<div><dt class=\"depth-2\">",$2, "</dt><dd>",$1,"</dd></div>"        
    } else {
        print "<div><dt>",$2, "</dt><dd>",$1,"</dd></div>"        
    } 
}'
echo '</dl>'