tex2html.sh 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  1. #!/bin/bash
  2. # 06-07-2016
  3. # Licence : GPLv3
  4. echo "generating complete file"
  5. if [ ! -d ../output/images ]; then
  6. mkdir ../output/images
  7. fi
  8. if [ ! -d ../output/sources ]; then
  9. mkdir ../output/sources
  10. fi
  11. if [ -f content.textile ]; then
  12. rm content.textile
  13. fi
  14. touch content.textile
  15. echo "" > /tmp/summary
  16. # _ _
  17. # | | | |
  18. # ___ ___ _ __ | |_ ___ _ __ | |_
  19. # / __/ _ \| '_ \| __/ _ \ '_ \| __|
  20. # | (_| (_) | | | | || __/ | | | |_
  21. # \___\___/|_| |_|\__\___|_| |_|\__|
  22. echo "<section id='main'>" >> content.textile
  23. for i in ../content/*; do
  24. # if folder if not sys if not modele
  25. if [ -d "$i" ] && [ "$i" != "../model" ]; then
  26. # if readme exists
  27. if [ -f "$i/readme.textile" ]; then
  28. # user name
  29. # record readme content on variable
  30. cont=$(cat "$i/readme.textile")
  31. # echo "$cont"
  32. # user=$(grep "h1\.\s*.+" "$i/readme.textile")
  33. # user="${cont% h1}"
  34. # user=$(expr "$cont" : "h1. \(.*\)$")
  35. # echo "user : $user"
  36. u=${i/..\//}
  37. # record link for menu
  38. # echo "<li><a href='#$u'>$u</a></li>" >> /tmp/summary
  39. echo "* \"$u\":#$u" >> /tmp/summary
  40. # right html and contents on main content.textile
  41. echo "<div id='$u' class='user'>" >> content.textile
  42. # add user content to main content
  43. echo "<section class='content'>"$'\n' >> content.textile
  44. # add content to main content.textile
  45. cat "$i/readme.textile" >> content.textile
  46. echo $'\n'"</section>" >> content.textile
  47. # get folder name
  48. folder=$(basename "$i")
  49. # _
  50. # (_)
  51. # _ _ __ ___ __ _ __ _ ___ ___
  52. # | | '_ ` _ \ / _` |/ _` |/ _ \/ __|
  53. # | | | | | | | (_| | (_| | __/\__ \
  54. # |_|_| |_| |_|\__,_|\__, |\___||___/
  55. # __/ |
  56. # |___/
  57. images=""
  58. l=0
  59. echo "<section class='images'>"$'\n' >> content.textile
  60. for img in $i/images/*; do
  61. # echo "images : $img"
  62. if [ -f "$img" ]; then
  63. # record file name
  64. fn=$(basename "$img")
  65. counter=$(printf %02d $l)
  66. # record extension
  67. ext="${fn##*.}"
  68. # record new image name
  69. fimg="$folder-$counter.$ext"
  70. # copy image file with new name
  71. cp -f "$img" ../output/images/$fimg
  72. # replace image name in main content.textile file
  73. sed -i "s/images\/$fn/images\/$fimg/g" content.textile
  74. # find "content.textile" -print0 | xargs -0 sed -i '' -e "s/images\/$fn/images\/$fimg/g"
  75. l=$(($l+1))
  76. # if image is not on content ...
  77. if [[ ! "$cont" =~ "images/$fn" ]]; then
  78. # ... add it at end of content
  79. echo "* !images/$fimg!" >> content.textile
  80. fi
  81. fi
  82. done
  83. echo $'\n'"</section>" >> content.textile
  84. # _________ __ _______________ _____
  85. # / ___/ __ \/ / / / ___/ ___/ _ \/ ___/
  86. # (__ ) /_/ / /_/ / / / /__/ __(__ )
  87. # /____/\____/\__,_/_/ \___/\___/____/
  88. #
  89. echo "<section class='sources'>"$'\n' >> content.textile
  90. for src in $i/sources/*; do
  91. # echo "patch : $src"
  92. if [ -f "$src" ]; then
  93. # if image is not on content ...
  94. if [[ ! "$src" =~ "~" ]]; then
  95. # record file name
  96. fn=$(basename "$src")
  97. cp -f "$src" ../output/sources/$fn
  98. # echo $'\r'"<li>" >> content.textile
  99. echo "* \"$fn\":sources/$fn" >> content.textile
  100. # echo $'\r'"</li>" >> content.textile
  101. fi
  102. fi
  103. done
  104. echo $'\n'"</section>" >> content.textile
  105. echo "</div>" >> content.textile
  106. echo '<div class="pagebreak"></div>' >> content.textile
  107. fi
  108. fi
  109. done
  110. # end main section
  111. echo "</section>" >> content.textile
  112. # _ _
  113. # | | | |
  114. # | |__ ___ __ _ __| | ___ _ __
  115. # | '_ \ / _ \/ _` |/ _` |/ _ \ '__|
  116. # | | | | __/ (_| | (_| | __/ |
  117. # |_| |_|\___|\__,_|\__,_|\___|_|
  118. touch /tmp/header
  119. echo "<header id='header'>"$'\n' > /tmp/header
  120. echo "h1. OLA#3 Documentation"$'\n' >> /tmp/header
  121. echo "<nav id='menu'>"$'\n' >> /tmp/header
  122. cat /tmp/summary >> /tmp/header
  123. echo $'\n'"</nav>" >> /tmp/header
  124. echo "</header>" >> /tmp/header
  125. cat /tmp/header|cat - content.textile > /tmp/out && mv /tmp/out content.textile
  126. pandoc -s \
  127. -f textile \
  128. -t html5 -o ../output/index.html \
  129. -H css/main.css \
  130. -A script.tpl.html \
  131. content.textile
  132. cp -r fonts ../output/
  133. # echo "export markdown as html"
  134. # pandoc -s \
  135. # -f markdown+hard_line_breaks+auto_identifiers+ascii_identifiers+tex_math_dollars+pipe_tables+all_symbols_escapable \
  136. # -t html5 -o index.html \
  137. # -c fonts/amiri/amiri.css \
  138. # -H css/styles.css \
  139. # -B body-base-top.tpl.html \
  140. # -A body-base-bot.tpl.html \
  141. # -A js/jquery.min.js \
  142. # -A js/script.js \
  143. # # -A js/css-regions-polyfill.min.js \
  144. # -A body-base-end.tpl.html \
  145. # pad.md