MD-question: Is it possible to assign colours to par of my text?

I am slowly getting into using MD. However, I cannot figure out if it is possible to give part of a text a specific colour? In the same way, I can use italics or bold?
As far as I understand things, a CSS is needed, and I have to look more into how to use that. But will I find what I’m looking for?

Also: can anyone recommend a good MD-guide?

This is the guide that I use: https://www.markdownguide.org.

There is nothing out of the box to will enable you to colour text, and so yes, this will get you into the realm of custom CSS or mixed mode (incorporating HTML) which will break the beautiful simplicity of MD, and I’d expect that the different flavours of md will not all play nicely with the various md editors, DT included.

There are some great examples of using CSS to style md on this forum, especially the guides written by @chrillek : CSS for Markdown – the series.

My simple go-to solution that I actually use a lot to make text jump out is highlighting. The extended markdown syntax states that ‘some Markdown processors allow you to highlight text’. Here is what this will look like in DT:

Screenshot 2024-07-18 at 06.15.15

3 Likes

I find The Markdown Guide very helpful. But don’t overlook the section on markdown documents on page 40 of the manual (also available through the in-app Help).

Stephen

4 Likes

It’s not clear what you are looking for, but assuming that you want to “assign colour” to an arbitrary span of text in your MD: no, you can’t do that. Not with MD, not with CSS.

And that is a Good Thing™. MD, as HTML, is about markup, i.e. semantics. That’s why in HTML “bold” and “italic” are very much unfashionable and replaced with the strong and em element. Colo(u)r as font weight and slant are about representation, not semantics.

MD had been conceived to make production of HTML easier. As such, it offers simpler markup, especially no inline markup but _ and * (yes, I know that these are for italic and bold – because MD is fairly old. In HTML, they should still be rendered as em and strong).

You could use CSS that assigns color(s) to these elements. Unusual, but feasible. Or you could follow @SebMacV’s idea to use == markup for highlighted text and define your own CSS rule for the mark element. In addition, DT supports CriticMarkup, which provides additional inline markup codes. You’d have to figure out how those are translated into HTML and then style these in CSS.

3 Likes

Thanks for your response! Aww - to distinguish between representation and semantics makes things more complicated than I anticipated, but it makes perfect sense.

When you write, ‘You could use CSS that assigns color(s) to these elements’ - does that mean I can only assign a colour to elements that are bold and italic? I cannot define a third element?

I’ll have a look at SebMacV’s idea! Or CriticMarkup!

1 Like

Great advice, thank you. I do have the markdown guide, but I have a very hard time reading manuals without ‘hands on’. I think I will find a CSS course to get me started :slight_smile:

I’m puzzled about the simplicity of MD. My son writes his assignments for university in MD - through ‘R’. That seems far from simple, and I have suggested finding something simpler(!) so he can concentrate on the text’s content, not the formatting (and compiling) of the text. He seems happy, which, of course, is the most important. I would be greatly disturbed in my writing …

1 Like

Based on my decades of using computer writing tools … if you want that sort of control over the format of your document … use a tool that is built for that. RTF as a format, or Pages, or Word, or … a very long list. Just IMHO. Trying to bend MarkDown to your will for this sort of thing, might be fun and a learning exploration, it will detract from your writing which I assume is a priority.

1 Like

From my experience as a student, lifelong learner, inveterate note-taker, and today an academic writer, this is key. When you are writing, you want nothing to get into the way of expressing your ideas. For me too, that definitely includes issues like markup and presentation. I do get that creating for instance class notes brings the additional challenges of organisation, especially for the purposes of revision and for instance assessment prep.

There are popular reading and study apps to help with colour coding and the organisation of thoughts and evidence, especially from digital reading content: e.g. https://www.marginnote.com, or, https://readwise.io. or https://highlightsapp.net. Some will allow for the extraction of notes to md. Personally, I have always been interested in these apps, but ultimately steer clear of them as for me they bring as much complication as they do enlightenment (and some operate within their own siloed note-taking environments, which I don’t like). For virtually all my learning, note-taking in meeting, seminars, at conference, and so on, I stick to annotating PDFs and print books, and alongside these, my own notes in markdown.

I don’t know about R with MD – but R is about statistics and probably equations. Those are never “simple” in any markup. Not even in TeX which has been conceived mainly for equations.

That’s what I said: MD (as HTML, XML and many other markup languages) are not about formatting but about content and its structure. If someone thinks about “formatting” when writing MD, they are making things more complicated than they should be.

1 Like

Absolutely! I use ‘distract-free’ apps when I write myself. And not MD :slight_smile: MD is only for ‘fleeting notes’, ‘reference notes’ and ‘permanent notes’ in the Zettelkästen system

1 Like

Yup - but try as a parent to convince kids (even adult kids) about that!

If you are going to do that why not just use HTML? What benefit do you get from Markup in that case?

1 Like

Kids will convince themselves once they have tried giving each word a different color by wrapping it in <span>, and gotten bored with that before dinner. Adults are more mature in this regard, since they will get bored before they even try it out.

1 Like