Skip to content

Compatibility with markdown-it-attrs #72

@AleksandrHovhannisyan

Description

@AleksandrHovhannisyan

One of the reasons I currently use markdown-it-prism is because it's compatible with markdown-it-attrs, which allows me to specify any custom attribute on an as-needed basis. Like this:

```js {data-copyable=true data-filename="a/file/path"}
const javascript = 'code';
```

I have a use case for this: Some code blocks need to support copying to the clipboard, but others are just for show. The way I currently do this is by specifying a custom inline data-attribute and then using JavaScript to insert buttons only for code blocks that have this attribute. Other code blocks get a file name via a data-attribute that I then show using CSS's attr function.

Unfortunately, this means that I cannot use eleventy-plugin-syntaxhighlight because it ignores those attributes, so this means I can't take advantage of the tabindex enhancement for code blocks that scroll horizontally. Is there a way to forward other attributes to the pre/code tags?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions