Currently, any errors returned by anything ran asynchronously (e.g. mermaid diagram generation) is ignored during a PDF/HTML export. This causes the export to succeed even if a failure is found. We should instead detect that, display an error in stderr, and exit(1).
This is the second part of #824 but more general.