-
-
Notifications
You must be signed in to change notification settings - Fork 32
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
Allow custom attributes to be applied to pre and code tags #48
Allow custom attributes to be applied to pre and code tags #48
Conversation
Joins the formattedAttributes with space characters to allow for multiple attributes in the attribute map. Also fixes the test to ensure support for multiple attributes.
Going to merge this but I wonder if we should also change I’ll probably also remove the string support as I think the object literal support is probably sufficient (if you disagree please chime in!) |
Filed the tabindex question at #49 |
This is fantastic! I added PR #50 to enable dynamic attributes to be generated based on context data — this will for example allow the language to be provided directly as an attribute (see #22 use-case, solved with example below). I hope this isn't already available with this PR as I couldn't get it to work, but please let me know if I'm wrong. eleventyConfig.addPlugin(pluginSyntaxHighlight, {
preAttributes: {
'data-lang': function (context) { return context.language.toUpperCase(); }
}
}); |
‘@11ty/eleventy-plugin-syntaxhighlight’ recently [added][1] support for preAttributes that can be used to put a tabindex attributes on a scrollable (`overflow: auto;`) `<pre>` element. It's not yet the default setting for these elements, but this sets it through the eleventy config. [1]: 11ty/eleventy-plugin-syntaxhighlight#48
‘@11ty/eleventy-plugin-syntaxhighlight’ recently [added][1] support for preAttributes that can be used to put a tabindex attributes on a scrollable (`overflow: auto;`) `<pre>` element. It's not yet the default setting for these elements, but this sets it through the eleventy config. [1]: 11ty/eleventy-plugin-syntaxhighlight#48
Fixes #22
I created a function,
getAttributes(attributes)
, that takes either a string or an object of strings or numbers and outputs a string of HTML attributes. This function is then used to allow the use of the followingoptions
:preAttributes
andcodeAttributes
. Usage is as follows:This will add
tabindex="0"
to the<pre>
tag — allowing code blocks with scrollbars to be keyboard accessible — like so: