How to change the color of Markdown elements (*, 1., [, $, etc.)?

What I’m trying to do

I would like to set the color of Markdown elements (like *, 1., [, $…) in both the light and dark themes.

The current (Things theme) color is not very visible in dark mode and makes things like $42 and [CLS] be displayed in a funny way (the dollar sign and the brackets don’t look like regular text, when they should, because I escaped them).

Things I have tried

A Google and forum search didn’t turn up anything obvious for a CSS noob. :slight_smile:

I also raise an issue with the Things theme, to no avail.

Give these a try…

.cm-formatting-strong {
  color: violet !important;
}

.cm-formatting-em {
  color: var(--color-blue) !important;
}

.markdown-source-view .cm-formatting-list-ol {
  color: var(--color-green);
}

.cm-s-obsidian span.cm-formatting-link { 
color: var(--color-yellow); 
} 

.cm-s-obsidian span.cm-math {
  color: var(--color-orange);
}

Things →

Default theme (doesn’t need !important) →

1 Like

Thanks.

In order to get the regular text color mentioned in the question, I substituted the color with --text-normal.

The CSS above indeed changes the colors of the markdown elements for numbered lists and strong/emphasis, indeed (number, stars, underline).

Now, unfortunately, things like the escaped Markdown elements I was mentioning are left untouched: \$ and \[ are still quite illegible. They are useful for typing amounts in dollars, or text that contains brackets. What would the CSS be for these?

PS: Is there a way I could answer this question by myself? I tried the CSS explorer (?) with Cmd-Opt-I (macOS), to no avail…

I put the colors in so it was easy to see what was going on. Wasn’t sure if you were looking for everything to be the same color or not. Forgot the escaped characters bit. This should take care of the first character after an escape:

.cm-s-obsidian span.cm-hmd-escape-char {
  color: var(--color-red);
}

Screenshot 2023-04-04 at 23.01.15

Yeah, if you look in the dev tools, there’s a box with an arrow on the top left ( or cmd+shift+c ). Elements at the top, Styles below. Then poke around at things to get an idea of what is what.

Maybe you’ve see this, but it’s a good resource:

2 Likes

I was going to suggest you up upvote this feature request, but then I saw you are the one who posted it! :laughing: (Thanks!) But I’ll leave it here for others.

1 Like

Yes. I had forgotten I had posted it already, and I had missed the response from 2 months ago (which explains that)…

Yesterday I searched before making a feature request to see if someone had already done it — and found that I had, half a year ago. So, you’re not alone. :sweat_smile:

Occasionally it’s necessary to add styles to Markdown material, such as mass variables and CSS characteristics for colour and font sizes.

Nevertheless, neither native Markdown nor any markdown parsers enable the styles used by CSS.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.