Highlight INSIDE of a code block

I take notes that involves multiline code blocks. Is there a way to highlight a line inside a code block so that I can call out the importance of the specific line please?

You can use Obsidian-Code-Styler… It will let you highlight whatever you want. For example, we can highlight lines 2 and lines from 7 to 11

```js {2,7-11} 
for (let i = 0; i < 5; i++) {
  console.log(i);
}

// Conditional statement example
const condition = true;
if (condition) {
  console.log('Condition is true');
} else {
  console.log('Condition is false');
}```

And obtain:

3 Likes

You could also use comments (the programming language’s comments, not Obsidian’s) as you would in actual code.

Or split the code block into multiple blocks blocks interspersed with normal text, or repeat the relevant line in the text.

Hi @zhens, does the solution work for you? If yes, please mark the answer as a solution to help others in the future. Thanks.

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