pygsgallery.sh 983 B

12345678910111213141516171819202122232425
  1. #!/bin/bash
  2. out='<div class="all"><link rel="stylesheet" href="/plugins/PicoPygments/pygsgallery.sh.css" type="text/css" /><link rel="stylesheet" href="/plugins/PicoPygments/css/_common.css" type="text/css" />'
  3. toc='<input id="dd" type="checkbox"/><label class=boxed for="dd">TOC</label><div class="boxed ddc">'
  4. post='</div>'
  5. for file in css/custom*.css; do
  6. name="${file##*/}"
  7. name="${name%.*}"
  8. name="${name#custom-}"
  9. mapfile -s1 style < "$file"
  10. style=("${style[@]//.pcpg/.pcpg.$name}")
  11. out="$out<div><style>${style[@]}</style><h3 id=\"$name\">$name<a href=\"#\"></a></h3>"
  12. code="<pre class=\"pcpg $name\"><code class=\"pcpg $name\">"
  13. while read -r class text; do
  14. ## "hll" means highlighted (current) line
  15. code="$code<span class=\"$class\">$text</span>\t"
  16. done < pygsgallery.classes
  17. out="$out$code</code></pre></div>"
  18. toc="$toc<a href=\"#$name\">$name</a>"
  19. >&2 echo "Processing $name"
  20. done
  21. echo -e "$toc</div>$out$post"