Anchors don't work in embedded notebook

Here’s a modification of the intoFilter function (from your last thread) that’ll make these links work:

<script type="module">

import {Runtime, Inspector} from "https://cdn.jsdelivr.net/npm/@observablehq/runtime@4/dist/runtime.js";
import notebook from "./YOUR-NOTEBOOK.js";

// modified from https://github.com/observablehq/inspector/blob/master/src/index.js#L51
const intoFilter = function(container, filterFunc) {
  if (typeof container === "string") {
    container = document.querySelector(container);
    if (container == null) throw new Error("container not found");
  }
  return function(variable) {
    if (filterFunc(variable.name)) {
      const div = document.createElement("div");
      if (variable.name) {
        const name = variable.name.split(' ');
        if (name[0] === "viewof" || name[0] === "initial") name.shift();
        if (name.length === 1 && !document.querySelector(name[0])) div.setAttribute("id", name[0]);
      }
      return new Inspector(container.appendChild(div));
    }
  };
};

// you can enter an arbitrary filtering function as the second argument to intoFilter.
// it should take the variable name (a string or undefined) as an input and return a boolean
Runtime.load(notebook, intoFilter(document.body, (name) => name !== "excludeThis"));

</script>

Edit: made more robust; should work better now with viewof and mutable cells.
Edit 2: added missing braces…