title: How to split in a string only when delimiter does not occur in code-formatted block?
body: <p>I'm making an app that splits markdown content at each '---', and displays each as a slide.</p>
  <p>However, there is an error of splitting when there is a <code>---</code> in a code block. In that case it should not be used as a split delimiter.</p>
  <p>How can I split the input by '---', ignoring any such mark in code blocks?</p>
  <p>Example:</p>
  <pre class="lang-js prettyprint-override"><code>const str = `
  
  slide1
  
  --- // This is the delimiter to split the string into slides.
  
  ```code 
  -
  --
  --- // I don't want to split here, as it is part of a code block
  ``` // 
  
  --- // Another delimiter to split at.
  
  slide2
  
  ---
  
  ```code 
  var a = 0
  ``` //
  
  
  `
  </code></pre>
  <p>The expected output should consist of 4 parts, not 5:</p>
  <pre class="lang-js prettyprint-override"><code>[`
  
  slide1
  
  `,
  
  `
  ```code 
  -
  --
  --- // I don't want to split here, as it is part of a code block
  ``` // 
  
  `,
  
  `
  slide2
  
  ---
  
  ```code 
  var a = 0
  ``` //
  
  
  `]
  </code></pre>