diff --git a/scripts/export.js b/scripts/export.js
index 30b2bba..939e3bd 100644
--- a/scripts/export.js
+++ b/scripts/export.js
@@ -171,7 +171,7 @@ async function exportInit() {
//For quicker testing use js fiddle: https://jsfiddle.net/xtraeme/x34ao9jp/13/
block.innerHTML = block.innerHTML
- .replace(/ |\u00A0/g, ' ') //Replace =C2=A0 (nbsp non-breaking space) with breaking-space
+ .replace(/ |\u00A0/g, ' ') //Replace =C2=A0 (nbsp non-breaking space) /w breaking-space
.replace(/\t/g, ' ') // Replace tab with 4 non-breaking spaces
.replace(/^ +/gm, function(match) { return ' '.repeat(match.length); }) //Add =C2=A0
.replace(/\n/g, '
');
@@ -182,7 +182,18 @@ async function exportInit() {
}
async function exportMarkdown() {
- const nodes = Array.from(document.querySelectorAll(SELECTOR));
+ const allBlocks = document.querySelectorAll(SELECTOR);
+ const nodes = Array.from(allBlocks);
+
+ // blocks with leading spaces mess up ExportMD markdown conversion. ex/
+ // import package
+ //becomes (spaces are moved to the front of the ''' line)):
+ // '''Python import package
+ //so we remove whitespace after tags and add
and/or \n
+ allBlocks.forEach((block) => {
+ block.innerHTML = block.innerHTML
+ .replace(/(]*>)\s*/g, '$1
\n'); // Add \n or
after opening code tag
+ });
const content = nodes.map(i => processNode(i)).join('');
const updatedContent = nodes.map(i => processNode(i, true)).join('');