Paste a transcript from Google Docs. This tool replaces footnote references with \s*]*href="#sources"[^>]*>[^<]*<\/a>\s*<\/p>/gi, '');
// Remove empty paragraphs
bodyHTML = bodyHTML.replace(/ \s*<\/p>/gi, '');
// Normalize whitespace
bodyHTML = bodyHTML.replace(/\n{3,}/g, '\n\n');
return { output: bodyHTML.trim(), endnoteCount };
}
function cleanInline(html) {
return html
.replace(/\s*style="[^"]*"/gi, '')
.replace(/\s*class="[^"]*"/gi, '')
.replace(/\s*id="[^"]*"/gi, '')
.replace(/([\s\S]*?)<\/span>/gi, '$1');
}
function stripToText(html) {
// Keep , , but strip other tags
let t = html;
// Preserve text links
// Preserve text and text
// Strip everything else
t = t.replace(/<(?!\/?(?:em|i|a\s)[^>]*>)[^>]+>/gi, '');
// But that regex is tricky — let's be more precise:
// Actually, let's keep it simple: strip all tags, keep text + URLs as plain text
// The shortcode content can contain HTML, but let's keep it clean
t = html
.replace(/<\/?span[^>]*>/gi, '')
.replace(/<\/?p[^>]*>/gi, '')
.replace(/<\/?div[^>]*>/gi, '')
.replace(/<\/?strong[^>]*>/gi, '')
.replace(/<\/?sup[^>]*>/gi, '')
.replace(/\s*style="[^"]*"/gi, '')
.replace(/\s*class="[^"]*"/gi, '')
.replace(/\s*id="[^"]*"/gi, '');
return t.replace(/\s{2,}/g, ' ').trim();
}
function showStatus(msg, type) {
const el = document.getElementById('status');
el.textContent = msg;
el.className = type;
}
function copyOutput() {
const output = document.getElementById('output');
output.select();
document.execCommand('copy');
const btn = document.querySelector('.btn-copy');
const orig = btn.textContent;
btn.textContent = 'Copied ✓';
btn.style.background = '#2D8A56';
setTimeout(() => { btn.textContent = orig; btn.style.background = ''; }, 2000);
}
function clearAll() {
document.getElementById('input').value = '';
document.getElementById('output').value = '';
document.getElementById('output-section').classList.remove('visible');
document.getElementById('status').className = '';
document.getElementById('status').style.display = 'none';
document.getElementById('stats').innerHTML = '';
}
5` : `6`;
}
);
// Pattern: bare NUM without
bodyHTML = bodyHTML.replace(
/]*href="[^"]*(?:bookmark=id\.|docs\.google\.com\/document)[^"]*"[^>]*>(\d+)<\/a>/gi,
(match, numStr) => {
if (match.includes('efn_note')) return match;
const n = actualNum(numStr);
const note = endnoteMap[n];
return note ? `7` : `8`;
}
);
// ---- Clean up ----
bodyHTML = cleanInline(bodyHTML);
// Remove "View Sources" links
bodyHTML = bodyHTML.replace(/