Replies: 1 comment
-
Hey! This has been addressed in [email protected], @astrojs/[email protected] (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
-
Can we add
data-language
or other attribute in the rendered<pre>
block? or provide an optional config attribute toMarkdownRenderingOptions
inrenderMarkdown
function(@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