<script>
	import Children from 'svelte-exmarkdown/renderer/Children.svelte';
  import { toAnchor } from '$lib/anchors';
  export let children;
  export let properties;

  function flatten(a) {
    if (a.value) {
      return a.value;
    } else if (a.children) {
      return a.children.map(flatten).join('');
    }
  }
</script>

<h2 id={toAnchor(children.map(flatten).join(''))} {...properties}><Children {children} /></h2>