Summary
The live TemplateMark dingus is currently broken:
https://templatemark-dingus.netlify.app/
The right-hand preview pane stays blank. I found two issues in the historical v0.16.2 dingus build, one of which appears to be the main cause.
Main issue
The dingus imports ToPdfMake from the @accordproject/markdown-pdf package root:
https://github.com/accordproject/markdown-transform/blob/v0.16.2/packages/dingus/lib/index.js#L12
const ToPdfMake = require('@accordproject/markdown-pdf').ToPdfMake;
But the package root eagerly exports both PdfTransformer and ToPdfMake:
https://github.com/accordproject/markdown-transform/blob/v0.16.2/packages/markdown-pdf/index.js#L22-L23
module.exports.PdfTransformer = require('./lib/PdfTransformer');
module.exports.ToPdfMake = require('./lib/ToPdfMake');
That pulls in browser-unsafe PDF parsing code. In particular:
https://github.com/accordproject/markdown-transform/blob/v0.16.2/packages/markdown-pdf/src/ToCiceroMark.js#L17-L20
require('./domstubs.js').setStubs(global);
let pdfjsLib = require('pdfjs-dist/legacy/build/pdf.js');
and then:
https://github.com/accordproject/markdown-transform/blob/v0.16.2/packages/markdown-pdf/src/domstubs.js#L267-L270
exports.setStubs = function (namespace) {
exported_symbols.forEach(function (key) {
console.assert(!(key in namespace), "property should not be set: " + key);
namespace[key] = exports[key];
});
};
In the browser bundle, global resolves to window, so this tries to assign window.document and crashes startup.
Console errors include:
Assertion failed: property should not be set: document
Uncaught TypeError: Cannot set property document of #<Window> which has only a getter
That appears to abort initialization before the initial preview render runs.
Secondary issue
The dingus template also hard-codes this script:
https://github.com/accordproject/markdown-transform/blob/v0.16.2/packages/dingus/lib/index.pug#L19
script(src='https://twemoji.maxcdn.com/twemoji.min.js')
That URL currently returns invalid content, causing:
Uncaught SyntaxError: Unexpected identifier 'World'
The Twemoji usage is here:
https://github.com/accordproject/markdown-transform/blob/v0.16.2/packages/dingus/lib/index.js#L178-L180
Expected behavior
The default sample input should render in the preview pane.
Actual behavior
The preview pane is blank.
Suggested fix
The main fix seems to be avoiding the @accordproject/markdown-pdf root import in the browser dingus bundle, or changing the package root so importing ToPdfMake does not also require PdfTransformer.
The Twemoji URL should also be updated or removed.
Summary
The live TemplateMark dingus is currently broken:
https://templatemark-dingus.netlify.app/
The right-hand preview pane stays blank. I found two issues in the historical
v0.16.2dingus build, one of which appears to be the main cause.Main issue
The dingus imports
ToPdfMakefrom the@accordproject/markdown-pdfpackage root:https://github.com/accordproject/markdown-transform/blob/v0.16.2/packages/dingus/lib/index.js#L12
But the package root eagerly exports both
PdfTransformerandToPdfMake:https://github.com/accordproject/markdown-transform/blob/v0.16.2/packages/markdown-pdf/index.js#L22-L23
That pulls in browser-unsafe PDF parsing code. In particular:
https://github.com/accordproject/markdown-transform/blob/v0.16.2/packages/markdown-pdf/src/ToCiceroMark.js#L17-L20
and then:
https://github.com/accordproject/markdown-transform/blob/v0.16.2/packages/markdown-pdf/src/domstubs.js#L267-L270
In the browser bundle,
globalresolves towindow, so this tries to assignwindow.documentand crashes startup.Console errors include:
Assertion failed: property should not be set: documentUncaught TypeError: Cannot set property document of #<Window> which has only a getterThat appears to abort initialization before the initial preview render runs.
Secondary issue
The dingus template also hard-codes this script:
https://github.com/accordproject/markdown-transform/blob/v0.16.2/packages/dingus/lib/index.pug#L19
That URL currently returns invalid content, causing:
Uncaught SyntaxError: Unexpected identifier 'World'The Twemoji usage is here:
https://github.com/accordproject/markdown-transform/blob/v0.16.2/packages/dingus/lib/index.js#L178-L180
Expected behavior
The default sample input should render in the preview pane.
Actual behavior
The preview pane is blank.
Suggested fix
The main fix seems to be avoiding the
@accordproject/markdown-pdfroot import in the browser dingus bundle, or changing the package root so importingToPdfMakedoes not also requirePdfTransformer.The Twemoji URL should also be updated or removed.