# net.atchan.richtext.facet

> Published by [atchan.net](https://lexicon.garden/identity/did:plc:vshgahazzq7qwvp2xc6ai27o)

✓ This is the authoritative definition for this NSID.

## Links

- [View on Lexicon Garden](https://lexicon.garden/lexicon/did:plc:vshgahazzq7qwvp2xc6ai27o/net.atchan.richtext.facet)
- [Documentation](https://lexicon.garden/lexicon/did:plc:vshgahazzq7qwvp2xc6ai27o/net.atchan.richtext.facet/docs)
- [Examples](https://lexicon.garden/lexicon/did:plc:vshgahazzq7qwvp2xc6ai27o/net.atchan.richtext.facet/examples)

## Definitions

### `net.atchan.richtext.facet#aa`

**Type**: `object`

Facet feature rendering the range in a Shift_JIS art font, as a block with whitespace preserved. This is a choice of typeface, not a claim about what the range says: it is the font ASCII art (AA) is drawn against, and only in it does the art keep its intended proportions. No other facet is valid inside it.

| Property | Type | Required | Description |
|----------|------|----------|-------------|

### `net.atchan.richtext.facet#pre`

**Type**: `object`

Facet feature marking the range as preformatted text, rendered as a block in a monospace font with whitespace preserved. No other facet is valid inside it.

| Property | Type | Required | Description |
|----------|------|----------|-------------|

### `net.atchan.richtext.facet#ref`

**Type**: `object`

Facet feature marking the range as a quote-link to another post, given by its record key. The range covers the ">>rkey" the author typed.

| Property | Type | Required | Description |
|----------|------|----------|-------------|
| `rkey` | `string` (record-key) | Yes |  |

### `net.atchan.richtext.facet#bold`

**Type**: `object`

Facet feature marking the range as bold.

| Property | Type | Required | Description |
|----------|------|----------|-------------|

### `net.atchan.richtext.facet#code`

**Type**: `object`

Facet feature marking the range as inline code, rendered in a monospace font. No other facet is valid inside it.

| Property | Type | Required | Description |
|----------|------|----------|-------------|

### `net.atchan.richtext.facet#font`

**Type**: `object`

Facet feature rendering the range in a named font

| Property | Type | Required | Description |
|----------|------|----------|-------------|
| `name` | `string` | Yes |  |

### `net.atchan.richtext.facet#link`

**Type**: `object`

Facet feature marking the range as a link to a uri

| Property | Type | Required | Description |
|----------|------|----------|-------------|
| `uri` | `string` (uri) | Yes |  |

### `net.atchan.richtext.facet`

**Type**: `object`

A facet defines a range of rich text within a larger string.

| Property | Type | Required | Description |
|----------|------|----------|-------------|
| `index` | `ref` → `#byteSlice` | Yes |  |
| `features` | `array` | Yes |  |

### `net.atchan.richtext.facet#size`

**Type**: `object`

Facet feature rendering the range at a relative text size from 1 (smallest) to 5 (largest), with 3 being the default.

| Property | Type | Required | Description |
|----------|------|----------|-------------|
| `value` | `integer` | Yes |  |

### `net.atchan.richtext.facet#color`

**Type**: `object`

Facet feature rendering the range in a color, given as a CSS hex color such as "#ff0000".

| Property | Type | Required | Description |
|----------|------|----------|-------------|
| `value` | `string` | Yes |  |

### `net.atchan.richtext.facet#italic`

**Type**: `object`

Facet feature marking the range as italic.

| Property | Type | Required | Description |
|----------|------|----------|-------------|

### `net.atchan.richtext.facet#kaomoji`

**Type**: `object`

Facet feature marking the range as a kaomoji, ideally rendered in a Shift-JIS font.

| Property | Type | Required | Description |
|----------|------|----------|-------------|

### `net.atchan.richtext.facet#spoiler`

**Type**: `object`

Facet feature marking the range as a spoiler, hidden until the reader interacts with it.

| Property | Type | Required | Description |
|----------|------|----------|-------------|

### `net.atchan.richtext.facet#byteSlice`

**Type**: `object`

Specifies the sub-string range a facet feature applies to. Start index is inclusive, end index is exclusive. Indices are zero-indexed, counting bytes of the UTF-8 encoded text. NOTE: some languages, like Javascript, use UTF-16 or Unicode codepoints for string slice indexing; in these languages, convert to byte arrays before working with facets.

| Property | Type | Required | Description |
|----------|------|----------|-------------|
| `byteEnd` | `integer` | Yes |  |
| `byteStart` | `integer` | Yes |  |

### `net.atchan.richtext.facet#underline`

**Type**: `object`

Facet feature marking the range as underlined.

| Property | Type | Required | Description |
|----------|------|----------|-------------|

### `net.atchan.richtext.facet#strikethrough`

**Type**: `object`

Facet feature marking the range as struck through.

| Property | Type | Required | Description |
|----------|------|----------|-------------|

## Raw Schema

```json
{
  "id": "net.atchan.richtext.facet",
  "defs": {
    "aa": {
      "type": "object",
      "properties": {},
      "description": "Facet feature rendering the range in a Shift_JIS art font, as a block with whitespace preserved. This is a choice of typeface, not a claim about what the range says: it is the font ASCII art (AA) is drawn against, and only in it does the art keep its intended proportions. No other facet is valid inside it."
    },
    "pre": {
      "type": "object",
      "properties": {},
      "description": "Facet feature marking the range as preformatted text, rendered as a block in a monospace font with whitespace preserved. No other facet is valid inside it."
    },
    "ref": {
      "type": "object",
      "required": [
        "rkey"
      ],
      "properties": {
        "rkey": {
          "type": "string",
          "format": "record-key"
        }
      },
      "description": "Facet feature marking the range as a quote-link to another post, given by its record key. The range covers the \">>rkey\" the author typed."
    },
    "bold": {
      "type": "object",
      "properties": {},
      "description": "Facet feature marking the range as bold."
    },
    "code": {
      "type": "object",
      "properties": {},
      "description": "Facet feature marking the range as inline code, rendered in a monospace font. No other facet is valid inside it."
    },
    "font": {
      "type": "object",
      "required": [
        "name"
      ],
      "properties": {
        "name": {
          "type": "string"
        }
      },
      "description": "Facet feature rendering the range in a named font"
    },
    "link": {
      "type": "object",
      "required": [
        "uri"
      ],
      "properties": {
        "uri": {
          "type": "string",
          "format": "uri"
        }
      },
      "description": "Facet feature marking the range as a link to a uri"
    },
    "main": {
      "type": "object",
      "required": [
        "index",
        "features"
      ],
      "properties": {
        "index": {
          "ref": "#byteSlice",
          "type": "ref"
        },
        "features": {
          "type": "array",
          "items": {
            "refs": [
              "#bold",
              "#italic",
              "#underline",
              "#strikethrough",
              "#spoiler",
              "#color",
              "#size",
              "#font",
              "#kaomoji",
              "#aa",
              "#code",
              "#pre",
              "#link",
              "#ref"
            ],
            "type": "union"
          },
          "minLength": 1
        }
      },
      "description": "A facet defines a range of rich text within a larger string."
    },
    "size": {
      "type": "object",
      "required": [
        "value"
      ],
      "properties": {
        "value": {
          "type": "integer",
          "maximum": 5,
          "minimum": 1
        }
      },
      "description": "Facet feature rendering the range at a relative text size from 1 (smallest) to 5 (largest), with 3 being the default."
    },
    "color": {
      "type": "object",
      "required": [
        "value"
      ],
      "properties": {
        "value": {
          "type": "string"
        }
      },
      "description": "Facet feature rendering the range in a color, given as a CSS hex color such as \"#ff0000\"."
    },
    "italic": {
      "type": "object",
      "properties": {},
      "description": "Facet feature marking the range as italic."
    },
    "kaomoji": {
      "type": "object",
      "properties": {},
      "description": "Facet feature marking the range as a kaomoji, ideally rendered in a Shift-JIS font."
    },
    "spoiler": {
      "type": "object",
      "properties": {},
      "description": "Facet feature marking the range as a spoiler, hidden until the reader interacts with it."
    },
    "byteSlice": {
      "type": "object",
      "required": [
        "byteStart",
        "byteEnd"
      ],
      "properties": {
        "byteEnd": {
          "type": "integer",
          "minimum": 0
        },
        "byteStart": {
          "type": "integer",
          "minimum": 0
        }
      },
      "description": "Specifies the sub-string range a facet feature applies to. Start index is inclusive, end index is exclusive. Indices are zero-indexed, counting bytes of the UTF-8 encoded text. NOTE: some languages, like Javascript, use UTF-16 or Unicode codepoints for string slice indexing; in these languages, convert to byte arrays before working with facets."
    },
    "underline": {
      "type": "object",
      "properties": {},
      "description": "Facet feature marking the range as underlined."
    },
    "strikethrough": {
      "type": "object",
      "properties": {},
      "description": "Facet feature marking the range as struck through."
    }
  },
  "$type": "com.atproto.lexicon.schema",
  "lexicon": 1
}
```
