sc0ttj / mdsh

A simple static site generator, using Markdown and Bash
https://sc0ttj.github.io/mdsh/
10 stars 0 forks source link

Add plugins for mdshell #13

Closed sc0ttj closed 5 years ago

sc0ttj commented 5 years ago

At the point of the script where mdshell is about to append $line to $text, it should pass $line through a list of available plugins.

Something like

for plugin in plugins/mdshell/*.sh
do
  line="$(echo "$line" | plugin)"
done

An example plugin script:

while read line
do
  [ "$(echo "$line" | grep 'foo')" != "" ] && echo '**'"$line"'**' || echo $line
done < "${1:-/dev/stdin}"

If a line contained 'foo', it would be made bold.

sc0ttj commented 5 years ago

Should use

while IFS= read -r line

to preserve whitespace and newlines, and backslashes