Here is an updated version that works for both pages and
entries. Unlike the previous version, this allows you to
embed variables right in your entry, just like you can embed
variables in templates. And of course, you can do command
substitution via $(..) or `..`, just remember to follow the
same escaping rules shown at the bottom of the nanoblogger
user manual when you don't want your writing to be
misinterpreted as shell commands.
$ more plugins/entry/format/bash.sh
plugins/page/format/bash.sh | cat
::::::::::::::
plugins/entry/format/bash.sh
::::::::::::::
# NanoBlogger plugin to filter Bash script content
BASH_HERE="__BASH_HERE:$$$RANDOM$$:BASH_HERE__"
eval "NB_EntryBody=\$( head -n -1 <<\$BASH_HERE
$NB_EntryBody
\$BASH_HERE )"
::::::::::::::
plugins/page/format/bash.sh
::::::::::::::
# NanoBlogger plugin to filter Bash script content
BASH_HERE="__BASH_HERE:$$$RANDOM$$:BASH_HERE__"
eval "MKPAGE_CONTENT=\$( head -n -1 <<\$BASH_HERE
$MKPAGE_CONTENT
\$BASH_HERE )"
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Logged In: YES
user_id=315014
Here is an updated version that works for both pages and
entries. Unlike the previous version, this allows you to
embed variables right in your entry, just like you can embed
variables in templates. And of course, you can do command
substitution via $(..) or `..`, just remember to follow the
same escaping rules shown at the bottom of the nanoblogger
user manual when you don't want your writing to be
misinterpreted as shell commands.
$ more plugins/entry/format/bash.sh
plugins/page/format/bash.sh | cat
::::::::::::::
plugins/entry/format/bash.sh
::::::::::::::
# NanoBlogger plugin to filter Bash script content
BASH_HERE="__BASH_HERE:$$$RANDOM$$:BASH_HERE__"
eval "NB_EntryBody=\$( head -n -1 <<\$BASH_HERE
$NB_EntryBody
\$BASH_HERE )"
::::::::::::::
plugins/page/format/bash.sh
::::::::::::::
# NanoBlogger plugin to filter Bash script content
BASH_HERE="__BASH_HERE:$$$RANDOM$$:BASH_HERE__"
eval "MKPAGE_CONTENT=\$( head -n -1 <<\$BASH_HERE
$MKPAGE_CONTENT
\$BASH_HERE )"