diff --git a/packages/zmarkdown/common.js b/packages/zmarkdown/common.js index b252d4a6d..5b625ba73 100644 --- a/packages/zmarkdown/common.js +++ b/packages/zmarkdown/common.js @@ -33,10 +33,15 @@ module.exports = ( parser.use(processor, processorConfig) } + // Regenerate footnotes postfix on extracts + const doRegenerate = (processor === 'html' && processorConfig._regenerateFootnotePostfix) + const regenerator = processorConfig._regenerateFootnotePostfix + return (input, cb) => { if (typeof cb !== 'function') { return new Promise((resolve, reject) => parser.process(input, (err, vfile) => { + if (doRegenerate) regenerator() if (err) return reject(err) resolve(vfile) @@ -44,6 +49,7 @@ module.exports = ( } parser.process(input, (err, vfile) => { + if (doRegenerate) regenerator() if (err) return cb(err) cb(null, vfile) diff --git a/packages/zmarkdown/config/html/index.js b/packages/zmarkdown/config/html/index.js index 7d16e6330..f1d451012 100644 --- a/packages/zmarkdown/config/html/index.js +++ b/packages/zmarkdown/config/html/index.js @@ -1,5 +1,7 @@ const shortid = require('shortid') +let currentFootnotePostfix = shortid.generate() + module.exports = { autolinkHeadings: { behaviour: 'append', @@ -22,7 +24,11 @@ module.exports = { sanitize: require('../sanitize'), - postfixFootnotes: (agg) => `${agg}-${shortid.generate()}`, + postfixFootnotes: (agg) => `${agg}-${currentFootnotePostfix}`, + + _regenerateFootnotePostfix: () => { + currentFootnotePostfix = shortid.generate() + }, postProcessors: { iframeWrappers: require('./iframe-wrappers'),