Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Persist attributes defined on code blocks #13

Merged
merged 4 commits into from
Sep 28, 2024
Merged

Conversation

joepavitt
Copy link
Contributor

When using https://www.npmjs.com/package/markdown-it-attrs we are able to define attributes to be appended to elements in our markdown, e.g:

paragraph {data-toggle=modal}

would render:

<p data-toggle="modal">paragraph</p>

It does also support injection of attributes on the fenced code blocks, but this Eleventy Plugin does not consider the attrs defined. This PR adds that in such that the introduced parent <div> takes ownership of the attributes.

For example, if, in my markdown, I include:

```python
nums = [x for x in range(10)]
```

```python {data=hello}
nums = [x for x in range(10)]
```

Then the following elements are rendered to my DOM:

Screenshot 2024-09-27 at 14 15 12

@joepavitt
Copy link
Contributor Author

This does also include a change from #12 - happy to revert that in favour of this attrs approach if that's preferred.

Copy link
Member

@kudoh kudoh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks a lot for the PR! This is really helpful.
I’ve reviewed the changes, and everything looks good, so I don’t think we need to revert anything.
I’ll be adding some unit tests after merging and bumping up the version afterward.

@kudoh kudoh merged commit 8307f55 into mamezou-tech:main Sep 28, 2024
1 check failed
@joepavitt
Copy link
Contributor Author

Thanks for such a quick turnaround @kudoh

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants