#!/bin/bash # This is a really rudementary way to make making file lists less HTML-y # I made it so: # 1) You don't have to write quite as much HTML # 2) The Data columns for each file get to be formatted as Markdown ( is not recognized as a block-level element, so the stuff inside get formatted https://kristaps.bsd.lv/lowdown/lowdown.5.html#HTML_Blocks) # Very roughly, each file list has the same structure: #
Folder Info File Data
# In Markdown you type in something like (without the "# " in front): # # &&fos # Description # &&fs0 # Data 1 # Data 1.1 # Data 1.2 # &&fs # Data 2 # Data 2.1 # Data 2.2 # &&fod # # And the lines starting with && (I'll call them ftags) get replaced by some HTML. The around each file Data is mandatory. # &&fs0 must only be used on before the very first file data. There must be no empty lines, lines mustn't start with spaces, there mustn't be anything around ftags and ftags have to be on their own lines. # The commands have intuitive abbreviations: # &&fos folder start # &&fs0 file start of first file # &&fs file start # &&fod folder end if [ -z "$1" ]; then echo First parameter must be a path exit fi for file in $(find "$1" -type f -name "*.html"); do # Replaces "&&fos" with "
" sed -i 's/^

&&fos$/

/g' "$file" # Replaces "&&fs0" with "" sed -i 's/^&&fs0$/<\/summary>
/g' "$file" # Replaces "&&fs" with "" sed -i 's/^&&fs$/<\/tr>/g' "$file" # Replaces "&&fod" with "
" sed -i 's/^&&fod<\/p>$/<\/tr><\/table><\/details>/g' "$file" done