I have a Hugo-generated static website and in each code snippet I want to place the language name in the bottom right.
I am already able to get the whole class (language-x) in the code tag using a CSS selector but I want to capture only the language name from the class name, not the whole class.
This is a minimum working example of what I have so far:
https://codepen.io/anon/pen/gZWWNP
<html>
<style>
pre {
background: #26282C;
color: #fff;
text-align: left;
padding: 0.5em;
padding-left: 0.5em;
padding-left: .8em;
word-break: break-all;
white-space: pre-wrap;
overflow: auto;
tab-size: 4;
margin-bottom: 20px;
border-left: 5px solid #F27563;
border-bottom-right-radius: 5px;
border-top-right-radius: 5px;
}
code[class*="language-"]:after,
pre[class*="language-"]:after {
content: attr(class);
color: #fff;
font-size: smaller;
font-weight: bold;
display: block;
text-align: right;
padding-top: 5px;
}
</style>
<body>
<pre>
<code class="language-perl6">class Person {
has Str $.firstname;
has Str $.lastname;
has Str $.age;
}
</code>
</pre>
</body>
</html>
In this case, instead of language-perl6 I'd like to display just perl6. I want to keep this as minimal as possible without using any additional tool besides CSS or probably vanilla JS.