{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://getcaute.com/card-format/1/highlights.schema.json",
  "title": "highlights.json",
  "description": "Every marked passage, with the words it marks.",
  "$defs": {
    "datetime": {
      "type": "string",
      "pattern": "^\\d{4}-\\d{2}-\\d{2}[ T]\\d{2}:\\d{2}:\\d{2}(\\.\\d+)?([+-]\\d{2}:\\d{2}|Z)$",
      "description": "A date and time with its offset (RFC 3339), written with a space between date and time: 2026-10-14 03:04:05.123456+00:00. Fractional seconds are left out when they are zero."
    },
    "uuid": {
      "type": "string",
      "pattern": "^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"
    }
  },
  "type": "array",
  "items": {
    "type": "object",
    "required": [
      "id",
      "item_id",
      "item_title",
      "quote",
      "anchor",
      "created_at"
    ],
    "additionalProperties": false,
    "properties": {
      "id": {
        "$ref": "#/$defs/uuid"
      },
      "item_id": {
        "$ref": "#/$defs/uuid",
        "description": "The card the passage is in."
      },
      "item_title": {
        "anyOf": [
          {
            "type": "string"
          },
          {
            "type": "null"
          }
        ]
      },
      "quote": {
        "anyOf": [
          {
            "type": "string",
            "description": "The words marked, cut from the card's text."
          },
          {
            "type": "null"
          }
        ]
      },
      "anchor": {
        "type": "object",
        "description": "Where the passage is: char_start and char_end, in code points into the card's text, and sometimes more (a page, a time).",
        "required": [
          "char_start"
        ],
        "properties": {
          "char_start": {
            "type": "integer",
            "minimum": 0
          },
          "char_end": {
            "type": "integer",
            "minimum": 0
          }
        }
      },
      "created_at": {
        "$ref": "#/$defs/datetime"
      }
    }
  }
}
