Help Adding Color to an Individual Custom Code Block #8221
-
Hello, I'm sure it's been mentioned before how to do this, however the last place I saw it work with was Codehilite, which is now unsupported. As you can see, if you look at the Roblox Lua Style Guide, you can see that there are some "Good:", "Bad:", and "Exception:" areas above some of the code blocks. Some of the code blocks are also colored, but don't contain any title above. I've tried the following in my
Sorry, I'm an ammeteur at mkdocs, so for anyone reading this, you're probably thinking I'm an absolute idiot. Here's my mkdocs.yml file:
|
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
Hello @GreenTheBlaze, Assuming you're doing it correctly, then with the ```lua { .style-good }
-- Without this condition, the aircraft hangar would fill up with water.
if waterLevelTooHigh() then
drainHangar()
end
```
So your CSS should have a switcheroo in the rule: .md-typeset .style-good * {
color: green;
font-weight: bold;
margin-bottom: 0.25em;
}
/* Green background for code blocks with .style-good */
.md-typeset .style-good pre > code {
background-color: #ecffe5;
display: block;
padding: 1em;
border-radius: 4px;
} Example: 8221-material.zip Updated example: 8221-material.zip Also I see you've added this to your highlightjs: true
hljs_languages:
- lua this is a theme setting exclusive to the default |
Beta Was this translation helpful? Give feedback.
Hello @GreenTheBlaze,
you haven't provided the way you're creating the code block in your markdown file, how you're adding the style-good class.
Assuming you're doing it correctly, then with the
highlight
extension the special class gets added to a div wrapper as parent of the pre and code tags.<div class="language-lua style-good highlight">
So your CSS should have a switcheroo in the rule: