Skip to main content

parseAttributes

@blockslides/core


@blockslides/core / parseAttributes

Function: parseAttributes()

parseAttributes(attrString): Record<string, any>

Defined in: blockslides/packages/core/src/utilities/markdown/attributeUtils.ts:26

Parses a Pandoc-style attribute string into an object.

Supports the following patterns:

  • Classes: .className{ class: 'className' }
  • IDs: #myId{ id: 'myId' }
  • Key-value pairs: key="value"{ key: 'value' }
  • Boolean attributes: disabled{ disabled: true }

Parameters

attrString

string

The attribute string to parse

Returns

Record<string, any>

Parsed attributes object

Example

parseAttributes('.btn #submit disabled type="button"')
// → { class: 'btn', id: 'submit', disabled: true, type: 'button' }