Skip to content

Enable the restriction of attributes #942

@MrSpoocy

Description

@MrSpoocy

Description

I would like to customize the extension https://commonmark.thephpleague.com/2.3/extensions/attributes/ so that you can limit the attributes of the user by configuration. Currently I give the user too much freedom once the extension is activated because e.g. I only want the user to be able to set values for bootstrap pull-left as class.

If restricted is true (default: false that there is no BC), then only the keys in the configuration are allowed. If false, then only the values of the specified keys are restricted.

Example

'attributes' => [
    'restricted' => true,
    'class' => ['multiple value', 'allowed'],
    'id' => 'allowed_value',
    'title' => function ($value) {
        if (strlen($value) > 10) {
            return true;
        } else {
            return false;
       }
    },
    // Allow the key and accept any value in case the restricted is true
    'font' => null,
]

Did this project help you today? Did it make you happy in any way?

No response

Metadata

Metadata

Assignees

Labels

enhancementNew functionality or behavior

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions