• Operand
  • ./bin/ganged/upon.

gram: luck

> ./sample-data-old/blocks.sorting-hat.highlighter

Lenses
(coming soon!)


{
  "id": "blocks.sorting-hat",
  "name": "sortingHat",
  "properties": [
    {
      "name": "$",
      "formula": "🎩 of {/\"[^\"]*\"/:a} by {/\"[^\"]*\"/:b}",
      "visibility": "HIDDEN"
    },
    {
      "name": "type",
      "formula": "a.text().slice(1, -1)",
      "visibility": "HIDDEN"
    },
    {
      "name": "attr",
      "formula": "b.text().slice(1, -1)",
      "visibility": "HIDDEN"
    },
    {
      "name": "block",
      "formula": "$.prev(\"block\")",
      "visibility": "HIDDEN"
    },
    {
      "name": "groupedItems",
      "formula": "return FindAll(type).filter(h => (\n    h.span[0] > block.span[0] &&\n    h.span[1] < block.span[1]\n  ))\n  .groupBy(h => h.data[attr])\n  .map(({group, items}) => {\n    const heading = `- **${group}**`\n\n    return(\n      `${heading}\\n${items.map((item) => (\n        `  ${item.wholeLine().text().trimStart()}`\n      )).join('\\n')}`\n    )\n  })\n.join(\"\\n\")\n",
      "visibility": "HIDDEN"
    },
    {
      "name": "button",
      "formula": "TemplateButton(block, \"group\", `[\\n${groupedItems}\\n]`, \"replace\")",
      "visibility": "INLINE"
    }
  ]
}