Skip to content

NotWoods/expressive-code-plugin-data-lang

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

expressive-code-plugin-data-lang

A third-party plugin for Expressive Code, an engine for presenting source code on the web.

It adds a data-lang="<language>" attribute onto the root HTML element of the code block (usually the Frame <figure> element).

This can be styled with psuedo-elements to display the code block language to the website user.

HTML code block in a webpage, with "html" written in the bottom right corner

Example usage

// astro.config.js
import { defineConfig } from "astro/config";
import expressiveCode from "astro-expressive-code";
import { pluginDataLang } from "expressive-code-plugin-data-lang";

export default defineConfig({
  integrations: [
    expressiveCode({
      plugins: [pluginDataLang()],
    }),
  ],
});

Example CSS for showing the psuedo-element

.expressive-code .frame::after {
  content: attr(data-lang);
  position: absolute;
  right: 1em;
  bottom: 1em;
  opacity: 0.7;
}

About

Adds data-lang="<language>" to Expressive Code blocks

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published