Replies: 1 comment
-
|
Hey! This has been addressed in astro@4.6.0, @astrojs/markdown-remark@5.1.0 (withastro/astro#10739): Adds a For example, the following Markdown code block will expose This allows retrieving the language in a rehype plugin from node.properties.dataLanguage by accessing the // myRehypePre.js
import { visit } from "unist-util-visit";
export default function myRehypePre() {
return (tree) => {
visit(tree, { tagName: "pre" }, (node) => {
const lang = node.properties.dataLanguage;
[...]
});
};
}Note: The The data-language attribute may also be used in css rules: pre::before {
content: attr(data-language);
}
pre[data-language='javascript'] {
font-size: 2rem;
} |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Can we add
data-languageor other attribute in the rendered<pre>block? or provide an optional config attribute toMarkdownRenderingOptionsinrenderMarkdownfunction(@astrojs/markdown-remark)?I can not customized the style of code block when using settings:
syntaxHighlight: 'prism'orsyntaxHighlight: 'shiki'.The reason why I need this is: I'm plan to add a language flag to the code block with CSS by using content like this
I can't find any language identifier in the rendered
<pre>or<code>tag.Beta Was this translation helpful? Give feedback.
All reactions