diff --git a/demo-site/insertr/insertr.js b/demo-site/insertr/insertr.js index 6da8a14..e6fdb16 100644 --- a/demo-site/insertr/insertr.js +++ b/demo-site/insertr/insertr.js @@ -302,7 +302,8 @@ class Insertr { // Check for headings if (line.match(/^#{1,6}\s/)) { if (currentBlock) blocks.push(currentBlock); - const level = line.match(/^#+/)[0].length; + const hashMatch = line.match(/^#+/); + const level = hashMatch ? hashMatch[0].length : 1; currentBlock = { type: `h${level}`, content: line.replace(/^#+\s*/, '').trim()