mdshell.sh parses markdown files, and can parse bash sub-shells inside the markdown, where the sub-shells use the $(some code) syntax.
Problem
The code which grabs the contents of the $() sub-shell is very buggy.
Examples:
This will work:
Some para text $(foo) more text.
^ the output of the foo command will appear in the final markdown.
This also works:
Some para.
$(cmd1;
cmd2)
More text.
^ the output of both cmd1 and cmd2 appear in the final markdown.
This will not work:
Some text.
$(cat file)
^ fails if file contains $() or various escaped quotes or parentheses..
This will not work:
Some para.
$(cmd1 $(foo))
More text
^ the foo command (and remaining document!) will not get parsed correctly
This will not work:
Some para.
$(echo "$foo \"blah\" $more")
More text
^ escaped ", (, ) and ' all cause problems...
Solution
Don't look for $() in markdown files to drop in and out of sub-shells... It's too brittle..
Use <?bash foo ?>, as this is unambiguous and way less brittle.. and it is what Bash on Steroids uses, which would make a better templating system than mo - more consistency in syntax across markdown and templates.
mdshell.sh
parses markdown files, and can parse bash sub-shells inside the markdown, where the sub-shells use the$(some code)
syntax.Problem
The code which grabs the contents of the
$()
sub-shell is very buggy.Examples:
This will work:
^ the output of the
foo
command will appear in the final markdown.This also works:
^ the output of both
cmd1
andcmd2
appear in the final markdown.This will not work:
^ fails if file contains
$()
or various escaped quotes or parentheses..This will not work:
^ the
foo
command (and remaining document!) will not get parsed correctlyThis will not work:
^ escaped
"
,(
,)
and'
all cause problems...Solution
Don't look for
$()
in markdown files to drop in and out of sub-shells... It's too brittle..Use
<?bash foo ?>
, as this is unambiguous and way less brittle.. and it is what Bash on Steroids uses, which would make a better templating system thanmo
- more consistency in syntax across markdown and templates.